1 7 package org.jboss.remoting.callback.pull.memory.callbackstore; 8 9 import org.jboss.remoting.AbstractInvokerTest; 10 import org.jboss.remoting.CallbackStore; 11 import org.jboss.remoting.InvokerLocator; 12 import org.jboss.remoting.ServerInvokerCallbackHandler; 13 import org.jboss.remoting.callback.pull.memory.CallbackInvocationHandler; 14 import org.jboss.remoting.transport.Connector; 15 16 22 public class CallbackTestServer extends AbstractInvokerTest 23 { 24 private static String transport = "socket"; 26 private static String host = "localhost"; 27 private static int port = 5412; 28 29 private String locatorURI = null; 30 31 private static final String RESPONSE_VALUE = "This is the return to SampleInvocationHandler invocation"; 33 34 public CallbackTestServer(String name) 35 { 36 super(name); 37 } 38 39 public CallbackTestServer(String name, String locatorURI) 40 { 41 super(name); 42 this.locatorURI = locatorURI; 43 } 44 45 public CallbackTestServer(String name, int numberOfInstances) 46 { 47 super(name, numberOfInstances); 48 } 49 50 public CallbackTestServer(String name, String transport, int port) 51 { 52 super(name, transport, port); 53 } 54 55 public CallbackTestServer(String name, String transport, int port, int numberOfInstances) 56 { 57 super(name, transport, port, numberOfInstances); 58 } 59 60 61 public void setupServer() throws Exception 62 { 63 InvokerLocator locator = new InvokerLocator(locatorURI); 64 System.out.println("Starting remoting server with locator uri of: " + locatorURI); 65 Connector connector = new Connector(); 66 connector.setInvokerLocator(locator.getLocatorURI()); 67 connector.start(); 68 69 CallbackInvocationHandler invocationHandler = new CallbackInvocationHandler(); 70 connector.addInvocationHandler("sample", invocationHandler); 72 } 73 74 public void serverTest() throws Exception 75 { 76 try 77 { 78 setupServer(); 79 setShutdownTimeout(600000); startup(getNumberOfInstances()); 81 Thread.sleep(15000); 83 shutdown(); 84 } 85 catch(Exception e) 86 { 87 throw e; 88 } 89 } 90 91 97 public static void main(String [] args) 98 { 99 if(args != null && args.length == 2) 100 { 101 transport = args[0]; 102 port = Integer.parseInt(args[1]); 103 } 104 String locatorURI = transport + "://" + host + ":" + port + "/?" + ServerInvokerCallbackHandler.CALLBACK_STORE_KEY + 105 "=" + CallbackStore.class.getName(); 106 CallbackTestServer server = new CallbackTestServer(CallbackTestServer.class.getName(), locatorURI); 107 try 108 { 109 server.serverTest(); 110 Thread.sleep(15000); 112 } 113 catch(Exception e) 114 { 115 e.printStackTrace(); 116 System.exit(1); 117 } 118 System.exit(0); 119 } 120 121 } | Popular Tags |