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