/*
* LocalServerTest
* $Id: LocalServerTest.java,v 1.6 2003/01/09 07:12:40 telrod Exp $
*/
package samples.scenario1;
import org.jboss.mx.remote.discovery.multicast.MulticastDetector;
import org.jboss.mx.remote.server.CascadingAgent;
import org.jboss.mx.remote.connector.socket.SocketConnector;
import javax.management.MBeanServer;
import javax.management.MBeanServerFactory;
import javax.management.ObjectInstance;
import javax.management.ObjectName;
/**
* @version 2.5
* @since Sep 25, 2002
* @author <a href="mailto:telrod@e2technologies.net">Tom ELrod/a>
*/
public class LocalServerTest
{
/**
* This is the sample for scenario 1 where there is a local
* MBeanServer, Detector, and CascadingAgent that will
* discover remote MBeanServers and MBeans.
* <p>
* If any argument is passed, and HTMLAdaptorServer will be
* started on port 8083. Point your browser to http://localhost:8083
* to view all the MBeanServers and MBeans (remote and local).
*/
public static void main(String args[])
{
try
{
org.apache.log4j.BasicConfigurator.configure();
org.apache.log4j.Category.getRoot().setLevel(org.apache.log4j.Level.INFO);
MBeanServer server = MBeanServerFactory.createMBeanServer();
LocalTest testMBean = new LocalTest();
server.registerMBean(testMBean,new ObjectName("test:type=LocalTest"));
System.err.println("LocalTest registered: "+testMBean);
SocketConnector connector = new SocketConnector();
server.registerMBean(connector, new ObjectName("jmx.remoting:type=Connector,transport=socket"));
connector.start();
System.err.println("Starting SocketConnector");
MulticastDetector detector = new MulticastDetector();
server.registerMBean(detector, new ObjectName("jmx.remoting:type=Detector,transport=multicast"));
detector.start();
System.err.println("Starting MulticastDetector");
CascadingAgent agent = new CascadingAgent();
server.registerMBean(agent, new ObjectName("jmx.remoting:type=CascadingAgent"));
agent.start();
System.err.println("Starting CascadingAgent");
ObjectInstance html = server.createMBean("com.sun.jdmk.comm.HtmlAdaptorServer",
null);
server.invoke(html.getObjectName(), "setPort",
new Object[]{new Integer("8083")}, new String[]{"java.lang.Integer"});
server.invoke(html.getObjectName(), "start",
new Object[0], new String[0]);
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
}