activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r384486 - in /incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq: ./ broker/jmx/ broker/region/
Date Thu, 09 Mar 2006 10:49:39 GMT
Author: jstrachan
Date: Thu Mar  9 02:49:37 2006
New Revision: 384486

URL: http://svn.apache.org/viewcvs?rev=384486&view=rev
Log:
minor refactor of a property and exposed the selector as an MBean attribute. the selector
can actually be updated in real time via JMX for non-durable topic subscriptions for AMQ-625

Modified:
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQQueueBrowser.java
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/SubscriptionView.java
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/SubscriptionViewMBean.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/DurableTopicSubscription.java
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/Subscription.java

Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQQueueBrowser.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQQueueBrowser.java?rev=384486&r1=384485&r2=384486&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQQueueBrowser.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQQueueBrowser.java
Thu Mar  9 02:49:37 2006
@@ -90,7 +90,7 @@
     /**
      * @param session
      * @param originalDestination
-     * @param selector
+     * @param selectorExpression
      * @param cnum
      * @return
      * @throws JMSException

Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/SubscriptionView.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/SubscriptionView.java?rev=384486&r1=384485&r2=384486&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/SubscriptionView.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/SubscriptionView.java
Thu Mar  9 02:49:37 2006
@@ -20,6 +20,8 @@
 import org.apache.activemq.command.ActiveMQDestination;
 import org.apache.activemq.command.ConsumerInfo;
 
+import javax.jms.InvalidSelectorException;
+
 
 
 /**
@@ -91,7 +93,22 @@
             return dest.getPhysicalName();
         }
         return "NOTSET";
-       
+    }
+
+    public String getSelector() {
+        if (subscription != null) {
+            return subscription.getSelector();
+        }
+        return null;
+    }
+
+    public void setSelector(String selector) throws InvalidSelectorException, UnsupportedOperationException
{
+        if (subscription != null) {
+            subscription.setSelector(selector);
+        }
+        else {
+            throw new UnsupportedOperationException("No subscription object");
+        }
     }
 
     /**

Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/SubscriptionViewMBean.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/SubscriptionViewMBean.java?rev=384486&r1=384485&r2=384486&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/SubscriptionViewMBean.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/SubscriptionViewMBean.java
Thu Mar  9 02:49:37 2006
@@ -13,6 +13,8 @@
  */
 package org.apache.activemq.broker.jmx;
 
+import javax.jms.InvalidSelectorException;
+
 /**
  * @version $Revision: 1.5 $
  */
@@ -42,6 +44,18 @@
      */
     public String getDestinationName();
 
+
+    /**
+     * @return the JMS selector on the current subscription
+     */
+    public String getSelector();
+    
+    /**
+     * Attempts to change the current active selector on the subscription.
+     * This operation is not supported for persistent topics.
+     */
+    public void setSelector(String selector) throws InvalidSelectorException, UnsupportedOperationException;
+    
     /**
      * @return true if the destination is a Queue
      */

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=384486&r1=384485&r2=384486&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
Thu Mar  9 02:49:37 2006
@@ -45,7 +45,7 @@
     protected ConnectionContext context;
     protected ConsumerInfo info;
     final protected DestinationFilter destinationFilter;
-    final protected BooleanExpression selector;
+    private BooleanExpression selectorExpression;
    
     final protected CopyOnWriteArrayList destinations = new CopyOnWriteArrayList();
 
@@ -54,7 +54,7 @@
         this.context = context;
         this.info = info;
         this.destinationFilter = DestinationFilter.parseFilter(info.getDestination());
-        this.selector = parseSelector(info);
+        this.selectorExpression = parseSelector(info);
     }
     
     static private BooleanExpression parseSelector(ConsumerInfo info) throws InvalidSelectorException
{
@@ -86,7 +86,7 @@
                 return false;
         }
         try {
-            return (selector == null || selector.matches(context)) && this.context.isAllowedToConsume(node);
+            return (selectorExpression == null || selectorExpression.matches(context)) &&
this.context.isAllowedToConsume(node);
         } catch (JMSException e) {
             log.info("Selector failed to evaluate: " + e.getMessage(), e);
             return false;
@@ -124,7 +124,20 @@
         return info;
     }
 
-    public BooleanExpression getSelector() {
-        return selector;
+    public BooleanExpression getSelectorExpression() {
+        return selectorExpression;
+    }
+    
+    public String getSelector() {
+        return info.getSelector();
+    }
+    
+    public void setSelector(String selector) throws InvalidSelectorException {
+        ConsumerInfo copy = info.copy();
+        copy.setSelector(selector);
+        BooleanExpression newSelector = parseSelector(copy);
+        // its valid so lets actually update it now
+        info.setSelector(selector);
+        this.selectorExpression = newSelector;
     }
 }

Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/DurableTopicSubscription.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/DurableTopicSubscription.java?rev=384486&r1=384485&r2=384486&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/DurableTopicSubscription.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/DurableTopicSubscription.java
Thu Mar  9 02:49:37 2006
@@ -16,10 +16,7 @@
  */
 package org.apache.activemq.broker.region;
 
-import java.io.IOException;
-import java.util.Iterator;
-
-import javax.jms.InvalidSelectorException;
+import edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap;
 
 import org.apache.activemq.broker.Broker;
 import org.apache.activemq.broker.ConnectionContext;
@@ -29,7 +26,10 @@
 import org.apache.activemq.command.MessageDispatch;
 import org.apache.activemq.util.SubscriptionKey;
 
-import edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap;
+import javax.jms.InvalidSelectorException;
+
+import java.io.IOException;
+import java.util.Iterator;
 
 public class DurableTopicSubscription extends PrefetchSubscription {
     
@@ -131,6 +131,9 @@
         return 0;
     }
     
+    public void setSelector(String selector) throws InvalidSelectorException {
+        throw new UnsupportedOperationException("You cannot dynamically change the selector
for durable topic subscriptions");
+    }
 
     protected boolean canDispatch(MessageReference node) {
         return active;

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=384486&r1=384485&r2=384486&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
Thu Mar  9 02:49:37 2006
@@ -25,6 +25,8 @@
 import org.apache.activemq.command.MessageDispatchNotification;
 import org.apache.activemq.filter.MessageEvaluationContext;
 
+import javax.jms.InvalidSelectorException;
+
 /**
  * @version $Revision: 1.5 $
  */
@@ -125,4 +127,14 @@
      */
     long getDequeueCounter();
 
+    /**
+     * @return the JMS selector on the current subscription
+     */
+    public String getSelector();
+    
+    /**
+     * Attempts to change the current active selector on the subscription.
+     * This operation is not supported for persistent topics.
+     */
+    public void setSelector(String selector) throws InvalidSelectorException, UnsupportedOperationException;
 }



Mime
View raw message