try
{
org.apache.log4j.BasicConfigurator.configure();
org.apache.log4j.Category.getRoot().setLevel(Level.DEBUG);
Logger log = Logger.getLogger(getClass());
System.setProperty("jboss.identity", String.valueOf(System.currentTimeMillis()));
MBeanServer server = MBeanServerFactory.createMBeanServer();
NetworkRegistry registry = NetworkRegistry.getInstance();
server.registerMBean(registry, new ObjectName("remoting:type=NetworkRegistry"));
InvokerLocator locator = new InvokerLocator("socket://localhost");
//ClassLoader clsLoader = Thread.currentThread().getContextClassLoader();
//SocketServerInvoker invokerSvr = new SocketServerInvoker(clsLoader, locator);
//ObjectName objName = new ObjectName("jboss.remoting:type=SocketServerInvoker");
//server.registerMBean(invokerSvr, objName);
//invokerSvr.start();
Connector connector = new Connector();
connector.setInvokerLocator(locator.getLocatorURI());
ObjectName obj = new ObjectName("jboss.remoting:type=Connector,transport=" + locator.getProtocol());
server.registerMBean(connector, obj);
//connector.create();
connector.start();
Detector detector = null;
ObjectName objName = null;
if(type.equals(TYPE_MULTICAST))
{
MulticastDetector mdet = new MulticastDetector();
mdet.setPort(port);
detector = mdet;
objName = new ObjectName("remoting:type=Detector,transport=multicast");
}
else if(type.equals(TYPE_JNDI))
{
JNDIDetector jdet = new JNDIDetector();
jdet.setPort(port);
jdet.setHost(host);
jdet.setContextFactory(contextFactory);
jdet.setURLPackage(urlPackage);
detector = jdet;
objName = new ObjectName("remoting:type=Detector,transport=jndi");
}
server.registerMBean(detector, objName);
detector.start();
System.err.println("Starting Detector");
while(true)
{
Thread.currentThread().sleep(3000);
NetworkInstance[] instances = registry.getServers();
for(int x = 0; x < instances.length; x++)
{
log.debug(instances[x]);
}
}
}