activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r504251 - in /activemq/trunk/activemq-web-console/src/main: java/org/apache/activemq/web/BrokerFacadeSupport.java java/org/apache/activemq/web/JMXBrokerFacade.java java/org/apache/activemq/web/LocalBrokerFacade.java webapp/queues.jsp
Date Tue, 06 Feb 2007 19:27:18 GMT
Author: jstrachan
Date: Tue Feb  6 11:27:18 2007
New Revision: 504251

URL: http://svn.apache.org/viewvc?view=rev&rev=504251
Log:
added in initial support for using a remote JMXBrokerFacade to connect to a remote broker

Added:
    activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/BrokerFacadeSupport.java
  (with props)
    activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/JMXBrokerFacade.java
  (with props)
Modified:
    activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/LocalBrokerFacade.java
    activemq/trunk/activemq-web-console/src/main/webapp/queues.jsp

Added: activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/BrokerFacadeSupport.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/BrokerFacadeSupport.java?view=auto&rev=504251
==============================================================================
--- activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/BrokerFacadeSupport.java
(added)
+++ activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/BrokerFacadeSupport.java
Tue Feb  6 11:27:18 2007
@@ -0,0 +1,83 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.web;
+
+import org.apache.activemq.broker.jmx.BrokerViewMBean;
+import org.apache.activemq.broker.jmx.DurableSubscriptionViewMBean;
+import org.apache.activemq.broker.jmx.ManagementContext;
+import org.apache.activemq.broker.jmx.TopicViewMBean;
+import org.apache.activemq.broker.jmx.QueueViewMBean;
+
+import javax.management.MBeanServer;
+import javax.management.MBeanServerInvocationHandler;
+import javax.management.ObjectName;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * A useful base class for an implementation of {@link BrokerFacade}
+ *
+ * @version $Revision$
+ */
+public abstract class BrokerFacadeSupport implements BrokerFacade {
+    public abstract ManagementContext getManagementContext();
+
+    public Collection getQueues() throws Exception {
+        BrokerViewMBean broker = getBrokerAdmin();
+        if (broker == null) {
+            return Collections.EMPTY_LIST;
+        }
+        ObjectName[] queues = broker.getQueues();
+        return getManagedObjects(queues, QueueViewMBean.class);
+    }
+
+    public Collection getTopics() throws Exception {
+        BrokerViewMBean broker = getBrokerAdmin();
+        if (broker == null) {
+            return Collections.EMPTY_LIST;
+        }
+        ObjectName[] queues = broker.getTopics();
+        return getManagedObjects(queues, TopicViewMBean.class);
+    }
+
+    public Collection getDurableTopicSubscribers() throws Exception {
+        BrokerViewMBean broker = getBrokerAdmin();
+        if (broker == null) {
+            return Collections.EMPTY_LIST;
+        }
+        ObjectName[] queues = broker.getDurableTopicSubscribers();
+        return getManagedObjects(queues, DurableSubscriptionViewMBean.class);
+    }
+
+    protected Collection getManagedObjects(ObjectName[] names, Class type) {
+        List answer = new ArrayList();
+        MBeanServer mbeanServer = getManagementContext().getMBeanServer();
+        if (mbeanServer != null) {
+            for (int i = 0; i < names.length; i++) {
+                ObjectName name = names[i];
+                Object value = MBeanServerInvocationHandler.newProxyInstance(mbeanServer,
name, type, true);
+                if (value != null) {
+                    answer.add(value);
+                }
+            }
+        }
+        return answer;
+    }
+}

Propchange: activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/BrokerFacadeSupport.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/BrokerFacadeSupport.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/BrokerFacadeSupport.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/JMXBrokerFacade.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/JMXBrokerFacade.java?view=auto&rev=504251
==============================================================================
--- activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/JMXBrokerFacade.java
(added)
+++ activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/JMXBrokerFacade.java
Tue Feb  6 11:27:18 2007
@@ -0,0 +1,52 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.web;
+
+import org.apache.activemq.broker.jmx.BrokerViewMBean;
+import org.apache.activemq.broker.jmx.ManagementContext;
+import org.apache.activemq.command.ActiveMQDestination;
+
+import java.util.Collection;
+
+/**
+ * A {@link BrokerFacade} which uses JMX to communicate with a remote broker
+ *
+ * @version $Revision$
+ */
+public class JMXBrokerFacade extends BrokerFacadeSupport {
+    private ManagementContext managementContext;
+
+    public BrokerViewMBean getBrokerAdmin() throws Exception {
+        return null;  /** TODO */
+    }
+
+    public void purgeQueue(ActiveMQDestination destination) throws Exception {
+        /** TODO */
+    }
+
+    public ManagementContext getManagementContext() {
+        if (managementContext == null) {
+            managementContext = new ManagementContext();
+        }
+        return managementContext;
+    }
+
+    public void setManagementContext(ManagementContext managementContext) {
+        this.managementContext = managementContext;
+    }
+}

Propchange: activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/JMXBrokerFacade.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/JMXBrokerFacade.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/JMXBrokerFacade.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/LocalBrokerFacade.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/LocalBrokerFacade.java?view=diff&rev=504251&r1=504250&r2=504251
==============================================================================
--- activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/LocalBrokerFacade.java
(original)
+++ activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/LocalBrokerFacade.java
Tue Feb  6 11:27:18 2007
@@ -45,9 +45,7 @@
  *
  * @version $Revision$
  */
-public class LocalBrokerFacade implements BrokerFacade {
-    private static final Log log = LogFactory.getLog(LocalBrokerFacade.class);
-
+public class LocalBrokerFacade extends BrokerFacadeSupport {
     private BrokerService brokerService;
 
     public LocalBrokerFacade(BrokerService brokerService) {
@@ -78,69 +76,6 @@
         }
         return adminView.getBroker();
     }
-
-    // TODO - we should not have to use JMX to implement the following methods...
-    
-    /*
-    public Collection getQueues() throws Exception {
-        BrokerView broker = brokerService.getAdminView();
-        if (broker == null) {
-            return Collections.EMPTY_LIST;
-        }
-        ObjectName[] queues = broker.getQueues();
-        return getManagedObjects(queues, QueueViewMBean.class);
-    }
-    */
-    public Collection getQueues() throws Exception {
-        ManagedRegionBroker broker = getManagedBroker();
-        if (broker == null) {
-            return new ArrayList();
-        }
-        return broker.getQueueRegion().getDestinationMap().values();
-    }
-
-    
-    public Collection getTopics() throws Exception {
-        BrokerView broker = brokerService.getAdminView();
-        if (broker == null) {
-            return Collections.EMPTY_LIST;
-        }
-        ObjectName[] queues = broker.getTopics();
-        return getManagedObjects(queues, TopicViewMBean.class);
-    }
-    
-    public Collection getDurableTopicSubscribers() throws Exception {
-        BrokerView broker = brokerService.getAdminView();
-        if (broker == null) {
-            return Collections.EMPTY_LIST;
-        }
-        ObjectName[] queues = broker.getDurableTopicSubscribers();
-        return getManagedObjects(queues, DurableSubscriptionViewMBean.class);
-    }
-
-    protected Collection getManagedObjects(ObjectName[] names, Class type) {
-        List answer = new ArrayList();
-        MBeanServer mbeanServer = getManagementContext().getMBeanServer();
-        if (mbeanServer != null) {
-            for (int i = 0; i < names.length; i++) {
-                ObjectName name = names[i];
-                Object value = MBeanServerInvocationHandler.newProxyInstance(mbeanServer,
name, type, true);
-                if (value != null) {
-                    answer.add(value);
-                }
-            }
-        }
-        return answer;
-    }
-
-    /**
-     *
-     *
-     * public Collection getTopics() throws Exception { ManagedRegionBroker
-     * broker = getManagedBroker(); if (broker == null) { return new
-     * ArrayList(); } return
-     * broker.getTopicRegion().getDestinationMap().values(); }
-     */
 
     public void purgeQueue(ActiveMQDestination destination) throws Exception {
         Set destinations = getManagedBroker().getQueueRegion().getDestinations(destination);

Modified: activemq/trunk/activemq-web-console/src/main/webapp/queues.jsp
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web-console/src/main/webapp/queues.jsp?view=diff&rev=504251&r1=504250&r2=504251
==============================================================================
--- activemq/trunk/activemq-web-console/src/main/webapp/queues.jsp (original)
+++ activemq/trunk/activemq-web-console/src/main/webapp/queues.jsp Tue Feb  6 11:27:18 2007
@@ -54,10 +54,10 @@
 <c:forEach items="${requestContext.brokerQuery.queues}" var="row">
 <tr>
 <td><a href="browse.jsp?JMSDestination=${row.name}">${row.name}</a></td>
-<td>${row.destinationStatistics.messages.count}</td>
-<td>${row.destinationStatistics.consumers.count}</td>
-<td>${row.destinationStatistics.enqueues.count}</td>
-<td>${row.destinationStatistics.dequeues.count}</td>
+<td>${row.queueSize}</td>
+<td>${row.consumerCount}</td>
+<td>${row.enqueueCount}</td>
+<td>${row.dequeueCount}</td>
 <td>
     <a href="browse.jsp?JMSDestination=${row.name}">Browse</a>
 <%--    



Mime
View raw message