1 7 package org.jboss.remoting.oneway; 8 9 import org.apache.log4j.Level; 10 import org.jboss.remoting.ServerInvocationHandler; 11 import org.jboss.remoting.ShutdownListener; 12 import org.jboss.remoting.performance.TestServerInvocationHandler; 13 import org.jboss.remoting.transport.socket.InvokerServerTest; 14 15 19 public class OnewayInvokerServer extends InvokerServerTest implements ShutdownListener 20 { 21 public boolean timeToShutdown = false; 22 23 private final Object waitObj = new Object (); 24 25 26 public OnewayInvokerServer(int instances) 27 { 28 super(instances); 29 } 30 31 public OnewayInvokerServer(String name) 32 { 33 super(name); 34 } 35 36 42 public void shutdown() throws Exception 43 { 44 synchronized(waitObj) 45 { 46 try 47 { 48 waitObj.wait(10 * 1000); } 50 catch(InterruptedException e) 51 { 52 System.out.println("Got interrupted exception."); 53 } 54 } 55 super.shutdown(); 56 } 57 58 public OnewayInvokerServer(String transport, int port) 59 { 60 super(transport, port); 61 } 62 63 public OnewayInvokerServer(String transport, int port, int instances) 64 { 65 super(transport, port, instances); 66 } 67 68 protected ServerInvocationHandler getServerInvocationHandler() 69 { 70 return new TestServerInvocationHandler(this); 71 } 72 73 protected String getSubsystem() 74 { 75 return "test"; 76 } 77 78 public static void main(String [] args) 79 { 80 org.apache.log4j.BasicConfigurator.configure(); 81 org.apache.log4j.Category.getRoot().setLevel(Level.INFO); 82 org.apache.log4j.Category.getInstance("org.jgroups").setLevel(Level.INFO); 83 org.apache.log4j.Category.getInstance("org.jboss.remoting").setLevel(Level.DEBUG); 84 org.apache.log4j.Category.getInstance("test").setLevel(Level.DEBUG); 85 86 OnewayInvokerServer server = null; 87 if(args.length == 1) 88 { 89 int instances = Integer.parseInt(args[0]); 90 server = new OnewayInvokerServer(instances); 91 } 92 else if(args.length == 2) 93 { 94 String transport = args[0]; 95 int port = Integer.parseInt(args[1]); 96 server = new OnewayInvokerServer(transport, port); 97 } 98 else if(args.length == 3) 99 { 100 String transport = args[0]; 101 int port = Integer.parseInt(args[1]); 102 int instances = Integer.parseInt(args[2]); 103 server = new OnewayInvokerServer(transport, port, instances); 104 } 105 else 106 { 107 server = new OnewayInvokerServer(InvokerServerTest.class.getName()); 108 System.out.println("Using default transport (" + server.getTransport() + 109 ") and default port (" + server.getPort() + ") and " + 110 "default number of instances (" + server.getNumberOfInstances() + ")" + 111 "\nCan enter transport, port, and instances via command line."); 112 } 113 114 try 115 { 116 server.serverTest(); 117 Thread.currentThread().sleep(5000); 118 } 119 catch(Exception e) 120 { 121 e.printStackTrace(); 122 System.exit(1); 123 } 124 System.exit(0); 125 } 126 127 public void shutdownTest() 128 throws Exception 129 { 130 synchronized(waitObj) 131 { 132 waitObj.notify(); 133 } 134 } 135 136 137 } 138 | Popular Tags |