Search in sources :

Example 1 with RmiProxyFactoryBean

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());
}
Also used : RmiProxyFactoryBean(org.springframework.remoting.rmi.RmiProxyFactoryBean)

Example 2 with RmiProxyFactoryBean

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();
}
Also used : RemoteInvocation(org.springframework.remoting.support.RemoteInvocation) RemoteInvocationFactory(org.springframework.remoting.support.RemoteInvocationFactory) MethodInvocation(org.aopalliance.intercept.MethodInvocation) RmiProxyFactoryBean(org.springframework.remoting.rmi.RmiProxyFactoryBean)

Aggregations

RmiProxyFactoryBean (org.springframework.remoting.rmi.RmiProxyFactoryBean)2 MethodInvocation (org.aopalliance.intercept.MethodInvocation)1 RemoteInvocation (org.springframework.remoting.support.RemoteInvocation)1 RemoteInvocationFactory (org.springframework.remoting.support.RemoteInvocationFactory)1