1 15 package org.apache.hivemind.management.impl; 16 17 import java.util.HashMap ; 18 import java.util.List ; 19 import java.util.Map ; 20 21 import javax.management.MBeanServer ; 22 import javax.management.remote.JMXConnectorServer ; 23 import javax.management.remote.JMXServiceURL ; 24 25 import org.apache.hivemind.ApplicationRuntimeException; 26 import org.apache.hivemind.ServiceImplementationFactory; 27 import org.apache.hivemind.ServiceImplementationFactoryParameters; 28 import org.apache.hivemind.management.ManagementMessages; 29 30 37 public class JMXConnectorServerFactory implements ServiceImplementationFactory 38 { 39 public JMXConnectorServerFactory(MBeanServer beanServer) 40 { 41 } 42 43 public Object createCoreServiceImplementation( 44 ServiceImplementationFactoryParameters factoryParameters) 45 { 46 List parameterList = (List ) factoryParameters.getParametersContainer(); 48 JMXConnectorServerParameter parameter = (JMXConnectorServerParameter) parameterList.get(0); 49 50 Map env = new HashMap (); 51 52 try 53 { 54 JMXServiceURL address = new JMXServiceURL (parameter.getJmxServiceURL()); 56 57 JMXConnectorServer server = javax.management.remote.JMXConnectorServerFactory 58 .newJMXConnectorServer(address, env, null); 59 60 return server; 61 } 62 catch (Exception e) 63 { 64 throw new ApplicationRuntimeException(ManagementMessages 65 .errorInstantiatingConnectorServer(parameter.getJmxServiceURL(), env, e), e); 66 } 67 } 68 69 } | Popular Tags |