Fields Summary |
---|
private static final String | mBeanName |
private static URLConnection | conn |
private static URL | url |
private static ObjectOutputStream | objectWriter |
private static ObjectInputStream | objectReader |
private static String | adminUser |
private static String | adminPassword |
private static int | adminPort |
private static String | contextRoot |
private static String | host |
public static final String | ADMIN_USER_ENV_PROPERTY_NAME |
public static final String | ADMIN_PASSWORD_ENV_PROPERTY_NAME |
public static final String | TRUST_MANAGER_PROPERTY_NAME |
public static final String | KEY_MANAGER_PROPERTY_NAME |
public static final String | SSL_SOCKET_FACTORY |
public static final String | HOSTNAME_VERIFIER_PROPERTY_NAME |
public static final String | STRING_MANAGER_CLASS_NAME |
public static final String | DEFAULT_TRUST_MANAGER |
public static final String | SERVLET_CONTEXT_PROPERTY_NAME |
public static final String | HTTP_AUTH_PROPERTY_NAME |
public static final String | DEFAULT_SERVLET_CONTEXT_ROOT |
public static final String | DEFAULT_HTTP_AUTH_SCHEME |
public static final String | DIGEST_HTTP_AUTH_SCHEME |
public static final String | S1_HTTP_PROTOCOL |
public static final String | S1_HTTPS_PROTOCOL |
Methods Summary |
---|
private static javax.management.MBeanServerConnection | getMBeanServerConnection()Local the MBeanServer.
return getMBeanServerConnection(host,adminPort,adminUser,adminPassword);
|
private static javax.management.MBeanServerConnection | getMBeanServerConnection(java.lang.String host, int port, java.lang.String user, java.lang.String password)Get an Server Connection.
final JMXServiceURL url =
new JMXServiceURL("service:jmx:s1ashttp://" + host + ":" + port);
final Map env = new HashMap();
final String PKGS = "com.sun.enterprise.admin.jmx.remote.protocol";
env.put(JMXConnectorFactory.PROTOCOL_PROVIDER_PACKAGES, PKGS);
env.put(ADMIN_USER_ENV_PROPERTY_NAME, user );
env.put( ADMIN_PASSWORD_ENV_PROPERTY_NAME, password);
env.put(HTTP_AUTH_PROPERTY_NAME, DEFAULT_HTTP_AUTH_SCHEME);
final JMXConnector conn = JMXConnectorFactory.connect(url, env);
return conn.getMBeanServerConnection();
|
private static javax.management.MBeanServerConnection | getSecureMBeanServerConnection()Get a secure JMX connection.
return getSecureMBeanServerConnection(host,adminPort,adminUser,
adminPassword);
|
private static javax.management.MBeanServerConnection | getSecureMBeanServerConnection(java.lang.String host, int port, java.lang.String user, java.lang.String password)Get a secure JMX connection.
final JMXServiceURL url = new JMXServiceURL("service:jmx:s1ashttps://" +
host + ":" + port);
final Map env = new HashMap();
final String PKGS = "com.sun.enterprise.admin.jmx.remote.protocol";
env.put(JMXConnectorFactory.PROTOCOL_PROVIDER_PACKAGES, PKGS);
env.put(ADMIN_USER_ENV_PROPERTY_NAME, user );
env.put( ADMIN_PASSWORD_ENV_PROPERTY_NAME, password);
env.put(HTTP_AUTH_PROPERTY_NAME, DIGEST_HTTP_AUTH_SCHEME);
final JMXConnector conn = JMXConnectorFactory.connect(url, env);
return conn.getMBeanServerConnection();
|
public static void | main(java.lang.String[] args)
try{
String command = args[0];
host = args[1];
contextRoot = "/" + args[2];
adminUser = args[3];
adminPassword = args[4];
adminPort = Integer.parseInt(args[5]);
if ( command.equals("--restart")){
restart(mBeanName + contextRoot);
} else if (command.equals("--reload")){
reload(mBeanName + contextRoot);
}
System.out.println("DEPLOYMENT SUCCESS");
} catch(Throwable ex){
System.out.println("Usage\n");
System.out.println("jmxReload --reload|restart");
System.out.print(" [contextRoot]");
ex.printStackTrace();
System.out.println("DEPLOYMENT FAILED");
}
|
private static void | reload(java.lang.String oName)
ObjectName appMBean = new ObjectName(oName);
try {
reloadHttp(appMBean);
} catch (Throwable t){
t.printStackTrace();
reloadHttps(appMBean);
}
|
private static void | reloadHttp(javax.management.ObjectName appMBean)Reload the Context using JMX and HTTP.
Object[] params = new Object[0];
String[] signature = new String[0];
System.out.println("Reload Context: " + contextRoot);
Object o= getMBeanServerConnection().
invoke(appMBean, "reload", params, signature);
|
private static void | reloadHttps(javax.management.ObjectName appMBean)Reload the Context using JMX and HTTPs
Object[] params = new Object[0];
String[] signature = new String[0];
System.out.println("Reloading Context: " + contextRoot);
Object o= getSecureMBeanServerConnection()
.invoke(appMBean, "reload", params, signature);
|
private static void | restart(java.lang.String oName)
ObjectName appMBean = new ObjectName(oName);
try {
restartHttp(appMBean);
} catch (Throwable t){
restartHttps(appMBean);
}
|
private static void | restartHttp(javax.management.ObjectName appMBean)Reload the Context using JMX and HTTP.
Object[] params = new Object[0];
String[] signature = new String[0];
System.out.println("Stopping Context: " + contextRoot);
Object o= getMBeanServerConnection().
invoke(appMBean, "stop", params, signature);
System.out.println("Starting Context: " + contextRoot);
o= getMBeanServerConnection()
.invoke(appMBean, "start", params, signature);
|
private static void | restartHttps(javax.management.ObjectName appMBean)Reload the Context using JMX and HTTPs
Object[] params = new Object[0];
String[] signature = new String[0];
System.out.println("Stopping Context: " + contextRoot);
Object o= getSecureMBeanServerConnection()
.invoke(appMBean, "stop", params, signature);
System.out.println("Starting Context: " + contextRoot);
o= getSecureMBeanServerConnection().invoke(
appMBean, "start", params, signature);
|