org.springframework.remoting.rmi
Class RmiProxyFactoryBean
java.lang.Object
org.springframework.remoting.support.RemotingSupport
org.springframework.remoting.support.RemoteAccessor
org.springframework.remoting.support.UrlBasedRemoteAccessor
org.springframework.remoting.support.RemoteInvocationBasedAccessor
org.springframework.remoting.rmi.RmiClientInterceptor
org.springframework.remoting.rmi.RmiProxyFactoryBean
- All Implemented Interfaces:
- org.aopalliance.aop.Advice, org.aopalliance.intercept.Interceptor, org.aopalliance.intercept.MethodInterceptor, org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanClassLoaderAware, org.springframework.beans.factory.FactoryBean<java.lang.Object>, org.springframework.beans.factory.InitializingBean
public class RmiProxyFactoryBean
- extends RmiClientInterceptor
- implements org.springframework.beans.factory.FactoryBean<java.lang.Object>, org.springframework.beans.factory.BeanClassLoaderAware
FactoryBean
for RMI proxies, supporting both conventional RMI services
and RMI invokers. Exposes the proxied service for use as a bean reference,
using the specified service interface. Proxies will throw Spring's unchecked
RemoteAccessException on remote invocation failure instead of RMI's RemoteException.
The service URL must be a valid RMI URL like "rmi://localhost:1099/myservice".
RMI invokers work at the RmiInvocationHandler level, using the same invoker stub
for any service. Service interfaces do not have to extend java.rmi.Remote
or throw java.rmi.RemoteException
. Of course, in and out parameters
have to be serializable.
With conventional RMI services, this proxy factory is typically used with the
RMI service interface. Alternatively, this factory can also proxy a remote RMI
service with a matching non-RMI business interface, i.e. an interface that mirrors
the RMI service methods but does not declare RemoteExceptions. In the latter case,
RemoteExceptions thrown by the RMI stub will automatically get converted to
Spring's unchecked RemoteAccessException.
The major advantage of RMI, compared to Hessian and Burlap, is serialization.
Effectively, any serializable Java object can be transported without hassle.
Hessian and Burlap have their own (de-)serialization mechanisms, but are
HTTP-based and thus much easier to setup than RMI. Alternatively, consider
Spring's HTTP invoker to combine Java serialization with HTTP-based transport.
- Since:
- 13.05.2003
- Author:
- Juergen Hoeller
- See Also:
RemoteAccessor.setServiceInterface(java.lang.Class)
,
UrlBasedRemoteAccessor.setServiceUrl(java.lang.String)
,
RmiClientInterceptor
,
RmiServiceExporter
,
Remote
,
RemoteException
,
RemoteAccessException
,
org.springframework.remoting.caucho.HessianProxyFactoryBean
,
org.springframework.remoting.caucho.BurlapProxyFactoryBean
,
org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean
Methods inherited from class org.springframework.remoting.rmi.RmiClientInterceptor |
doInvoke, doInvoke, getStub, invoke, isConnectFailure, lookupStub, prepare, refreshAndRetry, setCacheStub, setLookupStubOnStartup, setRefreshStubOnConnectFailure, setRegistryClientSocketFactory |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.springframework.beans.factory.BeanClassLoaderAware |
setBeanClassLoader |
RmiProxyFactoryBean
public RmiProxyFactoryBean()
afterPropertiesSet
public void afterPropertiesSet()
- Specified by:
afterPropertiesSet
in interface org.springframework.beans.factory.InitializingBean
- Overrides:
afterPropertiesSet
in class RmiClientInterceptor
getObject
public java.lang.Object getObject()
- Specified by:
getObject
in interface org.springframework.beans.factory.FactoryBean<java.lang.Object>
getObjectType
public java.lang.Class<?> getObjectType()
- Specified by:
getObjectType
in interface org.springframework.beans.factory.FactoryBean<java.lang.Object>
isSingleton
public boolean isSingleton()
- Specified by:
isSingleton
in interface org.springframework.beans.factory.FactoryBean<java.lang.Object>