1
package org.jboss.test.remoting.callback.push.bidirectional.multiplex;
3
import org.jboss.jrunit.extensions.ServerTestCase;
4
import org.jboss.remoting.InvocationRequest;
5
import org.jboss.remoting.ServerInvocationHandler;
6
import org.jboss.remoting.ServerInvoker;
7
import org.jboss.remoting.callback.Callback;
8
import org.jboss.remoting.callback.InvokerCallbackHandler;
9
import org.jboss.remoting.transport.Connector;
11
import javax.management.MBeanServer;
12
import java.util.ArrayList;
13
import java.util.List;
16
* @author <a href="mailto:tom.elrod@jboss.com">Tom Elrod</a>
18
public class MultiplexCallbackTestServer extends ServerTestCase
20
private String locatorUri = "multiplex://localhost:8999";
21
private Connector connector = null;
23
public void setUp() throws Exception
25
connector = new Connector(locatorUri);
27
connector.addInvocationHandler("test", new MultiplexCallbackTestServer.TestInvocationHandler());
31
public void tearDown() throws Exception
33
if (connector != null)
40
public static void main(String[] args)
42
MultiplexCallbackTestServer server = new MultiplexCallbackTestServer();
55
public class TestInvocationHandler implements ServerInvocationHandler
58
private List listeners = new ArrayList();
60
public void setMBeanServer(MBeanServer server)
62
//TODO: -TME Implement
65
public void setInvoker(ServerInvoker invoker)
67
//TODO: -TME Implement
70
public Object invoke(InvocationRequest invocation) throws Throwable
72
for (int x = 0; x < listeners.size(); x++)
74
InvokerCallbackHandler callbackHandler = (InvokerCallbackHandler) listeners.get(x);
75
callbackHandler.handleCallback(new Callback("This is callback payload"));
80
public void addListener(InvokerCallbackHandler callbackHandler)
82
listeners.add(callbackHandler);
85
public void removeListener(InvokerCallbackHandler callbackHandler)
87
listeners.remove(callbackHandler);