1 7 package org.jboss.remoting.samples.oneway; 8 9 import javax.management.MBeanServer ; 10 import org.jboss.remoting.InvocationRequest; 11 import org.jboss.remoting.InvokerLocator; 12 import org.jboss.remoting.ServerInvocationHandler; 13 import org.jboss.remoting.ServerInvoker; 14 import org.jboss.remoting.callback.InvokerCallbackHandler; 15 import org.jboss.remoting.transport.Connector; 16 17 23 public class OnewayServer 24 { 25 private static String transport = "socket"; 27 private static String host = "localhost"; 28 private static int port = 5400; 29 30 public void setupServer(String locatorURI) throws Exception 31 { 32 InvokerLocator locator = new InvokerLocator(locatorURI); 36 System.out.println("Starting remoting server with locator uri of: " + locatorURI); 37 Connector connector = new Connector(); 38 connector.setInvokerLocator(locator.getLocatorURI()); 39 connector.create(); 41 42 SampleInvocationHandler invocationHandler = new SampleInvocationHandler(); 44 connector.addInvocationHandler("sample", invocationHandler); 46 47 connector.start(); 48 } 49 50 56 public static void main(String [] args) 57 { 58 if(args != null && args.length == 2) 59 { 60 transport = args[0]; 61 port = Integer.parseInt(args[1]); 62 } 63 String locatorURI = transport + "://" + host + ":" + port; 64 OnewayServer server = new OnewayServer(); 65 try 66 { 67 server.setupServer(locatorURI); 68 69 while(true) 71 { 72 Thread.sleep(1000); 73 } 74 75 } 76 catch(Exception e) 77 { 78 e.printStackTrace(); 79 } 80 } 81 82 86 public static class SampleInvocationHandler implements ServerInvocationHandler 87 { 88 95 public Object invoke(InvocationRequest invocation) throws Throwable 96 { 97 System.out.println("Invocation request is: " + invocation.getParameter()); 99 return null; 100 } 101 102 108 public void addListener(InvokerCallbackHandler callbackHandler) 109 { 110 } 112 113 119 public void removeListener(InvokerCallbackHandler callbackHandler) 120 { 121 } 123 124 129 public void setMBeanServer(MBeanServer server) 130 { 131 } 133 134 139 public void setInvoker(ServerInvoker invoker) 140 { 141 } 143 144 } 145 } | Popular Tags |