Example usage for org.springframework.remoting.rmi RmiProxyFactoryBean setLookupStubOnStartup

List of usage examples for org.springframework.remoting.rmi RmiProxyFactoryBean setLookupStubOnStartup

Introduction

In this page you can find the example usage for org.springframework.remoting.rmi RmiProxyFactoryBean setLookupStubOnStartup.

Prototype

public void setLookupStubOnStartup(boolean lookupStubOnStartup) 

Source Link

Document

Set whether to look up the RMI stub on startup.

Usage

From source file:com.mysoft.b2b.event.scheduler.protocol.rmi.RMIClientHelper.java

public static ProtocolService getRMIProtocolService(String protocolUrl) {
    String serviceUrl = "";
    if (protocolUrl != null && protocolUrl.endsWith("/")) {
        serviceUrl = protocolUrl;/*from  w  w w  . jav  a  2  s .  c o m*/
    } else {
        serviceUrl = protocolUrl + "/";
    }
    serviceUrl = serviceUrl + ProtocolService.class.getSimpleName();
    RmiProxyFactoryBean rpfb = new RmiProxyFactoryBean();
    rpfb.setServiceUrl(serviceUrl);
    rpfb.setServiceInterface(ProtocolService.class);
    try {
        rpfb.setLookupStubOnStartup(false);
        rpfb.setRefreshStubOnConnectFailure(true);
        rpfb.afterPropertiesSet();
    } catch (Exception e) {
        logger.info("Can't get the remote RMI server: " + serviceUrl + ", because " + e.getMessage());
        return null;
    }
    logger.info("Success to init RMI local proxy service for " + serviceUrl);
    return (ProtocolService) rpfb.getObject();
}