activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rajdav...@apache.org
Subject svn commit: r907199 - in /activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web: BrokerFacade.java BrokerFacadeSupport.java JobFacade.java
Date Sat, 06 Feb 2010 09:06:42 GMT
Author: rajdavies
Date: Sat Feb  6 09:06:42 2010
New Revision: 907199

URL: http://svn.apache.org/viewvc?rev=907199&view=rev
Log:
support for scheduling

Added:
    activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/JobFacade.java   (with
props)
Modified:
    activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/BrokerFacade.java
    activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/BrokerFacadeSupport.java

Modified: activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/BrokerFacade.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/BrokerFacade.java?rev=907199&r1=907198&r2=907199&view=diff
==============================================================================
--- activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/BrokerFacade.java (original)
+++ activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/BrokerFacade.java Sat
Feb  6 09:06:42 2010
@@ -17,11 +17,11 @@
 package org.apache.activemq.web;
 
 import java.util.Collection;
-
 import org.apache.activemq.broker.jmx.BrokerViewMBean;
 import org.apache.activemq.broker.jmx.ConnectionViewMBean;
 import org.apache.activemq.broker.jmx.ConnectorViewMBean;
 import org.apache.activemq.broker.jmx.DurableSubscriptionViewMBean;
+import org.apache.activemq.broker.jmx.JobSchedulerViewMBean;
 import org.apache.activemq.broker.jmx.NetworkConnectorViewMBean;
 import org.apache.activemq.broker.jmx.QueueViewMBean;
 import org.apache.activemq.broker.jmx.SubscriptionViewMBean;
@@ -178,4 +178,19 @@
 	 * @throws Exception
 	 */
 	TopicViewMBean getTopic(String name) throws Exception;
+	
+	/**
+	 * Get the JobScheduler MBean
+	 * @return the jobScheduler or null if not configured
+	 * @throws Exception
+	 */
+	JobSchedulerViewMBean getJobScheduler() throws Exception;
+	
+	/**
+     * Get the JobScheduler MBean
+     * @return the jobScheduler or null if not configured
+     * @throws Exception
+     */
+    Collection<JobFacade> getScheduledJobs() throws Exception;
+
 }
\ No newline at end of file

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=907199&r1=907198&r2=907199&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
Sat Feb  6 09:06:42 2010
@@ -16,24 +16,28 @@
  */
 package org.apache.activemq.web;
 
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import javax.management.ObjectName;
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.TabularData;
 import org.apache.activemq.broker.jmx.BrokerViewMBean;
 import org.apache.activemq.broker.jmx.ConnectionViewMBean;
 import org.apache.activemq.broker.jmx.ConnectorViewMBean;
 import org.apache.activemq.broker.jmx.DestinationViewMBean;
 import org.apache.activemq.broker.jmx.DurableSubscriptionViewMBean;
+import org.apache.activemq.broker.jmx.JobSchedulerViewMBean;
 import org.apache.activemq.broker.jmx.ManagementContext;
 import org.apache.activemq.broker.jmx.NetworkConnectorViewMBean;
 import org.apache.activemq.broker.jmx.QueueViewMBean;
 import org.apache.activemq.broker.jmx.SubscriptionViewMBean;
 import org.apache.activemq.broker.jmx.TopicViewMBean;
 import org.springframework.util.StringUtils;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-import javax.management.ObjectName;
+
 /**
  * A useful base class for an implementation of {@link BrokerFacade}
  * 
@@ -102,13 +106,10 @@
         return answer;
     }
 
-   
-
     @SuppressWarnings("unchecked")
     public Collection<ConnectionViewMBean> getConnections() throws Exception {
         String brokerName = getBrokerName();
         ObjectName query = new ObjectName("org.apache.activemq:BrokerName=" + brokerName
+ ",Type=Connection,*");
-        System.out.println(query);
         Set<ObjectName> queryResult = getManagementContext().queryNames(query, null);
         return getManagedObjects(queryResult.toArray(new ObjectName[queryResult.size()]),
ConnectionViewMBean.class);
     }
@@ -137,8 +138,8 @@
         if (queryResult.size() == 0)
             return null;
         ObjectName objectName = queryResult.iterator().next();
-        return (ConnectionViewMBean) getManagementContext().newProxyInstance(objectName,
-                ConnectionViewMBean.class, true);
+        return (ConnectionViewMBean) getManagementContext().newProxyInstance(objectName,
ConnectionViewMBean.class,
+                true);
     }
 
     @SuppressWarnings("unchecked")
@@ -156,8 +157,7 @@
         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) getManagementContext().newProxyInstance(objectName, ConnectorViewMBean.class,
true);
     }
 
     @SuppressWarnings("unchecked")
@@ -187,4 +187,21 @@
         Set<ObjectName> queryResult = getManagementContext().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);
+    }
+
+    public Collection<JobFacade> getScheduledJobs() throws Exception {
+        JobSchedulerViewMBean jobScheduler = getJobScheduler();
+        List<JobFacade> result = new ArrayList<JobFacade>();
+        TabularData table = jobScheduler.getAllJobs();
+        for (Object object : table.values()) {
+            CompositeData cd = (CompositeData) object;
+            JobFacade jf = new JobFacade(cd);
+            result.add(jf);
+        }
+        return result;
+    }
 }

Added: activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/JobFacade.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/JobFacade.java?rev=907199&view=auto
==============================================================================
--- activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/JobFacade.java (added)
+++ activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/JobFacade.java Sat Feb
 6 09:06:42 2010
@@ -0,0 +1,62 @@
+/**
+ * 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 javax.management.openmbean.CompositeData;
+
+public class JobFacade {
+    private final CompositeData data;
+    public JobFacade(CompositeData data) {
+        this.data = data;
+    }
+    public String getCronEntry() {
+        return data.get("cronEntry").toString();
+    }
+
+    public String getJobId() {
+        return toString(data.get("jobId"));
+    }
+
+    public String getNextExecutionTime() {
+        return toString(data.get("next"));
+    }
+
+    public long getPeriod() {
+        Long result = (Long) data.get("period");
+        if (result != null) {
+            return result.longValue();
+        }
+        return 0l;
+    }
+
+    public int getRepeat() {
+        Integer result = (Integer) data.get("repeat");
+        if (result != null) {
+            return result.intValue();
+        }
+        return 0;
+    }
+
+    public String getStart() {
+        return toString(data.get("start"));
+    }
+
+    private String toString(Object object) {
+        return object != null ? object.toString() : "";
+    }
+
+}

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

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



Mime
View raw message