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