Java Code Examples for org.springframework.remoting.rmi.RmiProxyFactoryBean#getObject()

The following examples show how to use org.springframework.remoting.rmi.RmiProxyFactoryBean#getObject() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RmiProtocol.java    From dubbo-2.6.5 with Apache License 2.0 6 votes vote down vote up
@Override
@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.getProtocolVersion()).equals(Version.getProtocolVersion())) {
        // Check dubbo version on provider, this feature only support
        rmiProxyFactoryBean.setRemoteInvocationFactory(new RemoteInvocationFactory() {
            @Override
            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();
}
 
Example 2
Source File: RmiRemoteInputStreamServer.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * 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();
}
 
Example 3
Source File: RmiClientConfig.java    From Spring with Apache License 2.0 5 votes vote down vote up
@Bean
public UserService userService() {
    final RmiProxyFactoryBean factoryBean = new RmiProxyFactoryBean();
    factoryBean.setServiceInterface(UserService.class);
    factoryBean.setServiceUrl("rmi://localhost:1098/userService");
    factoryBean.afterPropertiesSet();
    return (UserService) factoryBean.getObject();
}
 
Example 4
Source File: RmiClientConfig.java    From Spring with Apache License 2.0 5 votes vote down vote up
@Bean
public UserService userService() {
    final RmiProxyFactoryBean factoryBean = new RmiProxyFactoryBean();
    factoryBean.setServiceInterface(UserService.class);
    factoryBean.setServiceUrl("rmi://localhost:1099/userService");
    factoryBean.afterPropertiesSet();
    return (UserService) factoryBean.getObject();
}
 
Example 5
Source File: RmiProtocol.java    From dubbox with Apache License 2.0 5 votes vote down vote up
@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();
}
 
Example 6
Source File: RmiProtocol.java    From dubbox-hystrix with Apache License 2.0 5 votes vote down vote up
@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();
}
 
Example 7
Source File: RmiProtocol.java    From dubbox with Apache License 2.0 5 votes vote down vote up
@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();
}
 
Example 8
Source File: RmiProtocol.java    From dubbox with Apache License 2.0 5 votes vote down vote up
@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();
}