1 23 24 29 30 package com.sun.enterprise.admin.jmx.remote; 31 32 import java.util.Map ; 33 import java.util.HashMap ; 34 import java.io.IOException ; 35 36 import javax.management.remote.JMXServiceURL ; 37 import javax.management.remote.JMXConnector ; 38 import javax.management.remote.JMXConnectorFactory ; 39 import com.sun.enterprise.admin.jmx.remote.DefaultConfiguration; 40 41 50 51 public class SunOneHttpJmxConnectorFactory { 52 53 54 private SunOneHttpJmxConnectorFactory() { 55 } 56 57 private static Map initEnvironment() { 58 final Map env = new HashMap (); 59 final String PKGS = "com.sun.enterprise.admin.jmx.remote.protocol"; 60 env.put(JMXConnectorFactory.PROTOCOL_PROVIDER_PACKAGES, PKGS); 61 env.put(DefaultConfiguration.HTTP_AUTH_PROPERTY_NAME, DefaultConfiguration.DEFAULT_HTTP_AUTH_SCHEME); 62 63 return ( env ); 64 } 65 66 public static JMXConnector connect(JMXServiceURL url, String user, String password) 67 throws IOException { 68 return connect(url, user, password, null); 69 } 70 71 public static JMXConnector connect(JMXServiceURL url, String user, String password, Map extraEnv) 72 throws IOException { 73 final Map env = initEnvironment(); 74 if (user != null) 75 env.put(DefaultConfiguration.ADMIN_USER_ENV_PROPERTY_NAME, user); 76 if (password != null) 77 env.put(DefaultConfiguration.ADMIN_PASSWORD_ENV_PROPERTY_NAME, password); 78 if (extraEnv != null) env.putAll(extraEnv); 79 80 return ( JMXConnectorFactory.connect(url, env) ); 81 } 82 } 83 | Popular Tags |