1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
|
package org.jboss.test.remoting.callback.pull;
import org.jboss.jrunit.extensions.ServerTestCase;
import org.jboss.remoting.InvokerLocator;
import org.jboss.remoting.transport.Connector;
/**
* Simple remoting server. Uses inner class SampleInvocationHandler
* as the invocation target handler class.
*
* @author <a href="mailto:telrod@e2technologies.net">Tom Elrod</a>
*/
public class CallbackTestServer extends ServerTestCase
{
// Default locator values
private static String transport = "socket";
private static String host = "localhost";
private static int port = 5411;
private String locatorURI = transport + "://" + host + ":" + port;
private Connector connector;
// String to be returned from invocation handler upon client invocation calls.
private static final String RESPONSE_VALUE = "This is the return to SampleInvocationHandler invocation";
public void setupServer() throws Exception
{
InvokerLocator locator = new InvokerLocator(locatorURI);
System.out.println("Starting remoting server with locator uri of: " + locatorURI);
connector = new Connector();
connector.setInvokerLocator(locator.getLocatorURI());
connector.create();
CallbackInvocationHandler invocationHandler = new CallbackInvocationHandler();
// first parameter is sub-system name. can be any String value.
connector.addInvocationHandler("sample", invocationHandler);
connector.start();
}
public void setUp() throws Exception
{
setupServer();
}
public void tearDown() throws Exception
{
if(connector != null)
{
connector.stop();
connector.destroy();
}
}
public static void main(String[] args)
{
CallbackTestServer server = new CallbackTestServer();
try
{
server.setUp();
Thread.sleep(6000000);
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
|