com.interface21.remoting.rmi
Class RmiServiceExporter
java.lang.Object
|
+--com.interface21.remoting.rmi.RmiServiceExporter
- All Implemented Interfaces:
- InitializingBean
- public class RmiServiceExporter
- extends java.lang.Object
- implements InitializingBean
RMI exporter that exposes the specified service as transparent RMI object
with the specified name. Such services can be accessed via RmiProxyFactoryBean.
Transparent means that RMI communication works on the RemoteInvocationHandler
level, needing only one stub for any service. Service interfaces do not have to
extend java.rmi.Remote or throw RemoteException on all methods, but in and out
parameters have to be serializable.
A conventional RMI lookup will return a RemoteInvocationHandler instance
instead of a proxy implementing the service interface. To access the service,
a java.lang.reflect.Proxy has to be created, using a StubInvocationHandler
configured for the RemoteInvocationHandler instance. Of course, a helper like
RmiProxyFactoryBean makes this much simpler!
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.
- Since:
- 13.05.2003
- Author:
- Juergen Hoeller
- See Also:
RmiProxyFactoryBean,
RemoteInvocationHandler,
RemoteInvocationWrapper
|
Field Summary |
protected org.apache.commons.logging.Log |
logger
|
|
Method Summary |
void |
afterPropertiesSet()
Register the service as RMI object.
|
void |
setName(java.lang.String name)
Set the name of the exported RMI object,
i.e. rmi://localhost:port/NAME |
void |
setPort(int port)
Set the port of the registry for the exported RMI object,
i.e. rmi://localhost:PORT/name
Default is Registry.REGISTRY_PORT (1099). |
void |
setService(java.lang.Object service)
Set the service to export via RMI.
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
logger
protected final org.apache.commons.logging.Log logger
RmiServiceExporter
public RmiServiceExporter()
setService
public void setService(java.lang.Object service)
- Set the service to export via RMI.
Typically populated via a bean reference.
setName
public void setName(java.lang.String name)
- Set the name of the exported RMI object,
i.e. rmi://localhost:port/NAME
setPort
public void setPort(int port)
- Set the port of the registry for the exported RMI object,
i.e. rmi://localhost:PORT/name
Default is Registry.REGISTRY_PORT (1099).
afterPropertiesSet
public void afterPropertiesSet()
throws java.rmi.AlreadyBoundException,
java.rmi.RemoteException
- Register the service as RMI object.
Creates an RMI registry on the specified port if none exists.
- Specified by:
afterPropertiesSet in interface InitializingBean
- Following copied from interface:
com.interface21.beans.factory.InitializingBean
- Throws:
java.lang.Exception - in the event of misconfiguration (such
as failure to set an essential property) or if initialization fails.
Rod Johnson and Spring contributors 2001-2003.