1 7 package org.jboss.test.remoting.marshall.dynamic.remote.http; 8 9 import javax.management.MBeanServer ; 10 import org.jboss.jrunit.extensions.ServerTestCase; 11 import org.jboss.remoting.InvocationRequest; 12 import org.jboss.remoting.InvokerLocator; 13 import org.jboss.remoting.ServerInvocationHandler; 14 import org.jboss.remoting.ServerInvoker; 15 import org.jboss.remoting.callback.InvokerCallbackHandler; 16 import org.jboss.remoting.transport.Connector; 17 18 24 public class MarshallerLoadingServer extends ServerTestCase implements MarshallerLoadingConstants 25 { 26 private Connector connector; 27 28 private static final String RESPONSE_VALUE = "This is the return to SampleInvocationHandler invocation"; 30 31 public void setupServer() throws Exception 32 { 33 System.out.println("locatorURI: " + locatorURI); 34 InvokerLocator locator = new InvokerLocator(locatorURI); 35 System.out.println("Starting remoting server with locator uri of: " + locatorURI); 36 connector = new Connector(); 37 connector.setInvokerLocator(locator.getLocatorURI()); 38 connector.start(); 39 40 SampleInvocationHandler invocationHandler = new SampleInvocationHandler(); 41 connector.addInvocationHandler("sample", invocationHandler); 43 } 44 45 public void setUp() throws Exception 46 { 47 setupServer(); 48 } 49 50 public void tearDown() throws Exception 51 { 52 if(connector != null) 53 { 54 connector.stop(); 55 connector.destroy(); 56 } 57 } 58 59 public static void main(String [] args) 60 { 61 MarshallerLoadingServer server = new MarshallerLoadingServer(); 62 try 63 { 64 server.setUp(); 65 } 66 catch(Exception e) 67 { 68 e.printStackTrace(); 69 } 70 } 71 72 73 76 public static class SampleInvocationHandler implements ServerInvocationHandler 77 { 78 85 public Object invoke(InvocationRequest invocation) throws Throwable 86 { 87 System.out.println("Invocation request is: " + invocation.getParameter()); 89 90 return RESPONSE_VALUE; 92 } 93 94 100 public void addListener(InvokerCallbackHandler callbackHandler) 101 { 102 } 104 105 111 public void removeListener(InvokerCallbackHandler callbackHandler) 112 { 113 } 115 116 121 public void setMBeanServer(MBeanServer server) 122 { 123 } 125 126 131 public void setInvoker(ServerInvoker invoker) 132 { 133 } 135 136 } 137 } | Popular Tags |