Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package org.jboss.remoting.samples.transporter.custom.server;
  
  
 import java.util.Map;

Author(s):
Tom Elrod
 
 public class SocketServer
 {
    public static String locatorURI = "socket://localhost:5400";
    private TransporterServer server = null;
 
    public void start() throws Exception
    {
       initTransporterServices();
 
       Map config = getConnectorConfig();
 
        = TransporterServer.createTransporterServer(getLocatorURI(), new CustomerProcessorImpl(),
                                                          CustomerProcessor.class.getName(), configtrue);
    }
 
    private Map getConnectorConfig()
    {
       Map config = new HashMap();
       // setting socket timeout to 5 seconds
       config.put("timeout""5000");
       return config;
    }
 
    protected String getLocatorURI()
    {
       return .;
    }
 
    public void stop()
    {
       if ( != null)
       {
          .stop();
       }
    }
 
    private void initTransporterServices() throws Exception
    {
       // create MBeanServer
       MBeanServer mbeanServer = MBeanServerFactory.createMBeanServer();
 
       NetworkRegistry registry = NetworkRegistry.getInstance();
 
       String host = InetAddress.getLocalHost().getHostAddress();
       JNDIDetector jndiDetector = new JNDIDetector();
       jndiDetector.setPort(.);
       jndiDetector.setHost(host);
       jndiDetector.setContextFactory("org.jnp.interfaces.NamingContextFactory");
       jndiDetector.setURLPackage("org.jboss.naming:org.jnp.interfaces");
 
 
       InternalTransporterServices transporterService = InternalTransporterServices.getInstance();
 
       transporterService.setup(mbeanServer,
                                jndiDetectornew ObjectName("remoting:type=Detector,transport=jndi"),
                                registrynew ObjectName("remoting:type=NetworkRegistry"),
                                truetrue);
 
       //TODO: -TME Have to start the detector after setup() call?
       jndiDetector.start();
 
    }
 
    public static void main(String[] args)
    {
       SocketServer server = new SocketServer();
       try
       {
          server.start();
 
          Thread.currentThread().sleep(60000);
 
       }
       catch (Exception e)
       {
          e.printStackTrace();
       }
       finally
       {
          server.stop();
      }
   }
New to GrepCode? Check out our FAQ X