1 7 package org.jboss.remoting.marshall.dynamic.remote.http; 8 9 import org.apache.log4j.Level; 10 import org.jboss.remoting.AbstractInvokerTest; 11 import org.jboss.remoting.InvocationRequest; 12 import org.jboss.remoting.InvokerCallbackHandler; 13 import org.jboss.remoting.InvokerLocator; 14 import org.jboss.remoting.ServerInvocationHandler; 15 import org.jboss.remoting.ServerInvoker; 16 import org.jboss.remoting.marshall.dynamic.remote.socket.MarshallerLoadingConstants; 17 import org.jboss.remoting.marshall.dynamic.remote.socket.TestMarshaller; 18 import org.jboss.remoting.marshall.dynamic.remote.socket.TestUnMarshaller; 19 import org.jboss.remoting.transport.Connector; 20 21 import javax.management.MBeanServer ; 22 23 29 public class MarshallerLoadingServer extends AbstractInvokerTest implements org.jboss.remoting.marshall.dynamic.remote.socket.MarshallerLoadingConstants 30 { 31 32 private static final String RESPONSE_VALUE = "This is the return to SampleInvocationHandler invocation"; 34 35 public MarshallerLoadingServer(String name) 36 { 37 super(name); 38 } 39 40 public MarshallerLoadingServer(String name, int numberOfInstances) 41 { 42 super(name, numberOfInstances); 43 } 44 45 public MarshallerLoadingServer(String name, String transport, int port) 46 { 47 super(name, transport, port); 48 } 49 50 public MarshallerLoadingServer(String name, String transport, int port, int numberOfInstances) 51 { 52 super(name, transport, port, numberOfInstances); 53 } 54 55 56 public void setupServer() throws Exception 57 { 58 String mylocatorURI = MarshallerLoadingConstants.transport + "://" + host + ":" + org.jboss.remoting.marshall.dynamic.remote.socket.MarshallerLoadingConstants.port + "/?" + 59 InvokerLocator.DATATYPE + "=" + dataType + "&" + 60 InvokerLocator.LOADER_PORT + "=" + 5401 + "&" + 61 InvokerLocator.MARSHALLER + "=" + TestMarshaller.class.getName() + "&" + 62 InvokerLocator.UNMARSHALLER + "=" + TestUnMarshaller.class.getName(); 63 64 System.out.println("mylocatorURI: " + mylocatorURI); 65 System.out.println("locatorURI: " + locatorURI); 66 InvokerLocator locator = new InvokerLocator(mylocatorURI); 68 System.out.println("Starting remoting server with locator uri of: " + locatorURI); 69 Connector connector = new Connector(); 70 connector.setInvokerLocator(locator.getLocatorURI()); 71 connector.start(); 72 73 SampleInvocationHandler invocationHandler = new SampleInvocationHandler(); 74 connector.addInvocationHandler("sample", invocationHandler); 76 } 77 78 public void serverTest() throws Exception 79 { 80 setupServer(); 81 startup(getNumberOfInstances()); 82 shutdown(); 83 } 84 85 91 public static void main(String [] args) 92 { 93 org.apache.log4j.BasicConfigurator.configure(); 94 org.apache.log4j.Category.getRoot().setLevel(Level.INFO); 95 org.apache.log4j.Category.getInstance("org.jboss.remoting").setLevel(Level.DEBUG); 96 98 105 MarshallerLoadingServer server = new MarshallerLoadingServer(MarshallerLoadingServer.class.getName()); 106 try 107 { 108 server.serverTest(); 109 110 Thread.sleep(10000); 112 } 113 catch(Exception e) 114 { 115 e.printStackTrace(); 116 System.exit(1); 117 } 118 System.exit(0); 119 } 120 121 124 public static class SampleInvocationHandler implements ServerInvocationHandler 125 { 126 133 public Object invoke(InvocationRequest invocation) throws Throwable 134 { 135 System.out.println("Invocation request is: " + invocation.getParameter()); 137 138 return RESPONSE_VALUE; 140 } 141 142 148 public void addListener(InvokerCallbackHandler callbackHandler) 149 { 150 } 152 153 159 public void removeListener(InvokerCallbackHandler callbackHandler) 160 { 161 } 163 164 169 public void setMBeanServer(MBeanServer server) 170 { 171 } 173 174 179 public void setInvoker(ServerInvoker invoker) 180 { 181 } 183 184 } 185 } | Popular Tags |