activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r385575 - in /incubator/activemq/trunk/activemq-core/src: main/java/org/apache/activemq/advisory/ main/java/org/apache/activemq/broker/ main/java/org/apache/activemq/broker/ft/ main/java/org/apache/activemq/broker/jmx/ main/java/org/apache/...
Date Mon, 13 Mar 2006 15:41:58 GMT
Author: jstrachan
Date: Mon Mar 13 07:41:55 2006
New Revision: 385575

URL: http://svn.apache.org/viewcvs?rev=385575&view=rev
Log:
refactor to allow the MBean createDurableSubscription() method to return the ObjectName of
the newly created subscription

Modified:
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/advisory/AdvisoryBroker.java
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/BrokerBroadcaster.java
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/BrokerFilter.java
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/EmptyBroker.java
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/ErrorBroker.java
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/MutableBrokerFilter.java
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/ft/MasterBroker.java
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/BrokerView.java
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/BrokerViewMBean.java
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/ManagedQueueRegion.java
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/ManagedRegionBroker.java
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/ManagedTempQueueRegion.java
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/ManagedTempTopicRegion.java
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/ManagedTopicRegion.java
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/AbstractRegion.java
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/AbstractSubscription.java
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/Region.java
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/RegionBroker.java
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/Subscription.java
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/TopicRegion.java
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/security/AuthorizationBroker.java
    incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/jmx/MBeanTest.java

Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/advisory/AdvisoryBroker.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/advisory/AdvisoryBroker.java?rev=385575&r1=385574&r2=385575&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/advisory/AdvisoryBroker.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/advisory/AdvisoryBroker.java
Mon Mar 13 07:41:55 2006
@@ -22,6 +22,7 @@
 import org.apache.activemq.broker.BrokerFilter;
 import org.apache.activemq.broker.ConnectionContext;
 import org.apache.activemq.broker.region.Destination;
+import org.apache.activemq.broker.region.Subscription;
 import org.apache.activemq.command.ActiveMQDestination;
 import org.apache.activemq.command.ActiveMQMessage;
 import org.apache.activemq.command.ActiveMQTopic;
@@ -70,8 +71,8 @@
         connections.put(info.getConnectionId(), info);
     }
 
-    public void addConsumer(ConnectionContext context, ConsumerInfo info) throws Exception
{
-        next.addConsumer(context, info);
+    public Subscription addConsumer(ConnectionContext context, ConsumerInfo info) throws
Exception {
+        Subscription answer = next.addConsumer(context, info);
 
         // Don't advise advisory topics.
         if( !AdvisorySupport.isAdvisoryTopic(info.getDestination()) ) { 
@@ -120,6 +121,7 @@
                 }
             }
         }
+        return answer;
     }
 
     public void addProducer(ConnectionContext context, ProducerInfo info) throws Exception
{

Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/BrokerBroadcaster.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/BrokerBroadcaster.java?rev=385575&r1=385574&r2=385575&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/BrokerBroadcaster.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/BrokerBroadcaster.java
Mon Mar 13 07:41:55 2006
@@ -16,6 +16,7 @@
 import java.util.ArrayList;
 import java.util.List;
 import org.apache.activemq.broker.region.Destination;
+import org.apache.activemq.broker.region.Subscription;
 import org.apache.activemq.command.ActiveMQDestination;
 import org.apache.activemq.command.BrokerInfo;
 import org.apache.activemq.command.ConnectionInfo;
@@ -54,12 +55,13 @@
         }
     }
 
-    public void addConsumer(ConnectionContext context,ConsumerInfo info) throws Exception{
-        next.addConsumer(context,info);
+    public Subscription addConsumer(ConnectionContext context,ConsumerInfo info) throws Exception{
+        Subscription answer = next.addConsumer(context,info);
         Broker brokers[]=getListeners();
         for(int i=0;i<brokers.length;i++){
             brokers[i].addConsumer(context,info);
         }
+        return answer;
     }
 
     public void addProducer(ConnectionContext context,ProducerInfo info) throws Exception{

Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/BrokerFilter.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/BrokerFilter.java?rev=385575&r1=385574&r2=385575&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/BrokerFilter.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/BrokerFilter.java
Mon Mar 13 07:41:55 2006
@@ -18,6 +18,7 @@
 
 import java.util.Set;
 import org.apache.activemq.broker.region.Destination;
+import org.apache.activemq.broker.region.Subscription;
 import org.apache.activemq.command.ActiveMQDestination;
 import org.apache.activemq.command.BrokerId;
 import org.apache.activemq.command.BrokerInfo;
@@ -63,8 +64,8 @@
         next.addConnection(context, info);
     }
 
-    public void addConsumer(ConnectionContext context, ConsumerInfo info) throws Exception
{
-        next.addConsumer(context, info);
+    public Subscription addConsumer(ConnectionContext context, ConsumerInfo info) throws
Exception {
+        return next.addConsumer(context, info);
     }
 
     public void addProducer(ConnectionContext context, ProducerInfo info) throws Exception
{

Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/EmptyBroker.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/EmptyBroker.java?rev=385575&r1=385574&r2=385575&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/EmptyBroker.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/EmptyBroker.java
Mon Mar 13 07:41:55 2006
@@ -18,6 +18,7 @@
 
 import java.util.Set;
 import org.apache.activemq.broker.region.Destination;
+import org.apache.activemq.broker.region.Subscription;
 import org.apache.activemq.command.ActiveMQDestination;
 import org.apache.activemq.command.BrokerId;
 import org.apache.activemq.command.BrokerInfo;
@@ -123,8 +124,8 @@
 
     }
 
-    public void addConsumer(ConnectionContext context,ConsumerInfo info) throws Exception{
-
+    public Subscription addConsumer(ConnectionContext context,ConsumerInfo info) throws Exception{
+        return null;
     }
 
     public void removeConsumer(ConnectionContext context,ConsumerInfo info) throws Exception{

Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/ErrorBroker.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/ErrorBroker.java?rev=385575&r1=385574&r2=385575&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/ErrorBroker.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/ErrorBroker.java
Mon Mar 13 07:41:55 2006
@@ -18,6 +18,7 @@
 
 import java.util.Set;
 import org.apache.activemq.broker.region.Destination;
+import org.apache.activemq.broker.region.Subscription;
 import org.apache.activemq.command.ActiveMQDestination;
 import org.apache.activemq.command.BrokerId;
 import org.apache.activemq.command.BrokerInfo;
@@ -124,7 +125,7 @@
         throw new IllegalStateException(this.message);
     }
 
-    public void addConsumer(ConnectionContext context, ConsumerInfo info) throws Exception
{
+    public Subscription addConsumer(ConnectionContext context, ConsumerInfo info) throws
Exception {
         throw new IllegalStateException(this.message);
     }
 

Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/MutableBrokerFilter.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/MutableBrokerFilter.java?rev=385575&r1=385574&r2=385575&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/MutableBrokerFilter.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/MutableBrokerFilter.java
Mon Mar 13 07:41:55 2006
@@ -18,6 +18,7 @@
 
 import java.util.Set;
 import org.apache.activemq.broker.region.Destination;
+import org.apache.activemq.broker.region.Subscription;
 import org.apache.activemq.command.ActiveMQDestination;
 import org.apache.activemq.command.BrokerId;
 import org.apache.activemq.command.BrokerInfo;
@@ -75,8 +76,8 @@
         getNext().addConnection(context, info);
     }
 
-    public void addConsumer(ConnectionContext context, ConsumerInfo info) throws Exception
{
-        getNext().addConsumer(context, info);
+    public Subscription addConsumer(ConnectionContext context, ConsumerInfo info) throws
Exception {
+        return getNext().addConsumer(context, info);
     }
 
     public void addProducer(ConnectionContext context, ProducerInfo info) throws Exception
{

Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/ft/MasterBroker.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/ft/MasterBroker.java?rev=385575&r1=385574&r2=385575&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/ft/MasterBroker.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/ft/MasterBroker.java
Mon Mar 13 07:41:55 2006
@@ -21,6 +21,7 @@
 import org.apache.activemq.broker.ConnectionContext;
 import org.apache.activemq.broker.InsertableMutableBrokerFilter;
 import org.apache.activemq.broker.MutableBrokerFilter;
+import org.apache.activemq.broker.region.Subscription;
 import org.apache.activemq.command.Command;
 import org.apache.activemq.command.ConnectionInfo;
 import org.apache.activemq.command.ConsumerInfo;
@@ -132,9 +133,10 @@
         sendAsyncToSlave(new RemoveInfo(info.getProducerId()));
     }
     
-    public void addConsumer(ConnectionContext context, ConsumerInfo info) throws Exception
{
-        super.addConsumer(context, info);
+    public Subscription addConsumer(ConnectionContext context, ConsumerInfo info) throws
Exception {
+        Subscription answer = super.addConsumer(context, info);
         sendAsyncToSlave(info);
+        return answer;
     }
 
     

Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/BrokerView.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/BrokerView.java?rev=385575&r1=385574&r2=385575&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/BrokerView.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/BrokerView.java
Mon Mar 13 07:41:55 2006
@@ -21,6 +21,7 @@
 import org.apache.activemq.broker.Broker;
 import org.apache.activemq.broker.BrokerService;
 import org.apache.activemq.broker.ConnectionContext;
+import org.apache.activemq.broker.region.Subscription;
 import org.apache.activemq.command.ActiveMQQueue;
 import org.apache.activemq.command.ActiveMQTopic;
 import org.apache.activemq.command.ConsumerId;
@@ -143,7 +144,7 @@
         broker.removeDestination(getConnectionContext(broker.getContextBroker()), new ActiveMQQueue(name),
1000);
     }
     
-    public void createDurableSubscriber(String clientId, String subscriberName, String topicName,
String selector) throws Exception {
+    public ObjectName createDurableSubscriber(String clientId, String subscriberName, String
topicName, String selector) throws Exception {
         ConnectionContext context = new ConnectionContext();
         context.setBroker(broker);
         context.setClientId(clientId);
@@ -156,8 +157,12 @@
         info.setDestination(new ActiveMQTopic(topicName));
         info.setSubcriptionName(subscriberName);
         info.setSelector(selector);
-        broker.addConsumer(context, info);
+        Subscription subscription = broker.addConsumer(context, info);
         broker.removeConsumer(context, info);
+        if (subscription != null) {
+            return subscription.getObjectName();
+        }
+        return null;
     }
 
     public void destroyDurableSubscriber(String clientId, String subscriberName) throws Exception
{

Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/BrokerViewMBean.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/BrokerViewMBean.java?rev=385575&r1=385574&r2=385575&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/BrokerViewMBean.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/BrokerViewMBean.java
Mon Mar 13 07:41:55 2006
@@ -109,8 +109,10 @@
      * @param subscriberName the durable subscriber name
      * @param topicName the name of the topic to subscribe to
      * @param selector a selector or null
+     * 
+     * @return the object name of the MBean registered in JMX
      */
-    public void createDurableSubscriber(String clientId, String subscriberName, String topicName,
String selector) throws Exception;
+    public ObjectName createDurableSubscriber(String clientId, String subscriberName, String
topicName, String selector) throws Exception;
 
     /**
      * Destroys a durable subscriber

Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/ManagedQueueRegion.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/ManagedQueueRegion.java?rev=385575&r1=385574&r2=385575&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/ManagedQueueRegion.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/ManagedQueueRegion.java
Mon Mar 13 07:41:55 2006
@@ -17,6 +17,7 @@
 package org.apache.activemq.broker.jmx;
 
 import javax.jms.InvalidSelectorException;
+import javax.management.ObjectName;
 
 import org.apache.activemq.broker.ConnectionContext;
 import org.apache.activemq.broker.region.Destination;
@@ -41,7 +42,8 @@
 
     protected Subscription createSubscription(ConnectionContext context, ConsumerInfo info)
throws InvalidSelectorException {
         Subscription sub = super.createSubscription(context, info);
-        regionBroker.registerSubscription(context,sub);
+        ObjectName name = regionBroker.registerSubscription(context,sub);
+        sub.setObjectName(name);
         return sub;
     }
     

Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/ManagedRegionBroker.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/ManagedRegionBroker.java?rev=385575&r1=385574&r2=385575&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/ManagedRegionBroker.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/ManagedRegionBroker.java
Mon Mar 13 07:41:55 2006
@@ -62,6 +62,7 @@
 import org.apache.commons.logging.LogFactory;
 import edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap;
 import edu.emory.mathcs.backport.java.util.concurrent.CopyOnWriteArraySet;
+
 public class ManagedRegionBroker extends RegionBroker{
     private static final Log log=LogFactory.getLog(ManagedRegionBroker.class);
     private final MBeanServer mbeanServer;
@@ -154,7 +155,7 @@
         }
     }
 
-    public void registerSubscription(ConnectionContext context,Subscription sub){
+    public ObjectName registerSubscription(ConnectionContext context,Subscription sub){
         Hashtable map=brokerObjectName.getKeyPropertyList();
         String name="";
         SubscriptionKey key=new SubscriptionKey(context.getClientId(),sub.getConsumerInfo().getSubcriptionName());
@@ -179,8 +180,10 @@
             }
             registerSubscription(objectName,sub.getConsumerInfo(),key,view);
             subscriptionMap.put(sub,objectName);
+            return objectName;
         }catch(Exception e){
             log.error("Failed to register subscription "+sub,e);
+            return null;
         }
     }
 

Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/ManagedTempQueueRegion.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/ManagedTempQueueRegion.java?rev=385575&r1=385574&r2=385575&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/ManagedTempQueueRegion.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/ManagedTempQueueRegion.java
Mon Mar 13 07:41:55 2006
@@ -17,6 +17,7 @@
 package org.apache.activemq.broker.jmx;
 
 import javax.jms.InvalidSelectorException;
+import javax.management.ObjectName;
 
 import org.apache.activemq.broker.ConnectionContext;
 import org.apache.activemq.broker.region.Destination;
@@ -39,7 +40,8 @@
     
     protected Subscription createSubscription(ConnectionContext context, ConsumerInfo info)
throws InvalidSelectorException {
         Subscription sub = super.createSubscription(context, info);
-        regionBroker.registerSubscription(context,sub);
+        ObjectName name = regionBroker.registerSubscription(context,sub);
+        sub.setObjectName(name);
         return sub;
     }
     

Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/ManagedTempTopicRegion.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/ManagedTempTopicRegion.java?rev=385575&r1=385574&r2=385575&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/ManagedTempTopicRegion.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/ManagedTempTopicRegion.java
Mon Mar 13 07:41:55 2006
@@ -17,6 +17,7 @@
 package org.apache.activemq.broker.jmx;
 
 import javax.jms.JMSException;
+import javax.management.ObjectName;
 
 import org.apache.activemq.broker.ConnectionContext;
 import org.apache.activemq.broker.region.Destination;
@@ -39,7 +40,8 @@
     
     protected Subscription createSubscription(ConnectionContext context, ConsumerInfo info)
throws JMSException {
         Subscription sub = super.createSubscription(context, info);
-        regionBroker.registerSubscription(context,sub);
+        ObjectName name = regionBroker.registerSubscription(context,sub);
+        sub.setObjectName(name);
         return sub;
     }
     

Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/ManagedTopicRegion.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/ManagedTopicRegion.java?rev=385575&r1=385574&r2=385575&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/ManagedTopicRegion.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/ManagedTopicRegion.java
Mon Mar 13 07:41:55 2006
@@ -17,6 +17,7 @@
 package org.apache.activemq.broker.jmx;
 
 import javax.jms.JMSException;
+import javax.management.ObjectName;
 
 import org.apache.activemq.broker.ConnectionContext;
 import org.apache.activemq.broker.region.Destination;
@@ -41,7 +42,8 @@
 
     protected Subscription createSubscription(ConnectionContext context, ConsumerInfo info)
throws JMSException {
         Subscription sub = super.createSubscription(context, info);
-        regionBroker.registerSubscription(context,sub);
+        ObjectName name = regionBroker.registerSubscription(context,sub);
+        sub.setObjectName(name);
         return sub;
     }
     

Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/AbstractRegion.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/AbstractRegion.java?rev=385575&r1=385574&r2=385575&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/AbstractRegion.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/AbstractRegion.java
Mon Mar 13 07:41:55 2006
@@ -113,7 +113,7 @@
         }
     }
 
-    public void addConsumer(ConnectionContext context, ConsumerInfo info) throws Exception
{
+    public Subscription addConsumer(ConnectionContext context, ConsumerInfo info) throws
Exception {
 
         Subscription sub = createSubscription(context, info);
 
@@ -148,6 +148,7 @@
             ((QueueBrowserSubscription)sub).browseDone();
         }
         
+        return sub;
     }
     
     /**

Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/AbstractSubscription.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/AbstractSubscription.java?rev=385575&r1=385574&r2=385575&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/AbstractSubscription.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/AbstractSubscription.java
Mon Mar 13 07:41:55 2006
@@ -18,6 +18,7 @@
 
 import javax.jms.InvalidSelectorException;
 import javax.jms.JMSException;
+import javax.management.ObjectName;
 
 import java.io.IOException;
 
@@ -46,6 +47,7 @@
     protected ConsumerInfo info;
     final protected DestinationFilter destinationFilter;
     private BooleanExpression selectorExpression;
+    private ObjectName objectName;
    
     final protected CopyOnWriteArrayList destinations = new CopyOnWriteArrayList();
 
@@ -139,5 +141,13 @@
         // its valid so lets actually update it now
         info.setSelector(selector);
         this.selectorExpression = newSelector;
+    }
+
+    public ObjectName getObjectName() {
+        return objectName;
+    }
+
+    public void setObjectName(ObjectName objectName) {
+        this.objectName = objectName;
     }
 }

Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/Region.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/Region.java?rev=385575&r1=385574&r2=385575&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/Region.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/Region.java
Mon Mar 13 07:41:55 2006
@@ -60,9 +60,10 @@
     /**
      * Adds a consumer.
      * @param context the environment the operation is being executed under.
+     * @return TODO
      * @throws Exception TODO
      */
-    public void addConsumer(ConnectionContext context, ConsumerInfo info) throws Exception;
+    public Subscription addConsumer(ConnectionContext context, ConsumerInfo info) throws
Exception;
 
     /**
      * Removes a consumer.

Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/RegionBroker.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/RegionBroker.java?rev=385575&r1=385574&r2=385575&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/RegionBroker.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/RegionBroker.java
Mon Mar 13 07:41:55 2006
@@ -200,7 +200,7 @@
             answer = tempTopicRegion.addDestination(context, destination);
             break;
         default:
-            throwUnknownDestinationType(destination);
+            throw createUnknownDestinationTypeException(destination);
         }
 
         destinations.add(destination);
@@ -225,7 +225,7 @@
             tempTopicRegion.removeDestination(context, destination, timeout);
             break;
         default:
-            throwUnknownDestinationType(destination);
+            throw createUnknownDestinationTypeException(destination);
         }
         
         destinations.remove(destination);
@@ -251,23 +251,23 @@
     public void removeProducer(ConnectionContext context, ProducerInfo info) throws Exception
{
     }
 
-    public void addConsumer(ConnectionContext context, ConsumerInfo info) throws Exception
{
+    public Subscription addConsumer(ConnectionContext context, ConsumerInfo info) throws
Exception {
         ActiveMQDestination destination = info.getDestination();
         switch(destination.getDestinationType()) {
         case ActiveMQDestination.QUEUE_TYPE:
-            queueRegion.addConsumer(context, info);
-            break;
+            return queueRegion.addConsumer(context, info);
+            
         case ActiveMQDestination.TOPIC_TYPE:
-            topicRegion.addConsumer(context, info);
-            break;
+            return topicRegion.addConsumer(context, info);
+        
         case ActiveMQDestination.TEMP_QUEUE_TYPE:
-            tempQueueRegion.addConsumer(context, info);
-            break;
+            return tempQueueRegion.addConsumer(context, info);
+            
         case ActiveMQDestination.TEMP_TOPIC_TYPE:
-            tempTopicRegion.addConsumer(context, info);
-            break;
+            return tempTopicRegion.addConsumer(context, info);
+            
         default:
-            throwUnknownDestinationType(destination);
+            throw createUnknownDestinationTypeException(destination);
         }
     }
 
@@ -287,7 +287,7 @@
             tempTopicRegion.removeConsumer(context, info);
             break;
         default:
-            throwUnknownDestinationType(destination);
+            throw createUnknownDestinationTypeException(destination);
         }
     }
 
@@ -316,7 +316,7 @@
             tempTopicRegion.send(context, message);
             break;
         default:
-            throwUnknownDestinationType(destination);
+            throw createUnknownDestinationTypeException(destination);
         }
     }
 
@@ -336,7 +336,7 @@
             tempTopicRegion.acknowledge(context, ack);
             break;
         default:
-            throwUnknownDestinationType(destination);
+            throw createUnknownDestinationTypeException(destination);
         }
     }
 
@@ -402,8 +402,8 @@
         return destinationStatistics;
     }
 
-    protected void throwUnknownDestinationType(ActiveMQDestination destination) throws JMSException
{
-        throw new JMSException("Unknown destination type: " + destination.getDestinationType());
+    protected JMSException createUnknownDestinationTypeException(ActiveMQDestination destination)
{
+        return new JMSException("Unknown destination type: " + destination.getDestinationType());
     }
 
     public synchronized void addBroker(Connection connection,BrokerInfo info){
@@ -442,7 +442,7 @@
             tempTopicRegion.processDispatchNotification(messageDispatchNotification);
             break;
         default:
-            throwUnknownDestinationType(destination);
+            throw createUnknownDestinationTypeException(destination);
         }
     }
     

Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/Subscription.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/Subscription.java?rev=385575&r1=385574&r2=385575&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/Subscription.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/Subscription.java
Mon Mar 13 07:41:55 2006
@@ -26,6 +26,7 @@
 import org.apache.activemq.filter.MessageEvaluationContext;
 
 import javax.jms.InvalidSelectorException;
+import javax.management.ObjectName;
 
 /**
  * @version $Revision: 1.5 $
@@ -137,4 +138,14 @@
      * This operation is not supported for persistent topics.
      */
     public void setSelector(String selector) throws InvalidSelectorException, UnsupportedOperationException;
+
+    /**
+     * @return the JMX object name that this subscription was registered as if applicable
+     */
+    public ObjectName getObjectName();
+
+    /**
+     * Set when the subscription is registered in JMX
+     */
+    public void setObjectName(ObjectName objectName);
 }

Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/TopicRegion.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/TopicRegion.java?rev=385575&r1=385574&r2=385575&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/TopicRegion.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/TopicRegion.java
Mon Mar 13 07:41:55 2006
@@ -57,7 +57,7 @@
         
     }
 
-    public void addConsumer(ConnectionContext context, ConsumerInfo info) throws Exception
{
+    public Subscription addConsumer(ConnectionContext context, ConsumerInfo info) throws
Exception {
         if (info.isDurable()) {
 
             ActiveMQDestination destination = info.getDestination();
@@ -103,9 +103,10 @@
             }
             
             sub.activate(context, info);
+            return sub;
         }
         else {
-            super.addConsumer(context, info);
+            return super.addConsumer(context, info);
         }
     }
 

Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/security/AuthorizationBroker.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/security/AuthorizationBroker.java?rev=385575&r1=385574&r2=385575&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/security/AuthorizationBroker.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/security/AuthorizationBroker.java
Mon Mar 13 07:41:55 2006
@@ -20,6 +20,7 @@
 import org.apache.activemq.broker.BrokerFilter;
 import org.apache.activemq.broker.ConnectionContext;
 import org.apache.activemq.broker.region.Destination;
+import org.apache.activemq.broker.region.Subscription;
 import org.apache.activemq.command.ActiveMQDestination;
 import org.apache.activemq.command.ActiveMQQueue;
 import org.apache.activemq.command.ActiveMQTempDestination;
@@ -85,7 +86,7 @@
         super.removeDestination(context, destination, timeout);
     }
     
-    public void addConsumer(ConnectionContext context, ConsumerInfo info) throws Exception
{
+    public Subscription addConsumer(ConnectionContext context, ConsumerInfo info) throws
Exception {
         
         final SecurityContext subject = (SecurityContext) context.getSecurityContext();
         if( subject == null )
@@ -117,7 +118,7 @@
             
         }
         
-        super.addConsumer(context, info);
+        return super.addConsumer(context, info);
     }
     
     public void addProducer(ConnectionContext context, ProducerInfo info) throws Exception
{

Modified: incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/jmx/MBeanTest.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/jmx/MBeanTest.java?rev=385575&r1=385574&r2=385575&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/jmx/MBeanTest.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/jmx/MBeanTest.java
Mon Mar 13 07:41:55 2006
@@ -140,10 +140,14 @@
 
         String topicName = getDestinationString();
         String selector = null;
-        broker.createDurableSubscriber(clientID, "subscriber1", topicName , selector);
+        ObjectName name1 = broker.createDurableSubscriber(clientID, "subscriber1", topicName
, selector);
         broker.createDurableSubscriber(clientID, "subscriber2", topicName, selector);
         assertEquals("Durable subscriber count", 2, broker.getDurableTopicSubscribers().length);
 
+        assertNotNull("Should have created an mbean name for the durable subscriber!", name1);
+        
+        System.out.println("Created durable subscriber with name: "  + name1);
+        
         // now lets try destroy it
         broker.destroyDurableSubscriber(clientID, "subscriber1");
         assertEquals("Durable subscriber count", 1, broker.getDurableTopicSubscribers().length);



Mime
View raw message