本文整理汇总了Java中org.springframework.remoting.rmi.RmiProxyFactoryBean.setRefreshStubOnConnectFailure方法的典型用法代码示例。如果您正苦于以下问题:Java RmiProxyFactoryBean.setRefreshStubOnConnectFailure方法的具体用法?Java RmiProxyFactoryBean.setRefreshStubOnConnectFailure怎么用?Java RmiProxyFactoryBean.setRefreshStubOnConnectFailure使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.remoting.rmi.RmiProxyFactoryBean
的用法示例。
在下文中一共展示了RmiProxyFactoryBean.setRefreshStubOnConnectFailure方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: obtain
import org.springframework.remoting.rmi.RmiProxyFactoryBean; //导入方法依赖的package包/类
/**
* Utility method to lookup a remote stream peer over RMI.
*/
public static RemoteInputStreamServer obtain(String host, int port, String name) throws RemoteException
{
RmiProxyFactoryBean rmiProxyFactoryBean = new RmiProxyFactoryBean();
rmiProxyFactoryBean.setServiceUrl("rmi://" + host + ":" + port + "/" + name);
rmiProxyFactoryBean.setServiceInterface(RemoteInputStreamServer.class);
rmiProxyFactoryBean.setRefreshStubOnConnectFailure(true);
try
{
rmiProxyFactoryBean.afterPropertiesSet();
}
catch (Exception e)
{
throw new RemoteException("Error create rmi proxy");
}
return (RemoteInputStreamServer) rmiProxyFactoryBean.getObject();
}
示例2: doRefer
import org.springframework.remoting.rmi.RmiProxyFactoryBean; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
protected <T> T doRefer(final Class<T> serviceType, final URL url) throws RpcException {
final RmiProxyFactoryBean rmiProxyFactoryBean = new RmiProxyFactoryBean();
//RMI传输时使用自定义的远程执行对象,从而传递额外的参数
rmiProxyFactoryBean.setRemoteInvocationFactory(new RemoteInvocationFactory() {
public RemoteInvocation createRemoteInvocation(MethodInvocation methodInvocation) {
return new RmiRemoteInvocation(methodInvocation);
}
});
rmiProxyFactoryBean.setServiceUrl(url.toIdentityString());
rmiProxyFactoryBean.setServiceInterface(serviceType);
rmiProxyFactoryBean.setCacheStub(true);
rmiProxyFactoryBean.setLookupStubOnStartup(true);
rmiProxyFactoryBean.setRefreshStubOnConnectFailure(true);
rmiProxyFactoryBean.afterPropertiesSet();
return (T) rmiProxyFactoryBean.getObject();
}
示例3: doRefer
import org.springframework.remoting.rmi.RmiProxyFactoryBean; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
protected <T> T doRefer(final Class<T> serviceType, final URL url) throws RpcException {
final RmiProxyFactoryBean rmiProxyFactoryBean = new RmiProxyFactoryBean();
rmiProxyFactoryBean.setServiceUrl(url.toIdentityString());
rmiProxyFactoryBean.setServiceInterface(serviceType);
rmiProxyFactoryBean.setCacheStub(true);
rmiProxyFactoryBean.setLookupStubOnStartup(true);
rmiProxyFactoryBean.setRefreshStubOnConnectFailure(true);
rmiProxyFactoryBean.afterPropertiesSet();
return (T) rmiProxyFactoryBean.getObject();
}
示例4: importService
import org.springframework.remoting.rmi.RmiProxyFactoryBean; //导入方法依赖的package包/类
public static <T> T importService(Class<T> serviceInterface, int port, String serviceName, long timeout, TimeUnit timeunit) {
long timeoutMs = timeunit.toMillis(timeout);
String url = "rmi://localhost:" + port + "/" + serviceName;
log.debug("Creating RMI proxy for " + serviceInterface + " on " + url);
RmiProxyFactoryBean rmiFactory = new RmiProxyFactoryBean();
rmiFactory.setServiceInterface(serviceInterface);
rmiFactory.setServiceUrl(url);
rmiFactory.setRefreshStubOnConnectFailure(true);
rmiFactory.setLookupStubOnStartup(true);
boolean connected = false;
RuntimeException thrown = null;
long start = System.currentTimeMillis();
while (!connected && System.currentTimeMillis() - start < timeoutMs) {
try {
rmiFactory.afterPropertiesSet();
connected = true;
} catch (RuntimeException e) {
thrown = e;
try {
Thread.sleep(100);
} catch (InterruptedException e1) {
throw new RuntimeException("Interrupted while waiting for service to be available", e1);
}
}
}
if (!connected) {
throw thrown;
}
T serviceProxy = (T) rmiFactory.getObject();
return serviceProxy;
}