use of org.springframework.remoting.rmi.RmiProxyFactoryBean in project otter by alibaba.
the class RmiCommunicationConnectionFactory method createConnection.
@Override
public CommunicationConnection createConnection(CommunicationParam params) {
if (params == null) {
throw new IllegalArgumentException("param is null!");
}
// 构造对应的url
String serviceUrl = MessageFormat.format(RMI_SERVICE_URL, params.getIp(), String.valueOf(params.getPort()));
// 自己实现的有连接池的Stub
RmiProxyFactoryBean proxy = new RmiProxyFactoryBean();
proxy.setServiceUrl(serviceUrl);
proxy.setServiceInterface(CommunicationEndpoint.class);
proxy.afterPropertiesSet();
// 创建链接
return new RmiCommunicationConnection(params, (CommunicationEndpoint) proxy.getObject());
}
use of org.springframework.remoting.rmi.RmiProxyFactoryBean in project dubbo by alibaba.
the class RmiProtocol method doRefer.
@SuppressWarnings("unchecked")
protected <T> T doRefer(final Class<T> serviceType, final URL url) throws RpcException {
final RmiProxyFactoryBean rmiProxyFactoryBean = new RmiProxyFactoryBean();
// RMI needs extra parameter since it uses customized remote invocation object
if (url.getParameter(Constants.DUBBO_VERSION_KEY, Version.getVersion()).equals(Version.getVersion())) {
// Check dubbo version on provider, this feature only support
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();
}
Aggregations