KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > remoting > callback > pull > memory > nullstore > CallbackTestServer


1 /*
2  * JBoss, the OpenSource J2EE webOS
3  *
4  * Distributable under LGPL license.
5  * See terms of license at gnu.org.
6  */

7 package org.jboss.test.remoting.callback.pull.memory.nullstore;
8
9 import org.jboss.jrunit.extensions.ServerTestCase;
10 import org.jboss.remoting.InvokerLocator;
11 import org.jboss.remoting.transport.Connector;
12 import org.jboss.test.remoting.callback.pull.memory.CallbackInvocationHandler;
13
14 /**
15  * Simple remoting server. Uses inner class SampleInvocationHandler
16  * as the invocation target handler class.
17  *
18  * @author <a HREF="mailto:telrod@e2technologies.net">Tom Elrod</a>
19  */

20 public class CallbackTestServer extends ServerTestCase
21 {
22    // Default locator values
23
private static String JavaDoc transport = "socket";
24    private static String JavaDoc host = "localhost";
25    private static int port = 5411;
26
27    private String JavaDoc locatorURI = transport + "://" + host + ":" + port;
28
29    private Connector connector;
30
31    // String to be returned from invocation handler upon client invocation calls.
32
private static final String JavaDoc RESPONSE_VALUE = "This is the return to SampleInvocationHandler invocation";
33
34
35    public void setupServer() throws Exception JavaDoc
36    {
37       InvokerLocator locator = new InvokerLocator(locatorURI);
38       System.out.println("Starting remoting server with locator uri of: " + locatorURI);
39       connector = new Connector();
40       connector.setInvokerLocator(locator.getLocatorURI());
41       connector.start();
42
43       CallbackInvocationHandler invocationHandler = new CallbackInvocationHandler();
44       // first parameter is sub-system name. can be any String value.
45
connector.addInvocationHandler("sample", invocationHandler);
46    }
47
48    public void setUp() throws Exception JavaDoc
49    {
50       setupServer();
51    }
52
53    public void tearDown() throws Exception JavaDoc
54    {
55       if(connector != null)
56       {
57          connector.stop();
58          connector.destroy();
59       }
60    }
61
62 }
Popular Tags