1 7 package org.jboss.test.remoting.interceptor; 8 9 import javax.management.MBeanServer ; 10 import javax.management.MBeanServerFactory ; 11 import javax.management.ObjectName ; 12 import org.apache.log4j.Level; 13 import org.jboss.remoting.InvokerLocator; 14 import org.jboss.remoting.ident.Identity; 15 import org.jboss.remoting.marshal.serializable.SerializableUnMarshaller; 16 import org.jboss.remoting.network.NetworkRegistry; 17 import org.jboss.remoting.transport.Connector; 18 19 22 public class ServerInterceptorTest 23 { 24 private InvokerLocator locator; 25 26 public void setLocator(InvokerLocator locator) 27 { 28 this.locator = locator; 29 } 30 31 protected void setup() 32 { 33 try 34 { 35 System.setProperty("jboss.identity", Identity.createUniqueID()); 36 MBeanServer server = MBeanServerFactory.createMBeanServer(); 37 38 System.out.println("my identity is: " + Identity.get(server)); 39 40 41 NetworkRegistry registry = NetworkRegistry.getInstance(); 42 server.registerMBean(registry, new ObjectName ("remoting:type=NetworkRegistry")); 43 44 46 Connector connector = new Connector(); 47 connector.setInvokerLocator(locator.getLocatorURI()); 48 ObjectName obj = new ObjectName ("jboss.remoting:type=Connector,transport=" + locator.getProtocol()); 49 server.registerMBean(connector, obj); 50 51 connector.start(); 52 53 connector.addInvocationHandler("test", new TestInvocationHandler()); 54 55 59 65 } 66 catch(Throwable e) 67 { 68 e.printStackTrace(); 69 } 70 71 } 72 73 public static void main(String [] args) 74 { 75 try 76 { 77 79 int port = 8081; 80 String transport = "socket"; 81 InvokerLocator locator = new InvokerLocator(transport + "://localhost:" + port + "/?" + 84 InvokerLocator.DATATYPE + "=" + SerializableUnMarshaller.DATATYPE); 85 86 ServerInterceptorTest server = new ServerInterceptorTest(); 87 server.setLocator(locator); 88 server.setup(); 89 90 while(true) 91 { 92 Thread.sleep(1000); 93 } 94 } 95 catch(Exception e) 96 { 97 e.printStackTrace(); 98 } 99 } 100 101 112 public void run() 113 { 114 setup(); 115 } 116 } | Popular Tags |