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

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
package org.jboss.remoting.samples.transporter.multiple.server;

import org.jboss.remoting.samples.transporter.multiple.CustomerProcessorImpl;
import org.jboss.remoting.samples.transporter.multiple.AccountProcessorImpl;
import org.jboss.remoting.samples.transporter.multiple.CustomerProcessor;
import org.jboss.remoting.samples.transporter.multiple.AccountProcessor;
import org.jboss.remoting.transporter.TransporterServer;


/**
 * @author <a href="mailto:tom.elrod@jboss.com">Tom Elrod</a>
 */
public class Server
{
   private String locatorURI = "socket://localhost:5400";
   private TransporterServer server = null;

   public void start() throws Exception
   {
      server = TransporterServer.createTransporterServer(locatorURI, new CustomerProcessorImpl(), CustomerProcessor.class.getName());
      server.addHandler(new AccountProcessorImpl(), AccountProcessor.class.getName());
   }

   public void stop()
   {
      if(server != null)
      {
         server.stop();
      }
   }

   public static void main(String[] args)
   {
      Server server = new Server();
      try
      {
         server.start();

         Thread.currentThread().sleep(60000);

      }
      catch(Exception e)
      {
         e.printStackTrace();
      }
      finally
      {
         server.stop();
      }
   }
}