activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dej...@apache.org
Subject svn commit: r963970 - in /activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web: BrokerFacadeSupport.java LocalBrokerFacade.java RemoteJMXBrokerFacade.java
Date Wed, 14 Jul 2010 08:21:54 GMT
Author: dejanb
Date: Wed Jul 14 08:21:53 2010
New Revision: 963970

URL: http://svn.apache.org/viewvc?rev=963970&view=rev
Log:
https://issues.apache.org/activemq/browse/AMQ-2570 - allow monitoring connections, scheduled
messages, etc. for remote brokers

Modified:
    activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/BrokerFacadeSupport.java
    activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/LocalBrokerFacade.java
    activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/RemoteJMXBrokerFacade.java

Modified: activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/BrokerFacadeSupport.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/BrokerFacadeSupport.java?rev=963970&r1=963969&r2=963970&view=diff
==============================================================================
--- activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/BrokerFacadeSupport.java
(original)
+++ activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/BrokerFacadeSupport.java
Wed Jul 14 08:21:53 2010
@@ -23,6 +23,7 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
 import javax.management.ObjectName;
+import javax.management.QueryExp;
 import javax.management.openmbean.CompositeData;
 import javax.management.openmbean.TabularData;
 import org.apache.activemq.broker.jmx.BrokerViewMBean;
@@ -45,6 +46,8 @@ import org.springframework.util.StringUt
  */
 public abstract class BrokerFacadeSupport implements BrokerFacade {
     public abstract ManagementContext getManagementContext();
+    public abstract Set queryNames(ObjectName name, QueryExp query) throws Exception;
+    public abstract Object newProxyInstance( ObjectName objectName, Class interfaceClass,
boolean notificationBroadcaster) throws Exception;
 
     public Collection<QueueViewMBean> getQueues() throws Exception {
         BrokerViewMBean broker = getBrokerAdmin();
@@ -94,11 +97,11 @@ public abstract class BrokerFacadeSuppor
     }
 
     @SuppressWarnings("unchecked")
-    protected <T> Collection<T> getManagedObjects(ObjectName[] names, Class<T>
type) {
+    protected <T> Collection<T> getManagedObjects(ObjectName[] names, Class<T>
type) throws Exception {
         List<T> answer = new ArrayList<T>();
         for (int i = 0; i < names.length; i++) {
             ObjectName name = names[i];
-            T value = (T) getManagementContext().newProxyInstance(name, type, true);
+            T value = (T) newProxyInstance(name, type, true);
             if (value != null) {
                 answer.add(value);
             }
@@ -110,7 +113,7 @@ public abstract class BrokerFacadeSuppor
     public Collection<ConnectionViewMBean> getConnections() throws Exception {
         String brokerName = getBrokerName();
         ObjectName query = new ObjectName("org.apache.activemq:BrokerName=" + brokerName
+ ",Type=Connection,*");
-        Set<ObjectName> queryResult = getManagementContext().queryNames(query, null);
+        Set<ObjectName> queryResult = queryNames(query, null);
         return getManagedObjects(queryResult.toArray(new ObjectName[queryResult.size()]),
ConnectionViewMBean.class);
     }
 
@@ -119,7 +122,7 @@ public abstract class BrokerFacadeSuppor
         String brokerName = getBrokerName();
         ObjectName query = new ObjectName("org.apache.activemq:BrokerName=" + brokerName
                 + ",Type=Connection,ConnectorName=" + connectorName + ",*");
-        Set<ObjectName> queryResult = getManagementContext().queryNames(query, null);
+        Set<ObjectName> queryResult = queryNames(query, null);
         Collection<String> result = new ArrayList<String>(queryResult.size());
         for (ObjectName on : queryResult) {
             String name = StringUtils.replace(on.getKeyProperty("Connection"), "_", ":");
@@ -134,11 +137,11 @@ public abstract class BrokerFacadeSuppor
         String brokerName = getBrokerName();
         ObjectName query = new ObjectName("org.apache.activemq:BrokerName=" + brokerName
                 + ",Type=Connection,*,Connection=" + connectionName);
-        Set<ObjectName> queryResult = getManagementContext().queryNames(query, null);
+        Set<ObjectName> queryResult = queryNames(query, null);
         if (queryResult.size() == 0)
             return null;
         ObjectName objectName = queryResult.iterator().next();
-        return (ConnectionViewMBean) getManagementContext().newProxyInstance(objectName,
ConnectionViewMBean.class,
+        return (ConnectionViewMBean) newProxyInstance(objectName, ConnectionViewMBean.class,
                 true);
     }
 
@@ -146,7 +149,7 @@ public abstract class BrokerFacadeSuppor
     public Collection<String> getConnectors() throws Exception {
         String brokerName = getBrokerName();
         ObjectName query = new ObjectName("org.apache.activemq:BrokerName=" + brokerName
+ ",Type=Connector,*");
-        Set<ObjectName> queryResult = getManagementContext().queryNames(query, null);
+        Set<ObjectName> queryResult = queryNames(query, null);
         Collection<String> result = new ArrayList<String>(queryResult.size());
         for (ObjectName on : queryResult)
             result.add(on.getKeyProperty("ConnectorName"));
@@ -157,14 +160,14 @@ public abstract class BrokerFacadeSuppor
         String brokerName = getBrokerName();
         ObjectName objectName = new ObjectName("org.apache.activemq:BrokerName=" + brokerName
                 + ",Type=Connector,ConnectorName=" + name);
-        return (ConnectorViewMBean) getManagementContext().newProxyInstance(objectName, ConnectorViewMBean.class,
true);
+        return (ConnectorViewMBean) newProxyInstance(objectName, ConnectorViewMBean.class,
true);
     }
 
     @SuppressWarnings("unchecked")
     public Collection<NetworkConnectorViewMBean> getNetworkConnectors() throws Exception
{
         String brokerName = getBrokerName();
         ObjectName query = new ObjectName("org.apache.activemq:BrokerName=" + brokerName
+ ",Type=NetworkConnector,*");
-        Set<ObjectName> queryResult = getManagementContext().queryNames(query, null);
+        Set<ObjectName> queryResult = queryNames(query, null);
         return getManagedObjects(queryResult.toArray(new ObjectName[queryResult.size()]),
                 NetworkConnectorViewMBean.class);
     }
@@ -175,7 +178,7 @@ public abstract class BrokerFacadeSuppor
         queueName = StringUtils.replace(queueName, "\"", "_");
         ObjectName query = new ObjectName("org.apache.activemq:BrokerName=" + brokerName
                 + ",Type=Subscription,destinationType=Queue,destinationName=" + queueName
+ ",*");
-        Set<ObjectName> queryResult = getManagementContext().queryNames(query, null);
+        Set<ObjectName> queryResult = queryNames(query, null);
         return getManagedObjects(queryResult.toArray(new ObjectName[queryResult.size()]),
SubscriptionViewMBean.class);
     }
 
@@ -185,13 +188,13 @@ public abstract class BrokerFacadeSuppor
         String brokerName = getBrokerName();
         ObjectName query = new ObjectName("org.apache.activemq:BrokerName=" + brokerName
                 + ",Type=Subscription,clientId=" + connectionName + ",*");
-        Set<ObjectName> queryResult = getManagementContext().queryNames(query, null);
+        Set<ObjectName> queryResult = queryNames(query, null);
         return getManagedObjects(queryResult.toArray(new ObjectName[queryResult.size()]),
SubscriptionViewMBean.class);
     }
 
     public JobSchedulerViewMBean getJobScheduler() throws Exception {
         ObjectName name = getBrokerAdmin().getJMSJobScheduler();
-        return (JobSchedulerViewMBean) getManagementContext().newProxyInstance(name, JobSchedulerViewMBean.class,
true);
+        return (JobSchedulerViewMBean) newProxyInstance(name, JobSchedulerViewMBean.class,
true);
     }
 
     public Collection<JobFacade> getScheduledJobs() throws Exception {

Modified: activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/LocalBrokerFacade.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/LocalBrokerFacade.java?rev=963970&r1=963969&r2=963970&view=diff
==============================================================================
--- activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/LocalBrokerFacade.java
(original)
+++ activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/LocalBrokerFacade.java
Wed Jul 14 08:21:53 2010
@@ -19,6 +19,9 @@ package org.apache.activemq.web;
 import java.util.Iterator;
 import java.util.Set;
 
+import javax.management.ObjectName;
+import javax.management.QueryExp;
+
 import org.apache.activemq.broker.Broker;
 import org.apache.activemq.broker.BrokerService;
 import org.apache.activemq.broker.jmx.BrokerView;
@@ -74,5 +77,15 @@ public class LocalBrokerFacade extends B
             }
         }
     }
+
+    @Override
+    public Set queryNames(ObjectName name, QueryExp query) throws Exception {
+        return getManagementContext().queryNames(name, query);
+    }
+
+    @Override
+    public Object newProxyInstance(ObjectName objectName, Class interfaceClass, boolean notificationBroadcaster)
{
+        return getManagementContext().newProxyInstance(objectName, interfaceClass, notificationBroadcaster);
+    }
     
 }

Modified: activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/RemoteJMXBrokerFacade.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/RemoteJMXBrokerFacade.java?rev=963970&r1=963969&r2=963970&view=diff
==============================================================================
--- activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/RemoteJMXBrokerFacade.java
(original)
+++ activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/RemoteJMXBrokerFacade.java
Wed Jul 14 08:21:53 2010
@@ -28,6 +28,7 @@ import javax.management.MBeanServerConne
 import javax.management.MBeanServerInvocationHandler;
 import javax.management.MalformedObjectNameException;
 import javax.management.ObjectName;
+import javax.management.QueryExp;
 import javax.management.remote.JMXConnector;
 import javax.management.remote.JMXConnectorFactory;
 import javax.management.remote.JMXServiceURL;
@@ -240,4 +241,14 @@ public class RemoteJMXBrokerFacade exten
 		return answer;
     }
 
+    @Override
+    public Set queryNames(ObjectName name, QueryExp query) throws Exception {
+        return getMBeanServerConnection().queryNames(name, query);
+    }
+
+    @Override
+    public Object newProxyInstance(ObjectName objectName, Class interfaceClass,boolean notificationBroadcaster)
throws Exception {
+        return MBeanServerInvocationHandler.newProxyInstance(getMBeanServerConnection(),
objectName, interfaceClass, notificationBroadcaster);
+    }
+
 }



Mime
View raw message