Dynamic Clustering in Apache Application Server
To enable dynamic clustering in Apache Application Server, JMS is required. Java Messaging System (JMS) communicates with the server through messaging and is used for configuring server properties dynamically without restarting the server system. The following code snippet gives the option for enabling clustering with Apache Web Server:
Registry registry =Registry.getRegistry();
MBeanServer mBeanServer = Registry.getRegistry().getServer()
String beans[]=registry.findManagedBeans();
ManagedBean mbeanProxy = registry.findManagedBean("org.jboss.modcluster.ModClusterListener");
ClassNameMBean mbean= new ClassNameMBean();
mbean.setManagedBean(mbeanProxy);
OperationInfo info[] = mbeanProxy.getOperations() ;
for(int i=0;i-1){
OperationInfo opinfo=info[i];
ParameterInfo param[]=opinfo.getSignature();
Object params[] = {"localhost",9999};
String sig[] = {"java.lang.String","int"};
mbeanProxy.getInvoke("addProxy",params,sig,mbean,null);
}
}
Dynamically Deploying/Undeploying Apps in Tomcat
The following code snippet is for deploying Web applications in Tomcat:
DeployTask dt = new DeployTask();
dt.setUrl("http://localhost:8080/manager");
dt.setUsername("admin");
dt.setPassword("admin");
dt.setPath("/examples11");
dt.setWar("d:/cas-cert/examples1/examples11.war");
dt.execute();
The following code snippet is for undeploying Web applications in Tomcat.
UndeployTask udt = new UndeployTask();
udt.setUrl("http://localhost:8080/manager");
udt.setUsername("admin");
udt.setPassword("admin");
//http://localhost:8080/manager/undeploy?path=/examples11
udt.setPath("/examples11");
udt.execute(); : : : : :