org.springframework.remoting.rmi

## 类 RmiRegistryFactoryBean

- java.lang.Object
- - org.springframework.remoting.rmi.RmiRegistryFactoryBean

- 所有已实现的接口:
    org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.FactoryBean<Registry>, org.springframework.beans.factory.InitializingBean

      public class RmiRegistryFactoryBean
      extends Object
      implements org.springframework.beans.factory.FactoryBean<Registry>, org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.DisposableBean

  `FactoryBean` that locates a `Registry` and exposes it for bean references. Can also create a local RMI registry on the fly if none exists already.

  Can be used to set up and pass around the actual Registry object to applications objects that need to work with RMI. One example for such an object that needs to work with RMI is Spring's `RmiServiceExporter`, which either works with a passed-in Registry reference or falls back to the registry as specified by its local properties and defaults.

  Also useful to enforce creation of a local RMI registry at a given port, for example for a JMX connector. If used in conjunction with `ConnectorServerFactoryBean`, it is recommended to mark the connector definition (ConnectorServerFactoryBean) as "depends-on" the registry definition (RmiRegistryFactoryBean), to guarantee starting up the registry first.

  Note: The implementation of this class mirrors the corresponding logic in `RmiServiceExporter`, and also offers the same customization hooks. RmiServiceExporter implements its own registry lookup as a convenience: It is very common to simply rely on the registry defaults.

  从以下版本开始:
    1.2.3
  作者:
    Juergen Hoeller
  另请参阅:
    `RmiServiceExporter.setRegistry(java.rmi.registry.Registry)`, `ConnectorServerFactoryBean`, `Registry`, `LocateRegistry`

- - ### 字段概要

    字段
    限定符和类型 | 字段和说明
    --- | ---
    `protected Log` | `logger`

  - ### 构造器概要

    构造器
    构造器和说明
    `RmiRegistryFactoryBean()`

  - ### 方法概要

    所有方法 实例方法 具体方法
    限定符和类型 | 方法和说明
    --- | ---
    `void` | `afterPropertiesSet()`
    `void` | `destroy()` Unexport the RMI registry on bean factory shutdown, provided that this bean actually created a registry.
    `String` | `getHost()` Return the host of the registry for the exported RMI service.
    `Registry` | `getObject()`
    `Class<? extends Registry>` | `getObjectType()`
    `int` | `getPort()` Return the port of the registry for the exported RMI service.
    `protected Registry` | `getRegistry(int registryPort)` Locate or create the RMI registry.
    `protected Registry` | `getRegistry(int registryPort, RMIClientSocketFactory clientSocketFactory, RMIServerSocketFactory serverSocketFactory)` Locate or create the RMI registry.
    `protected Registry` | `getRegistry(String registryHost, int registryPort, RMIClientSocketFactory clientSocketFactory, RMIServerSocketFactory serverSocketFactory)` Locate or create the RMI registry.
    `boolean` | `isSingleton()`
    `void` | `setAlwaysCreate(boolean alwaysCreate)` Set whether to always create the registry in-process, not attempting to locate an existing registry at the specified port.
    `void` | `setClientSocketFactory(RMIClientSocketFactory clientSocketFactory)` Set a custom RMI client socket factory to use for the RMI registry.
    `void` | `setHost(String host)` Set the host of the registry for the exported RMI service, i.e.
    `void` | `setPort(int port)` Set the port of the registry for the exported RMI service, i.e.
    `void` | `setServerSocketFactory(RMIServerSocketFactory serverSocketFactory)` Set a custom RMI server socket factory to use for the RMI registry.
    `protected void` | `testRegistry(Registry registry)` Test the given RMI registry, calling some operation on it to check whether it is still active.

    - ### 从类继承的方法 java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### 字段详细资料

    - #### logger

          protected final Log logger

  - ### 构造器详细资料

    - #### RmiRegistryFactoryBean

          public RmiRegistryFactoryBean()

  - ### 方法详细资料

    - #### setHost

          public void setHost(String host)

      Set the host of the registry for the exported RMI service, i.e. `rmi://HOST:port/name`

      Default is localhost.

    - #### getHost

          public String getHost()

      Return the host of the registry for the exported RMI service.

    - #### setPort

          public void setPort(int port)

      Set the port of the registry for the exported RMI service, i.e. `rmi://host:PORT/name`

      Default is `Registry.REGISTRY_PORT` (1099).

    - #### getPort

          public int getPort()

      Return the port of the registry for the exported RMI service.

    - #### setClientSocketFactory

          public void setClientSocketFactory(RMIClientSocketFactory clientSocketFactory)

      Set a custom RMI client socket factory to use for the RMI registry.

      If the given object also implements `java.rmi.server.RMIServerSocketFactory`, it will automatically be registered as server socket factory too.

      另请参阅:
        `setServerSocketFactory(java.rmi.server.RMIServerSocketFactory)`, `RMIClientSocketFactory`, `RMIServerSocketFactory`, `LocateRegistry.getRegistry(String, int, java.rmi.server.RMIClientSocketFactory)`

    - #### setServerSocketFactory

          public void setServerSocketFactory(RMIServerSocketFactory serverSocketFactory)

      Set a custom RMI server socket factory to use for the RMI registry.

      Only needs to be specified when the client socket factory does not implement `java.rmi.server.RMIServerSocketFactory` already.

      另请参阅:
        `setClientSocketFactory(java.rmi.server.RMIClientSocketFactory)`, `RMIClientSocketFactory`, `RMIServerSocketFactory`, `LocateRegistry.createRegistry(int, RMIClientSocketFactory, java.rmi.server.RMIServerSocketFactory)`

    - #### setAlwaysCreate

          public void setAlwaysCreate(boolean alwaysCreate)

      Set whether to always create the registry in-process, not attempting to locate an existing registry at the specified port.

      Default is "false". Switch this flag to "true" in order to avoid the overhead of locating an existing registry when you always intend to create a new registry in any case.

    - #### afterPropertiesSet

          public void afterPropertiesSet()
                                  throws Exception

      指定者:
        `afterPropertiesSet` 在接口中 `org.springframework.beans.factory.InitializingBean`
      抛出:
        `Exception`

    - #### getRegistry

          protected Registry getRegistry(String registryHost,
                                         int registryPort,
                                         @Nullable
                                         RMIClientSocketFactory clientSocketFactory,
                                         @Nullable
                                         RMIServerSocketFactory serverSocketFactory)
                                  throws RemoteException

      Locate or create the RMI registry.
      参数:
        `registryHost` - the registry host to use (if this is specified, no implicit creation of a RMI registry will happen)
        `registryPort` - the registry port to use
        `clientSocketFactory` - the RMI client socket factory for the registry (if any)
        `serverSocketFactory` - the RMI server socket factory for the registry (if any)
      返回:
        the RMI registry
      抛出:
        `RemoteException` - if the registry couldn't be located or created

    - #### getRegistry

          protected Registry getRegistry(int registryPort,
                                         @Nullable
                                         RMIClientSocketFactory clientSocketFactory,
                                         @Nullable
                                         RMIServerSocketFactory serverSocketFactory)
                                  throws RemoteException

      Locate or create the RMI registry.
      参数:
        `registryPort` - the registry port to use
        `clientSocketFactory` - the RMI client socket factory for the registry (if any)
        `serverSocketFactory` - the RMI server socket factory for the registry (if any)
      返回:
        the RMI registry
      抛出:
        `RemoteException` - if the registry couldn't be located or created

    - #### getRegistry

          protected Registry getRegistry(int registryPort)
                                  throws RemoteException

      Locate or create the RMI registry.
      参数:
        `registryPort` - the registry port to use
      返回:
        the RMI registry
      抛出:
        `RemoteException` - if the registry couldn't be located or created

    - #### testRegistry

          protected void testRegistry(Registry registry)
                               throws RemoteException

      Test the given RMI registry, calling some operation on it to check whether it is still active.

      Default implementation calls `Registry.list()`.

      参数:
        `registry` - the RMI registry to test
      抛出:
        `RemoteException` - if thrown by registry methods
      另请参阅:
        `Registry.list()`

    - #### getObject

          public Registry getObject()
                             throws Exception

      指定者:
        `getObject` 在接口中 `org.springframework.beans.factory.FactoryBean<Registry>`
      抛出:
        `Exception`

    - #### getObjectType

          public Class<? extends Registry> getObjectType()

      指定者:
        `getObjectType` 在接口中 `org.springframework.beans.factory.FactoryBean<Registry>`

    - #### isSingleton

          public boolean isSingleton()

      指定者:
        `isSingleton` 在接口中 `org.springframework.beans.factory.FactoryBean<Registry>`

    - #### destroy

          public void destroy()
                       throws RemoteException

      Unexport the RMI registry on bean factory shutdown, provided that this bean actually created a registry.
      指定者:
        `destroy` 在接口中 `org.springframework.beans.factory.DisposableBean`
      抛出:
        `RemoteException`