1
package org.jboss.test.remoting.transport.http.timeout;
3
import javax.management.MBeanServer;
4
import org.jboss.jrunit.extensions.ServerTestCase;
5
import org.jboss.remoting.transport.Connector;
6
import org.jboss.remoting.InvokerLocator;
7
import org.jboss.remoting.ServerInvocationHandler;
8
import org.jboss.remoting.ServerInvoker;
9
import org.jboss.remoting.InvocationRequest;
10
import org.jboss.remoting.callback.InvokerCallbackHandler;
13
* @author <a href="mailto:tom.elrod@jboss.com">Tom Elrod</a>
15
public class TimeoutServerTest extends ServerTestCase
17
private String locatorURI = "http://localhost:8899/?timeout=3000";
18
private Connector connector = null;
20
public void setUp() throws Exception
22
connector = new Connector();
23
InvokerLocator locator = new InvokerLocator(locatorURI);
24
connector.setInvokerLocator(locator.getLocatorURI());
26
connector.addInvocationHandler("test", new org.jboss.test.remoting.transport.http.timeout.TimeoutServerTest.TimeoutHandler());
30
protected void tearDown() throws Exception
39
public static void main(String[] args)
41
org.jboss.test.remoting.transport.http.timeout.TimeoutServerTest server = new org.jboss.test.remoting.transport.http.timeout.TimeoutServerTest();
46
Thread.currentThread().sleep(30000);
54
private class TimeoutHandler implements ServerInvocationHandler
58
* set the mbean server that the handler can reference
62
public void setMBeanServer(MBeanServer server)
64
//TODO: -TME Implement
68
* set the invoker that owns this handler
72
public void setInvoker(ServerInvoker invoker)
74
//TODO: -TME Implement
78
* called to handle a specific invocation. Please take care to make sure
79
* implementations are thread safe and can, and often will, receive concurrent
80
* calls on this method.
86
public Object invoke(InvocationRequest invocation) throws Throwable
88
Object obj = invocation.getParameter();
89
if(obj instanceof String && "timeout".equals(obj))
91
System.out.println("server got 'timeout' invocation... sleeping 30 seconds.");
92
Thread.currentThread().sleep(30000);
94
return null; //TODO: -TME Implement
98
* Adds a callback handler that will listen for callbacks from
99
* the server invoker handler.
101
* @param callbackHandler
103
public void addListener(InvokerCallbackHandler callbackHandler)
105
//TODO: -TME Implement
109
* Removes the callback handler that was listening for callbacks
110
* from the server invoker handler.
112
* @param callbackHandler
114
public void removeListener(InvokerCallbackHandler callbackHandler)
116
//TODO: -TME Implement