1 23 24 29 30 package com.sun.enterprise.admin.jmx.remote; 31 32 import java.util.Map ; 33 import javax.management.remote.JMXServiceURL ; 34 import com.sun.enterprise.admin.jmx.remote.comm.AuthenticationInfo; 35 import com.sun.enterprise.admin.jmx.remote.comm.ConnectionFactory; 36 import com.sun.enterprise.admin.jmx.remote.comm.HttpConnectorAddress; 37 import com.sun.enterprise.admin.jmx.remote.internal.RemoteMBeanServerConnection; 38 39 import javax.management.MBeanServerConnection ; 40 41 47 48 final class MBeanServerConnectionFactory { 49 50 private MBeanServerConnectionFactory() { 51 } 52 53 63 64 static MBeanServerConnection getRemoteMBeanServerConnection(Map env, JMXServiceURL serviceUrl) 65 throws Exception { 66 return new RemoteMBeanServerConnection(env2HttpAddress(env, serviceUrl), env); 67 } 68 69 70 71 private static HttpConnectorAddress env2HttpAddress(Map env, JMXServiceURL serviceUrl) { 72 73 final HttpConnectorAddress ad = new HttpConnectorAddress(serviceUrl.getHost(), serviceUrl.getPort(), isHttps(serviceUrl), serviceUrl.getURLPath()); 74 75 ad.setAuthenticationInfo(env2AuthenticationInfo(env)); 76 return ( ad ); 77 } 78 79 80 81 private static AuthenticationInfo env2AuthenticationInfo(Map env) { 82 final String user = (String ) env.get(DefaultConfiguration.ADMIN_USER_ENV_PROPERTY_NAME); 83 final String pwd = (String ) env.get(DefaultConfiguration.ADMIN_PASSWORD_ENV_PROPERTY_NAME); 84 return ( new AuthenticationInfo(user, pwd) ); 85 } 86 87 private static boolean isHttps(JMXServiceURL url) { 88 return ( DefaultConfiguration.S1_HTTPS_PROTOCOL.equals(url.getProtocol()) ); 89 } 90 } 91 | Popular Tags |