Example usage for java.rmi.registry Registry REGISTRY_PORT

List of usage examples for java.rmi.registry Registry REGISTRY_PORT

Introduction

In this page you can find the example usage for java.rmi.registry Registry REGISTRY_PORT.

Prototype

int REGISTRY_PORT

To view the source code for java.rmi.registry Registry REGISTRY_PORT.

Click Source Link

Document

Well known port for registry.

Usage

From source file:org.speechforge.cairo.server.resource.ResourceServerImpl.java

/**
 * TODOC/*  w  ww . j  a v a 2s.com*/
 * 
 * @param args
 * @throws Exception
 */
public static void main(String[] args) throws Exception {
    CommandLineParser parser = new GnuParser();
    Options options = getOptions();
    CommandLine line = parser.parse(options, args, true);
    args = line.getArgs();

    /*if (args.length < 3 || args.length > 5 || line.hasOption(ResourceImpl.HELP_OPTION)) {
    HelpFormatter formatter = new HelpFormatter();
    formatter.printHelp("ResourceServerImpl [options] ", options);
    return;
    }*/

    int sipPort = 0;
    String sipTransport = null;
    String publicAddress = null;
    if (line.hasOption(SIPPORT_OPTION)) {
        String tmp = line.getOptionValue(SIPPORT_OPTION);
        sipPort = Integer.valueOf(tmp);
    }

    if (line.hasOption(SIPTRANSPORT_OPTION)) {
        sipTransport = line.getOptionValue(SIPTRANSPORT_OPTION);
    }

    if (line.hasOption(SIPPUBLICADDRESS_OPTION)) {
        publicAddress = line.getOptionValue(SIPPUBLICADDRESS_OPTION);
    }

    String hostName = null;
    if (line.hasOption(LOCALADDRESS_OPTION)) {
        hostName = line.getOptionValue(LOCALADDRESS_OPTION);
    }

    _logger.debug("Command line specified sip port: " + sipPort + " and sip transport: " + sipTransport);

    ResourceRegistryImpl rr = new ResourceRegistryImpl();
    ResourceServerImpl rs = new ResourceServerImpl(rr, sipPort, sipTransport, hostName, publicAddress);

    Registry registry = LocateRegistry.createRegistry(Registry.REGISTRY_PORT);
    registry.rebind(ResourceRegistry.NAME, rr);
    // registry.rebind(ResourceServer.NAME, rs);

    _logger.info("Server and registry bound and waiting...");

}