类 RmiServiceExporter

  • 所有已实现的接口:
    Aware, BeanClassLoaderAware, DisposableBean, InitializingBean

    public class RmiServiceExporter
    extends RmiBasedExporter
    implements InitializingBean, DisposableBean
    RMI exporter that exposes the specified service as RMI object with the specified name. Such services can be accessed via plain RMI or via RmiProxyFactoryBean. Also supports exposing any non-RMI service via RMI invokers, to be accessed via RmiClientInterceptor / RmiProxyFactoryBean's automatic detection of such invokers.

    With an RMI invoker, RMI communication works on the RmiInvocationHandler level, needing only one stub for any service. Service interfaces do not have to extend java.rmi.Remote or throw java.rmi.RemoteException on all methods, but in and out parameters have to be serializable.

    The major advantage of RMI, compared to Hessian, is serialization. Effectively, any serializable Java object can be transported without hassle. Hessian has its own (de-)serialization mechanisms, but is HTTP-based and thus much easier to setup than RMI. Alternatively, consider Spring's HTTP invoker to combine Java serialization with HTTP-based transport.

    Note: RMI makes a best-effort attempt to obtain the fully qualified host name. If one cannot be determined, it will fall back and use the IP address. Depending on your network configuration, in some cases it will resolve the IP to the loopback address. To ensure that RMI will use the host name bound to the correct network interface, you should pass the java.rmi.server.hostname property to the JVM that will export the registry and/or the service using the "-D" JVM argument. For example: -Djava.rmi.server.hostname=myserver.com

    从以下版本开始:
    13.05.2003
    作者:
    Juergen Hoeller
    另请参阅:
    RmiClientInterceptor, RmiProxyFactoryBean, Remote, RemoteException, HessianServiceExporter, HttpInvokerServiceExporter