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

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

Introduction

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

Prototype

public void setRefreshStubOnConnectFailure(boolean refreshStubOnConnectFailure) 

Source Link

Document

Set whether to refresh the RMI stub on connect failure.

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;//  w  ww . j  a  v  a  2  s.co  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();
}