Example usage for org.springframework.remoting.rmi RmiServiceExporter setServicePort

List of usage examples for org.springframework.remoting.rmi RmiServiceExporter setServicePort

Introduction

In this page you can find the example usage for org.springframework.remoting.rmi RmiServiceExporter setServicePort.

Prototype

public void setServicePort(int servicePort) 

Source Link

Document

Set the port that the exported RMI service will use.

Usage

From source file:org.grouter.core.RouterServerImpl.java

/**
 * If there is a rmi port configured then we register the router in jndi.
 * <p/>/*ww w  .j a v  a 2  s .co  m*/
 * Lookup up bean in  context and use our config files parameters to set
 * port etc and finally call prepare to fire things up.
 */
private void initRmi() {
    logger.info("Check if we are to register as RMI service");
    if (router.getRmiRegistryPort() > 0 || router.getRmiServicePort() > 0) {
        try {
            logger.info("Trying to register in router as RMI service jndi");
            logger.info("Rmiregistryport :" + router.getRmiRegistryPort());
            logger.info("Rmiserviceport :" + router.getRmiServicePort());
            logger.debug("Get rmi exporter bean from context :" + RMI_SERVICE_EXPORTER_FACTORY_BEAN);
            RmiServiceExporter rmiServiceExporter = (RmiServiceExporter) context
                    .getBean(RMI_SERVICE_EXPORTER_FACTORY_BEAN);
            rmiServiceExporter.setRegistryPort(router.getRmiRegistryPort());
            rmiServiceExporter.setServicePort(router.getRmiServicePort());
            logger.debug("Calling prepare on rmi exporter");
            rmiServiceExporter.prepare();
            logger.info("Registered ok as RMI service jndi");
        } catch (RemoteException e) {
            logger.error("Failed to register router as RMI service in JNDI", e);
        }
    } else {
        logger.info("Router was no tconfigured to use RMI - rmi ports missing in config file");

    }

}