~ubuntu-branches/ubuntu/raring/libjboss-remoting-java/raring

« back to all changes in this revision

Viewing changes to tests/org/jboss/test/remoting/callback/push/bidirectional/multiplex/MultiplexCallbackTestServer.java

  • Committer: Package Import Robot
  • Author(s): Torsten Werner
  • Date: 2011-09-09 14:01:03 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: package-import@ubuntu.com-20110909140103-hqokx61534tas9rg
Tags: 2.5.3.SP1-1
* Newer but not newest upstream release. Do not build samples.
* Change debian/watch to upstream's svn repo.
* Add patch to fix compile error caused by tomcat update.
  (Closes: #628303)
* Switch to source format 3.0.
* Switch to debhelper level 7.
* Remove useless Depends.
* Update Standards-Version: 3.9.2.
* Update README.source.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
package org.jboss.test.remoting.callback.push.bidirectional.multiplex;
2
 
 
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;
10
 
 
11
 
import javax.management.MBeanServer;
12
 
import java.util.ArrayList;
13
 
import java.util.List;
14
 
 
15
 
/**
16
 
 * @author <a href="mailto:tom.elrod@jboss.com">Tom Elrod</a>
17
 
 */
18
 
public class MultiplexCallbackTestServer extends ServerTestCase
19
 
{
20
 
   private String locatorUri = "multiplex://localhost:8999";
21
 
   private Connector connector = null;
22
 
 
23
 
   public void setUp() throws Exception
24
 
   {
25
 
      connector = new Connector(locatorUri);
26
 
      connector.create();
27
 
      connector.addInvocationHandler("test", new MultiplexCallbackTestServer.TestInvocationHandler());
28
 
      connector.start();
29
 
   }
30
 
 
31
 
   public void tearDown() throws Exception
32
 
   {
33
 
      if (connector != null)
34
 
      {
35
 
         connector.stop();
36
 
         connector.destroy();
37
 
      }
38
 
   }
39
 
 
40
 
   public static void main(String[] args)
41
 
   {
42
 
      MultiplexCallbackTestServer server = new MultiplexCallbackTestServer();
43
 
      try
44
 
      {
45
 
         server.setUp();
46
 
 
47
 
         Thread.sleep(600000);
48
 
      }
49
 
      catch (Exception e)
50
 
      {
51
 
         e.printStackTrace();
52
 
      }
53
 
   }
54
 
 
55
 
   public class TestInvocationHandler implements ServerInvocationHandler
56
 
   {
57
 
 
58
 
      private List listeners = new ArrayList();
59
 
 
60
 
      public void setMBeanServer(MBeanServer server)
61
 
      {
62
 
         //TODO: -TME Implement
63
 
      }
64
 
 
65
 
      public void setInvoker(ServerInvoker invoker)
66
 
      {
67
 
         //TODO: -TME Implement
68
 
      }
69
 
 
70
 
      public Object invoke(InvocationRequest invocation) throws Throwable
71
 
      {
72
 
         for (int x = 0; x < listeners.size(); x++)
73
 
         {
74
 
            InvokerCallbackHandler callbackHandler = (InvokerCallbackHandler) listeners.get(x);
75
 
            callbackHandler.handleCallback(new Callback("This is callback payload"));
76
 
         }
77
 
         return "barfoo";
78
 
      }
79
 
 
80
 
      public void addListener(InvokerCallbackHandler callbackHandler)
81
 
      {
82
 
         listeners.add(callbackHandler);
83
 
      }
84
 
 
85
 
      public void removeListener(InvokerCallbackHandler callbackHandler)
86
 
      {
87
 
         listeners.remove(callbackHandler);
88
 
      }
89
 
   }
90
 
 
91
 
}