[jboss-svn-commits] JBL Code SVN: r16776 - in labs/jbossesb/tags/JBESB_4_2_1_GA_CP_IR1/product/tools/console/management/src/main/java/org/jboss/soa/esb/monitoring: client and 1 other directory.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Sat Nov 24 01:57:55 EST 2007
Author: kevin.conner at jboss.com
Date: 2007-11-24 01:57:54 -0500 (Sat, 24 Nov 2007)
New Revision: 16776
Added:
labs/jbossesb/tags/JBESB_4_2_1_GA_CP_IR1/product/tools/console/management/src/main/java/org/jboss/soa/esb/monitoring/JMXTest.java
labs/jbossesb/tags/JBESB_4_2_1_GA_CP_IR1/product/tools/console/management/src/main/java/org/jboss/soa/esb/monitoring/client/DataCollector.java
labs/jbossesb/tags/JBESB_4_2_1_GA_CP_IR1/product/tools/console/management/src/main/java/org/jboss/soa/esb/monitoring/client/Invoker.java
labs/jbossesb/tags/JBESB_4_2_1_GA_CP_IR1/product/tools/console/management/src/main/java/org/jboss/soa/esb/monitoring/client/OperationsCollector.java
Removed:
labs/jbossesb/tags/JBESB_4_2_1_GA_CP_IR1/product/tools/console/management/src/main/java/org/jboss/soa/esb/monitoring/client/DataCollector.java
labs/jbossesb/tags/JBESB_4_2_1_GA_CP_IR1/product/tools/console/management/src/main/java/org/jboss/soa/esb/monitoring/client/Invoker.java
labs/jbossesb/tags/JBESB_4_2_1_GA_CP_IR1/product/tools/console/management/src/main/java/org/jboss/soa/esb/monitoring/client/OperationsCollector.java
Log:
Reverted files which were updated by mistake
Copied: labs/jbossesb/tags/JBESB_4_2_1_GA_CP_IR1/product/tools/console/management/src/main/java/org/jboss/soa/esb/monitoring/JMXTest.java (from rev 16774, labs/jbossesb/tags/JBESB_4_2_1_GA_CP_IR1/product/tools/console/management/src/main/java/org/jboss/soa/esb/monitoring/JMXTest.java)
===================================================================
--- labs/jbossesb/tags/JBESB_4_2_1_GA_CP_IR1/product/tools/console/management/src/main/java/org/jboss/soa/esb/monitoring/JMXTest.java (rev 0)
+++ labs/jbossesb/tags/JBESB_4_2_1_GA_CP_IR1/product/tools/console/management/src/main/java/org/jboss/soa/esb/monitoring/JMXTest.java 2007-11-24 06:57:54 UTC (rev 16776)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.soa.esb.monitoring;
+
+import javax.naming.*;
+
+import org.jboss.soa.esb.monitoring.client.DataCollector;
+
+import java.util.*;
+
+/**
+ * JMXTest is a simple command line test of the DataCollector.
+ *
+ * @author <a href="mailto:tcunning at redhat.com">Tom Cunningham</a>
+ * @since Version 4.2
+ */
+public class JMXTest {
+ public JMXTest() {
+ }
+
+ /**
+ * @param args the command line arguments
+ */
+ @SuppressWarnings("unchecked")
+ public static void main(String[] args) throws Exception
+ {
+ Hashtable environment = new Hashtable();
+ environment.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
+ environment.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
+ environment.put(Context.PROVIDER_URL, "jnp://127.0.0.1:1099");
+ InitialContext ic = new InitialContext(environment);
+
+ DataCollector dcollector = new DataCollector(ic);
+ dcollector.collectData();
+ StatisticsData data = dcollector.getData();
+ data.print();
+ }
+}
Deleted: labs/jbossesb/tags/JBESB_4_2_1_GA_CP_IR1/product/tools/console/management/src/main/java/org/jboss/soa/esb/monitoring/client/DataCollector.java
===================================================================
--- labs/jbossesb/tags/JBESB_4_2_1_GA_CP_IR1/product/tools/console/management/src/main/java/org/jboss/soa/esb/monitoring/client/DataCollector.java 2007-11-24 06:49:52 UTC (rev 16775)
+++ labs/jbossesb/tags/JBESB_4_2_1_GA_CP_IR1/product/tools/console/management/src/main/java/org/jboss/soa/esb/monitoring/client/DataCollector.java 2007-11-24 06:57:54 UTC (rev 16776)
@@ -1,174 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.soa.esb.monitoring.client;
-
-import java.io.IOException;
-import java.net.InetAddress;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.UnknownHostException;
-import java.util.Date;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import javax.management.MBeanAttributeInfo;
-import javax.management.MBeanInfo;
-import javax.management.MBeanServerConnection;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-
-import org.apache.log4j.Logger;
-import org.hibernate.Session;
-import org.jboss.mx.util.MBeanServerLocator;
-import org.jboss.soa.esb.monitoring.MonitoringSessionFactory;
-import org.jboss.soa.esb.monitoring.StatisticsBean;
-import org.jboss.soa.esb.monitoring.StatisticsData;
-import org.jboss.soa.esb.monitoring.pojo.JMXPattern;
-
-/**
- * DataCollector collects all JMX Attributes of ObjectNames that match
- * specific ObjectName patterns contained in the database. The JMX Attribute
- * data is collected in StatisticBean objects and then added to a StatisticData
- * collection.
- *
- * @author <a href="mailto:tcunning at redhat.com">Tom Cunningham</a>
- * @since Version 4.2
- */
-public class DataCollector {
- Logger logger = Logger.getLogger(DataCollector.class);
- private Context context;
- private MBeanServerConnection server;
- private StatisticsData data;
-
- public DataCollector() {
- try {
- context = new InitialContext();
- } catch (NamingException e) {
- logger.error("", e);
- }
- server = MBeanServerLocator.locateJBoss();
- data = new StatisticsData();
- }
-
- public DataCollector(Context f_context) {
- context = f_context;
- server = MBeanServerLocator.locateJBoss();
- data = new StatisticsData();
-
- }
-
- public MBeanServerConnection getServer() {
- return server;
- }
-
- public List getClassPatterns() {
- Session sess = (Session) MonitoringSessionFactory.getInstance().openSession();
- sess.beginTransaction();
- List result = sess.createQuery("from JMXPattern").list();
- sess.close();
- return result;
- }
-
- public List<ObjectName> getObjectNames(JMXPattern jmc, MBeanServerConnection server) {
- List<ObjectName> list = new ArrayList<ObjectName>();
- ObjectName namePattern;
- try {
- namePattern = new ObjectName(jmc.getClasspattern());
- Set result = server.queryNames(namePattern, null);
- Iterator iter = result.iterator();
- while (iter.hasNext()) {
- ObjectName on = (ObjectName) iter.next();
- if (on.getKeyPropertyListString().contains(jmc.getKeyvalue())) {
- list.add(on);
- logger.debug(jmc.getKeyvalue() + " matches " + on.getKeyPropertyListString());
- } else {
- logger.debug(jmc.getKeyvalue() + " does not match " + on.getKeyPropertyListString());
- }
- }
- } catch (MalformedObjectNameException e) {
- logger.error("", e);
- } catch (NullPointerException e) {
- logger.error("", e);
- } catch (IOException e) {
- logger.error("", e);
- }
-
- return list;
- }
-
- public void insertAttributes(ObjectName on) {
- String serverString = null;
- MBeanInfo info = null;
- Date date = new Date(System.currentTimeMillis());
- InetAddress addr = null;
- try {
- addr = InetAddress.getLocalHost();
- String jndiURLString = (String) context.getEnvironment().get(Context.PROVIDER_URL);
- URL jndiURL = new URL("http://" + jndiURLString);
- serverString = addr.getHostName() + ":" + jndiURL.getPort();
- } catch (UnknownHostException e) {
- logger.error("", e);
- } catch (NamingException e) {
- logger.error("", e);
- } catch (MalformedURLException e) {
- logger.error("", e);
- }
-
- try {
- info = server.getMBeanInfo(on);
- MBeanAttributeInfo[] mai = info.getAttributes();
- for (int i = 0; i < mai.length; i++) {
- StatisticsBean sb = new StatisticsBean(on.toString(), mai[i].getName(),
- serverString, date, mai[i].getType(),
- server.getAttribute(on, mai[i].getName()));
- if (sb.getData() != null) {
- ArrayList<StatisticsBean> list = (ArrayList<StatisticsBean>) data.getList();
- list.add(sb);
- }
- }
- } catch (Exception e) {
- logger.error("", e);
- }
- }
-
- public void collectData() {
- List jmxPatterns = getClassPatterns();
- for (int i = 0; i < jmxPatterns.size(); i++) {
- JMXPattern jmxc = (JMXPattern) jmxPatterns.get(i);
- List<ObjectName> objectNames = getObjectNames(jmxc, server);
- for (int j = 0; j < objectNames.size(); j++) {
- ObjectName on = (ObjectName) objectNames.get(j);
- insertAttributes(on);
- }
- }
- }
-
- public StatisticsData getData() {
- return data;
- }
-
-}
Copied: labs/jbossesb/tags/JBESB_4_2_1_GA_CP_IR1/product/tools/console/management/src/main/java/org/jboss/soa/esb/monitoring/client/DataCollector.java (from rev 16774, labs/jbossesb/tags/JBESB_4_2_1_GA_CP_IR1/product/tools/console/management/src/main/java/org/jboss/soa/esb/monitoring/client/DataCollector.java)
===================================================================
--- labs/jbossesb/tags/JBESB_4_2_1_GA_CP_IR1/product/tools/console/management/src/main/java/org/jboss/soa/esb/monitoring/client/DataCollector.java (rev 0)
+++ labs/jbossesb/tags/JBESB_4_2_1_GA_CP_IR1/product/tools/console/management/src/main/java/org/jboss/soa/esb/monitoring/client/DataCollector.java 2007-11-24 06:57:54 UTC (rev 16776)
@@ -0,0 +1,177 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.soa.esb.monitoring.client;
+
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.UnknownHostException;
+import java.util.Date;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import javax.management.MBeanAttributeInfo;
+import javax.management.MBeanInfo;
+import javax.management.MBeanServerConnection;
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.apache.log4j.Logger;
+import org.hibernate.Session;
+import org.jboss.soa.esb.monitoring.MonitoringSessionFactory;
+import org.jboss.soa.esb.monitoring.StatisticsBean;
+import org.jboss.soa.esb.monitoring.StatisticsData;
+import org.jboss.soa.esb.monitoring.pojo.JMXPattern;
+
+/**
+ * DataCollector collects all JMX Attributes of ObjectNames that match
+ * specific ObjectName patterns contained in the database. The JMX Attribute
+ * data is collected in StatisticBean objects and then added to a StatisticData
+ * collection.
+ *
+ * @author <a href="mailto:tcunning at redhat.com">Tom Cunningham</a>
+ * @since Version 4.2
+ */
+public class DataCollector {
+ Logger logger = Logger.getLogger(DataCollector.class);
+ private Context context;
+ private MBeanServerConnection server;
+ private StatisticsData data;
+
+ public DataCollector() {
+ try {
+ context = new InitialContext();
+ server = (MBeanServerConnection) context.lookup("jmx/invoker/RMIAdaptor");
+ } catch (NamingException e) {
+ logger.error("", e);
+ }
+ data = new StatisticsData();
+ }
+
+ public DataCollector(Context f_context) {
+ context = f_context;
+ try {
+ server = (MBeanServerConnection) context.lookup("jmx/invoker/RMIAdaptor");
+ } catch (NamingException e) {
+ logger.error("", e);
+ }
+ data = new StatisticsData();
+
+ }
+
+ public MBeanServerConnection getServer() {
+ return server;
+ }
+
+ public List getClassPatterns() {
+ Session sess = (Session) MonitoringSessionFactory.getInstance().openSession();
+ sess.beginTransaction();
+ List result = sess.createQuery("from JMXPattern").list();
+ sess.close();
+ return result;
+ }
+
+ public List<ObjectName> getObjectNames(JMXPattern jmc, MBeanServerConnection server) {
+ List<ObjectName> list = new ArrayList<ObjectName>();
+ ObjectName namePattern;
+ try {
+ namePattern = new ObjectName(jmc.getClasspattern());
+ Set result = server.queryNames(namePattern, null);
+ Iterator iter = result.iterator();
+ while (iter.hasNext()) {
+ ObjectName on = (ObjectName) iter.next();
+ if (on.getKeyPropertyListString().contains(jmc.getKeyvalue())) {
+ list.add(on);
+ logger.debug(jmc.getKeyvalue() + " matches " + on.getKeyPropertyListString());
+ } else {
+ logger.debug(jmc.getKeyvalue() + " does not match " + on.getKeyPropertyListString());
+ }
+ }
+ } catch (MalformedObjectNameException e) {
+ logger.error("", e);
+ } catch (NullPointerException e) {
+ logger.error("", e);
+ } catch (IOException e) {
+ logger.error("", e);
+ }
+
+ return list;
+ }
+
+ public void insertAttributes(ObjectName on) {
+ String serverString = null;
+ MBeanInfo info = null;
+ Date date = new Date(System.currentTimeMillis());
+ InetAddress addr = null;
+ try {
+ addr = InetAddress.getLocalHost();
+ String jndiURLString = (String) context.getEnvironment().get(Context.PROVIDER_URL);
+ URL jndiURL = new URL("http://" + jndiURLString);
+ serverString = addr.getHostName() + ":" + jndiURL.getPort();
+ } catch (UnknownHostException e) {
+ logger.error("", e);
+ } catch (NamingException e) {
+ logger.error("", e);
+ } catch (MalformedURLException e) {
+ logger.error("", e);
+ }
+
+ try {
+ info = server.getMBeanInfo(on);
+ MBeanAttributeInfo[] mai = info.getAttributes();
+ for (int i = 0; i < mai.length; i++) {
+ StatisticsBean sb = new StatisticsBean(on.toString(), mai[i].getName(),
+ serverString, date, mai[i].getType(),
+ server.getAttribute(on, mai[i].getName()));
+ if (sb.getData() != null) {
+ ArrayList<StatisticsBean> list = (ArrayList<StatisticsBean>) data.getList();
+ list.add(sb);
+ }
+ }
+ } catch (Exception e) {
+ logger.error("", e);
+ }
+ }
+
+ public void collectData() {
+ List jmxPatterns = getClassPatterns();
+ for (int i = 0; i < jmxPatterns.size(); i++) {
+ JMXPattern jmxc = (JMXPattern) jmxPatterns.get(i);
+ List<ObjectName> objectNames = getObjectNames(jmxc, server);
+ for (int j = 0; j < objectNames.size(); j++) {
+ ObjectName on = (ObjectName) objectNames.get(j);
+ insertAttributes(on);
+ }
+ }
+ }
+
+ public StatisticsData getData() {
+ return data;
+ }
+
+}
Deleted: labs/jbossesb/tags/JBESB_4_2_1_GA_CP_IR1/product/tools/console/management/src/main/java/org/jboss/soa/esb/monitoring/client/Invoker.java
===================================================================
--- labs/jbossesb/tags/JBESB_4_2_1_GA_CP_IR1/product/tools/console/management/src/main/java/org/jboss/soa/esb/monitoring/client/Invoker.java 2007-11-24 06:49:52 UTC (rev 16775)
+++ labs/jbossesb/tags/JBESB_4_2_1_GA_CP_IR1/product/tools/console/management/src/main/java/org/jboss/soa/esb/monitoring/client/Invoker.java 2007-11-24 06:57:54 UTC (rev 16776)
@@ -1,48 +0,0 @@
-package org.jboss.soa.esb.monitoring.client;
-
-import java.io.IOException;
-
-import javax.management.InstanceNotFoundException;
-import javax.management.MBeanException;
-import javax.management.MBeanServerConnection;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-import javax.management.ReflectionException;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-
-import org.apache.log4j.Logger;
-import org.jboss.mx.util.MBeanServerLocator;
-import org.jboss.soa.esb.message.body.content.ServiceControlCommand;
-
-public class Invoker {
- Logger logger = Logger.getLogger(Invoker.class);
- private MBeanServerConnection server;
-
- public Invoker() {
- server = MBeanServerLocator.locateJBoss();
- }
-
- public Object invoke(ServiceControlCommand obean) {
- ObjectName on = null;
- try {
- on = new ObjectName(obean.getObjectName());
- Object result = server.invoke(on, obean.getOperation(), null, null);
- return result;
- } catch (MalformedObjectNameException e) {
- logger.error("", e);
- } catch (NullPointerException e) {
- logger.error("", e);
- } catch (InstanceNotFoundException e) {
- logger.error("", e);
- } catch (MBeanException e) {
- logger.error("", e);
- } catch (ReflectionException e) {
- logger.error("", e);
- } catch (IOException e) {
- logger.error("", e);
- }
- return null;
- }
-}
Copied: labs/jbossesb/tags/JBESB_4_2_1_GA_CP_IR1/product/tools/console/management/src/main/java/org/jboss/soa/esb/monitoring/client/Invoker.java (from rev 16774, labs/jbossesb/tags/JBESB_4_2_1_GA_CP_IR1/product/tools/console/management/src/main/java/org/jboss/soa/esb/monitoring/client/Invoker.java)
===================================================================
--- labs/jbossesb/tags/JBESB_4_2_1_GA_CP_IR1/product/tools/console/management/src/main/java/org/jboss/soa/esb/monitoring/client/Invoker.java (rev 0)
+++ labs/jbossesb/tags/JBESB_4_2_1_GA_CP_IR1/product/tools/console/management/src/main/java/org/jboss/soa/esb/monitoring/client/Invoker.java 2007-11-24 06:57:54 UTC (rev 16776)
@@ -0,0 +1,53 @@
+package org.jboss.soa.esb.monitoring.client;
+
+import java.io.IOException;
+
+import javax.management.InstanceNotFoundException;
+import javax.management.MBeanException;
+import javax.management.MBeanServerConnection;
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+import javax.management.ReflectionException;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.apache.log4j.Logger;
+import org.jboss.soa.esb.message.body.content.ServiceControlCommand;
+
+public class Invoker {
+ Logger logger = Logger.getLogger(Invoker.class);
+ private Context context;
+ private MBeanServerConnection server;
+
+ public Invoker() {
+ try {
+ context = new InitialContext();
+ server = (MBeanServerConnection) context.lookup("jmx/invoker/RMIAdaptor");
+ } catch (NamingException e) {
+ logger.error("", e);
+ }
+ }
+
+ public Object invoke(ServiceControlCommand obean) {
+ ObjectName on = null;
+ try {
+ on = new ObjectName(obean.getObjectName());
+ Object result = server.invoke(on, obean.getOperation(), null, null);
+ return result;
+ } catch (MalformedObjectNameException e) {
+ logger.error("", e);
+ } catch (NullPointerException e) {
+ logger.error("", e);
+ } catch (InstanceNotFoundException e) {
+ logger.error("", e);
+ } catch (MBeanException e) {
+ logger.error("", e);
+ } catch (ReflectionException e) {
+ logger.error("", e);
+ } catch (IOException e) {
+ logger.error("", e);
+ }
+ return null;
+ }
+}
Deleted: labs/jbossesb/tags/JBESB_4_2_1_GA_CP_IR1/product/tools/console/management/src/main/java/org/jboss/soa/esb/monitoring/client/OperationsCollector.java
===================================================================
--- labs/jbossesb/tags/JBESB_4_2_1_GA_CP_IR1/product/tools/console/management/src/main/java/org/jboss/soa/esb/monitoring/client/OperationsCollector.java 2007-11-24 06:49:52 UTC (rev 16775)
+++ labs/jbossesb/tags/JBESB_4_2_1_GA_CP_IR1/product/tools/console/management/src/main/java/org/jboss/soa/esb/monitoring/client/OperationsCollector.java 2007-11-24 06:57:54 UTC (rev 16776)
@@ -1,145 +0,0 @@
-package org.jboss.soa.esb.monitoring.client;
-
-import java.io.IOException;
-import java.net.InetAddress;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.UnknownHostException;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import javax.management.MBeanInfo;
-import javax.management.MBeanOperationInfo;
-import javax.management.MBeanServerConnection;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-
-import org.apache.log4j.Logger;
-import org.hibernate.Session;
-import org.jboss.mx.util.MBeanServerLocator;
-import org.jboss.soa.esb.message.body.content.ServiceControlCommand;
-import org.jboss.soa.esb.monitoring.MonitoringSessionFactory;
-import org.jboss.soa.esb.monitoring.OperationsData;
-import org.jboss.soa.esb.monitoring.pojo.JMXPattern;
-
-public class OperationsCollector {
-
- Logger logger = Logger.getLogger(OperationsCollector.class);
- private Context context;
- private MBeanServerConnection server;
- private OperationsData data;
-
- public OperationsCollector() {
- try {
- context = new InitialContext();
- } catch (NamingException e) {
- logger.error("", e);
- }
- server = MBeanServerLocator.locateJBoss();
- data = new OperationsData();
- }
-
- public OperationsCollector(Context f_context) {
- context = f_context;
- server = MBeanServerLocator.locateJBoss();
- data = new OperationsData();
-
- }
-
- public MBeanServerConnection getServer() {
- return server;
- }
-
- public List getClassPatterns() {
- Session sess = (Session) MonitoringSessionFactory.getInstance().openSession();
- sess.beginTransaction();
- List result = sess.createQuery("from JMXPattern").list();
- sess.close();
- return result;
- }
-
- public List<ObjectName> getObjectNames(JMXPattern jmc, MBeanServerConnection server) {
- List<ObjectName> list = new ArrayList<ObjectName>();
- ObjectName namePattern;
- try {
- namePattern = new ObjectName(jmc.getClasspattern());
- Set result = server.queryNames(namePattern, null);
- Iterator iter = result.iterator();
- while (iter.hasNext()) {
- ObjectName on = (ObjectName) iter.next();
- if (on.getKeyPropertyListString().contains(jmc.getKeyvalue())) {
- list.add(on);
- logger.debug(jmc.getKeyvalue() + " matches " + on.getKeyPropertyListString());
- } else {
- logger.debug(jmc.getKeyvalue() + " does not match " + on.getKeyPropertyListString());
- }
- }
- } catch (MalformedObjectNameException e) {
- logger.error("", e);
- } catch (NullPointerException e) {
- logger.error("", e);
- } catch (IOException e) {
- logger.error("", e);
- }
-
- return list;
- }
-
- public void insertOperations(ObjectName on) {
- String serverString = null;
- MBeanInfo info = null;
- Date date = new Date(System.currentTimeMillis());
- InetAddress addr = null;
- try {
- addr = InetAddress.getLocalHost();
- String jndiURLString = (String) context.getEnvironment().get(Context.PROVIDER_URL);
- URL jndiURL = new URL("http://" + jndiURLString);
- serverString = addr.getHostName() + ":" + jndiURL.getPort();
- } catch (UnknownHostException e) {
- logger.error("", e);
- } catch (NamingException e) {
- logger.error("", e);
- } catch (MalformedURLException e) {
- logger.error("", e);
- }
-
- try {
- info = server.getMBeanInfo(on);
- MBeanOperationInfo[] moi = info.getOperations();
- for (int i = 0; i < moi.length; i++) {
- ServiceControlCommand ob = new ServiceControlCommand(on.toString(), serverString,
- date, moi[i].getName(), moi[i].getDescription(),
- moi[i].getReturnType());
- if (moi[i].getSignature().length == 0) {
- ArrayList<ServiceControlCommand> list = (ArrayList<ServiceControlCommand>) data.getList();
- list.add(ob);
- }
- }
- } catch (Exception e) {
- logger.error("", e);
- }
- }
-
- public void collectData() {
- List jmxPatterns = getClassPatterns();
- for (int i = 0; i < jmxPatterns.size(); i++) {
- JMXPattern jmxc = (JMXPattern) jmxPatterns.get(i);
- List<ObjectName> objectNames = getObjectNames(jmxc, server);
- for (int j = 0; j < objectNames.size(); j++) {
- ObjectName on = (ObjectName) objectNames.get(j);
- insertOperations(on);
- }
- }
- }
-
- public OperationsData getData() {
- return data;
- }
-
-}
Copied: labs/jbossesb/tags/JBESB_4_2_1_GA_CP_IR1/product/tools/console/management/src/main/java/org/jboss/soa/esb/monitoring/client/OperationsCollector.java (from rev 16774, labs/jbossesb/tags/JBESB_4_2_1_GA_CP_IR1/product/tools/console/management/src/main/java/org/jboss/soa/esb/monitoring/client/OperationsCollector.java)
===================================================================
--- labs/jbossesb/tags/JBESB_4_2_1_GA_CP_IR1/product/tools/console/management/src/main/java/org/jboss/soa/esb/monitoring/client/OperationsCollector.java (rev 0)
+++ labs/jbossesb/tags/JBESB_4_2_1_GA_CP_IR1/product/tools/console/management/src/main/java/org/jboss/soa/esb/monitoring/client/OperationsCollector.java 2007-11-24 06:57:54 UTC (rev 16776)
@@ -0,0 +1,148 @@
+package org.jboss.soa.esb.monitoring.client;
+
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.UnknownHostException;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import javax.management.MBeanInfo;
+import javax.management.MBeanOperationInfo;
+import javax.management.MBeanServerConnection;
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.apache.log4j.Logger;
+import org.hibernate.Session;
+import org.jboss.soa.esb.message.body.content.ServiceControlCommand;
+import org.jboss.soa.esb.monitoring.MonitoringSessionFactory;
+import org.jboss.soa.esb.monitoring.OperationsData;
+import org.jboss.soa.esb.monitoring.pojo.JMXPattern;
+
+public class OperationsCollector {
+
+ Logger logger = Logger.getLogger(OperationsCollector.class);
+ private Context context;
+ private MBeanServerConnection server;
+ private OperationsData data;
+
+ public OperationsCollector() {
+ try {
+ context = new InitialContext();
+ server = (MBeanServerConnection) context.lookup("jmx/invoker/RMIAdaptor");
+ } catch (NamingException e) {
+ logger.error("", e);
+ }
+ data = new OperationsData();
+ }
+
+ public OperationsCollector(Context f_context) {
+ context = f_context;
+ try {
+ server = (MBeanServerConnection) context.lookup("jmx/invoker/RMIAdaptor");
+ } catch (NamingException e) {
+ logger.error("", e);
+ }
+ data = new OperationsData();
+
+ }
+
+ public MBeanServerConnection getServer() {
+ return server;
+ }
+
+ public List getClassPatterns() {
+ Session sess = (Session) MonitoringSessionFactory.getInstance().openSession();
+ sess.beginTransaction();
+ List result = sess.createQuery("from JMXPattern").list();
+ sess.close();
+ return result;
+ }
+
+ public List<ObjectName> getObjectNames(JMXPattern jmc, MBeanServerConnection server) {
+ List<ObjectName> list = new ArrayList<ObjectName>();
+ ObjectName namePattern;
+ try {
+ namePattern = new ObjectName(jmc.getClasspattern());
+ Set result = server.queryNames(namePattern, null);
+ Iterator iter = result.iterator();
+ while (iter.hasNext()) {
+ ObjectName on = (ObjectName) iter.next();
+ if (on.getKeyPropertyListString().contains(jmc.getKeyvalue())) {
+ list.add(on);
+ logger.debug(jmc.getKeyvalue() + " matches " + on.getKeyPropertyListString());
+ } else {
+ logger.debug(jmc.getKeyvalue() + " does not match " + on.getKeyPropertyListString());
+ }
+ }
+ } catch (MalformedObjectNameException e) {
+ logger.error("", e);
+ } catch (NullPointerException e) {
+ logger.error("", e);
+ } catch (IOException e) {
+ logger.error("", e);
+ }
+
+ return list;
+ }
+
+ public void insertOperations(ObjectName on) {
+ String serverString = null;
+ MBeanInfo info = null;
+ Date date = new Date(System.currentTimeMillis());
+ InetAddress addr = null;
+ try {
+ addr = InetAddress.getLocalHost();
+ String jndiURLString = (String) context.getEnvironment().get(Context.PROVIDER_URL);
+ URL jndiURL = new URL("http://" + jndiURLString);
+ serverString = addr.getHostName() + ":" + jndiURL.getPort();
+ } catch (UnknownHostException e) {
+ logger.error("", e);
+ } catch (NamingException e) {
+ logger.error("", e);
+ } catch (MalformedURLException e) {
+ logger.error("", e);
+ }
+
+ try {
+ info = server.getMBeanInfo(on);
+ MBeanOperationInfo[] moi = info.getOperations();
+ for (int i = 0; i < moi.length; i++) {
+ ServiceControlCommand ob = new ServiceControlCommand(on.toString(), serverString,
+ date, moi[i].getName(), moi[i].getDescription(),
+ moi[i].getReturnType());
+ if (moi[i].getSignature().length == 0) {
+ ArrayList<ServiceControlCommand> list = (ArrayList<ServiceControlCommand>) data.getList();
+ list.add(ob);
+ }
+ }
+ } catch (Exception e) {
+ logger.error("", e);
+ }
+ }
+
+ public void collectData() {
+ List jmxPatterns = getClassPatterns();
+ for (int i = 0; i < jmxPatterns.size(); i++) {
+ JMXPattern jmxc = (JMXPattern) jmxPatterns.get(i);
+ List<ObjectName> objectNames = getObjectNames(jmxc, server);
+ for (int j = 0; j < objectNames.size(); j++) {
+ ObjectName on = (ObjectName) objectNames.get(j);
+ insertOperations(on);
+ }
+ }
+ }
+
+ public OperationsData getData() {
+ return data;
+ }
+
+}
More information about the jboss-svn-commits
mailing list