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

« back to all changes in this revision

Viewing changes to src/main/org/jboss/remoting/samples/transporter/custom/server/RMIServer.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.remoting.samples.transporter.custom.server;
 
2
 
 
3
import org.jboss.remoting.detection.jndi.JNDIDetector;
 
4
import org.jboss.remoting.network.NetworkRegistry;
 
5
import org.jboss.remoting.samples.transporter.basic.CustomerProcessor;
 
6
import org.jboss.remoting.samples.transporter.basic.CustomerProcessorImpl;
 
7
import org.jboss.remoting.transporter.InternalTransporterServices;
 
8
import org.jboss.remoting.transporter.TransporterServer;
 
9
 
 
10
import javax.management.MBeanServer;
 
11
import javax.management.MBeanServerFactory;
 
12
import javax.management.ObjectName;
 
13
import java.net.InetAddress;
 
14
 
 
15
 
 
16
/**
 
17
 * @author <a href="mailto:tom.elrod@jboss.com">Tom Elrod</a>
 
18
 */
 
19
public class RMIServer
 
20
{
 
21
   private String localLocatorURI = "rmi://localhost:5500";
 
22
 
 
23
   private TransporterServer server = null;
 
24
 
 
25
   public void start() throws Exception
 
26
   {
 
27
      initTransporterServices();
 
28
 
 
29
      server = TransporterServer.createTransporterServer(localLocatorURI, new CustomerProcessorImpl(),
 
30
                                                         CustomerProcessor.class.getName(), true);
 
31
   }
 
32
 
 
33
   public void stop()
 
34
   {
 
35
      if (server != null)
 
36
      {
 
37
         server.stop();
 
38
      }
 
39
   }
 
40
 
 
41
   private void initTransporterServices() throws Exception
 
42
   {
 
43
      // create MBeanServer
 
44
      MBeanServer mbeanServer = MBeanServerFactory.createMBeanServer();
 
45
 
 
46
      NetworkRegistry registry = NetworkRegistry.getInstance();
 
47
 
 
48
      String host = InetAddress.getLocalHost().getHostAddress();
 
49
      JNDIDetector jndiDetector = new JNDIDetector();
 
50
      jndiDetector.setPort(JNDIServer.JNDI_PORT);
 
51
      jndiDetector.setHost(host);
 
52
      jndiDetector.setContextFactory("org.jnp.interfaces.NamingContextFactory");
 
53
      jndiDetector.setURLPackage("org.jboss.naming:org.jnp.interfaces");
 
54
 
 
55
 
 
56
      InternalTransporterServices transporterService = InternalTransporterServices.getInstance();
 
57
 
 
58
      transporterService.setup(mbeanServer,
 
59
                               jndiDetector, new ObjectName("remoting:type=Detector,transport=jndi"),
 
60
                               registry, new ObjectName("remoting:type=NetworkRegistry"),
 
61
                               true, true);
 
62
 
 
63
      //TODO: -TME Have to start the detector after setup() call?
 
64
      jndiDetector.start();
 
65
 
 
66
   }
 
67
 
 
68
   public static void main(String[] args)
 
69
   {
 
70
      RMIServer server = new RMIServer();
 
71
      try
 
72
      {
 
73
         server.start();
 
74
 
 
75
         Thread.currentThread().sleep(60000);
 
76
 
 
77
      }
 
78
      catch (Exception e)
 
79
      {
 
80
         e.printStackTrace();
 
81
      }
 
82
      finally
 
83
      {
 
84
         server.stop();
 
85
      }
 
86
   }
 
87
}