diff --git a/source/code/JEE/Common/src/com/interopbridges/scx/ScxExceptionBundle.java b/source/code/JEE/Common/src/com/interopbridges/scx/ScxExceptionBundle.java index 8ca1f73..24a5a4f 100644 --- a/source/code/JEE/Common/src/com/interopbridges/scx/ScxExceptionBundle.java +++ b/source/code/JEE/Common/src/com/interopbridges/scx/ScxExceptionBundle.java @@ -94,7 +94,7 @@ private ScxExceptionBundle(ResourceBundle bundle) { /** *
* Get the localized message for the given Exception Code. - *
* * @param key * A key to look-up in the resource file. diff --git a/source/code/JEE/Common/src/com/interopbridges/scx/jeeinfo/JeeServerInfo.java b/source/code/JEE/Common/src/com/interopbridges/scx/jeeinfo/JeeServerInfo.java index 5d8773d..b3fb668 100644 --- a/source/code/JEE/Common/src/com/interopbridges/scx/jeeinfo/JeeServerInfo.java +++ b/source/code/JEE/Common/src/com/interopbridges/scx/jeeinfo/JeeServerInfo.java @@ -169,6 +169,11 @@ public Statistic getAppServerName() { ServerName = getJMXAttribute(ijmx, "WebSphere:j2eeType=J2EEServer,*", "platformName"); } + else + if(storename.compareTo(JmxConstant.KARAF_MBEAN_STORE_NAME)==0) + { + ServerName = "JBoss A-MQ (on Karaf)"; + } } } @@ -225,6 +230,11 @@ public Statistic getVersion() { ServerVersion = getJMXAttribute(ijmx, "WebSphere:j2eeType=J2EEServer,*", "platformVersion"); } + else + if(storename.compareTo(JmxConstant.KARAF_MBEAN_STORE_NAME)==0) + { + ServerVersion = getJMXAttribute(ijmx, "org.apache.activemq:brokerName=*,type=Broker", "BrokerVersion"); + } } } return ServerVersion!=null ? new Statistic(AppServerVersion, String.class, ServerVersion) : null; diff --git a/source/code/JEE/Common/src/com/interopbridges/scx/jmx/JmxStores.java b/source/code/JEE/Common/src/com/interopbridges/scx/jmx/JmxStores.java index 01d59ee..7d0bef9 100644 --- a/source/code/JEE/Common/src/com/interopbridges/scx/jmx/JmxStores.java +++ b/source/code/JEE/Common/src/com/interopbridges/scx/jmx/JmxStores.java @@ -80,6 +80,7 @@ public static void connectToJmxStores() addStoreToJmxStores(JmxConstant.TOMCAT_MBEAN_STORE_NAME,null); addStoreToJmxStores(JmxConstant.WEBSPHERE_MBEAN_STORE_NAME,null); addStoreToJmxStores(JmxConstant.WEBLOGIC_MBEAN_STORE_NAME,null); + addStoreToJmxStores(JmxConstant.KARAF_MBEAN_STORE_NAME,null); /* * The JdkJMXAbstraction needs to be the last entry in the list to avoid the * version information being processed from the JdkJMXAbstraction MBean store. diff --git a/source/code/JEE/Common/src/com/interopbridges/scx/jmx/KarafJMXAbstraction.java b/source/code/JEE/Common/src/com/interopbridges/scx/jmx/KarafJMXAbstraction.java new file mode 100644 index 0000000..46f6837 --- /dev/null +++ b/source/code/JEE/Common/src/com/interopbridges/scx/jmx/KarafJMXAbstraction.java @@ -0,0 +1,225 @@ +/** + * Copyright (c) Microsoft Corporation + * + * Licensed 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. + * + * THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS + * OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION + * ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, + * MERCHANTABLITY OR NON-INFRINGEMENT. + * + * See the Apache Version 2.0 License for specific language governing + * permissions and limitations under the License. + */ + +package com.interopbridges.scx.jmx; + +import java.io.IOException; +import java.lang.management.ManagementFactory; +import java.util.Set; + +import javax.management.AttributeNotFoundException; +import javax.management.InstanceAlreadyExistsException; +import javax.management.InstanceNotFoundException; +import javax.management.IntrospectionException; +import javax.management.MBeanException; +import javax.management.MBeanInfo; +import javax.management.MBeanRegistrationException; +import javax.management.MBeanServer; +import javax.management.MBeanServerConnection; +import javax.management.NotCompliantMBeanException; +import javax.management.ObjectInstance; +import javax.management.ObjectName; +import javax.management.QueryExp; +import javax.management.ReflectionException; +import javax.naming.NamingException; + +import com.interopbridges.scx.ScxException; + + +/** + *+ * Karaf 2.2.3 for the Runtime JMX Store + *
+ * + * @author Geoff Erasmus + */ +public class KarafJMXAbstraction implements IJMX { + + /** + *+ * Connection to the MBeanServer + *
+ */ + private MBeanServerConnection _server; + + /** + *+ * Constructor. The constructor sets the MBeanServer to be used by this class. + *
+ * + * @param server + * An instance of a MBeanServer to be used by this class. + * + */ + public KarafJMXAbstraction(MBeanServer server) throws + NamingException + { + _server = server; + } + + /** + *+ * Default Constructor. The constructor attempts to locate a reference to the Weblogic runtime JMX MBean Store + * it does not use specific API calls but rather does a JNDI lookup to retrieve the reference to the + * MBeanServer. + *
+ * + * @throws ScxException + * The JNDI lookup could not return an instance of a MBeanServer. + */ + public KarafJMXAbstraction() throws + NamingException, + ScxException + { + /* + try + { + //JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi"); + JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:1099/karaf-root"); + HashMap env = new HashMap(); + String[] credentials = new String[] {"admin","admin"}; + env.put(JMXConnector.CREDENTIALS, credentials); + + JMXConnector connector = JMXConnectorFactory.connect(url, env); + //JMXConnector connector = JMXConnectorFactory.connect(url, null); + _server = connector.getMBeanServerConnection(); + + } + catch (MalformedURLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + */ + _server = ManagementFactory.getPlatformMBeanServer(); + + } + + /* + * (non-Javadoc) + * + * @see com.interopbridges.scx.jmx.IJMX#getAttribute(javax.management.ObjectName, + * java.lang.String) + */ + public Object getAttribute(ObjectName name, String attribute) + throws MBeanException, AttributeNotFoundException, + InstanceNotFoundException, ReflectionException, IOException { + return this._server.getAttribute(name, attribute); + } + + /* + * (non-Javadoc) + * + * @see com.interopbridges.scx.jmx.IJMX#getMBeanServerID() + */ + public int getMBeanServerID() + { + return this._server.hashCode(); + } + + /* + * (non-Javadoc) + * + * @see com.interopbridges.scx.jmx.IJMX#getMBeanCount() + */ + public Integer getMBeanCount() + throws IOException + { + return this._server.getMBeanCount(); + } + + /* + * (non-Javadoc) + * + * @see com.interopbridges.scx.jmx.IJMX#getMBeanInfo(javax.management.ObjectName) + */ + public MBeanInfo getMBeanInfo(ObjectName name) + throws InstanceNotFoundException, IntrospectionException, + ReflectionException, IOException { + return this._server.getMBeanInfo(name); + } + + /* + * (non-Javadoc) + * + * @see com.interopbridges.scx.jmx.IJMX#isStandAloneJmxStore() + */ + public boolean isStandAloneJmxStore() + { + return true; + } + + /* + * (non-Javadoc) + * + * @see com.interopbridges.scx.jmx.IJMX#queryMBeans(javax.management.ObjectName, + * javax.management.QueryExp) + */ + public Set+ * Logger for the class. + *
+ */ + private static ILogger _logger = LoggingFactory.getLogger(); + + + /** + *+ * Interface to getting the desired MBeans from the JMX Store (as XML). + *
+ */ + protected MBeanGetter _mbeanAccessor; + + public BeanSpyMainTest(){ + + //this._logger = LoggingFactory.getLogger(); + _mbeanAccessor = new MBeanGetter(JmxStores.getListOfJmxStoreAbstractions()); + + + String JMXQuery = "org.apache.activemq:type=Broker,*"; + HashMap