spring-framework / org.springframework.remoting.rmi / RmiRegistryFactoryBean

RmiRegistryFactoryBean

open class RmiRegistryFactoryBean : FactoryBean<Registry>, InitializingBean, DisposableBean

FactoryBean that locates a java.rmi.registry.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 org.springframework.jmx.support.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.

Author
Juergen Hoeller

Since
1.2.3

See Also
RmiServiceExporter#setRegistryorg.springframework.jmx.support.ConnectorServerFactoryBeanjava.rmi.registry.Registryjava.rmi.registry.LocateRegistry

Constructors

<init>

RmiRegistryFactoryBean()

FactoryBean that locates a java.rmi.registry.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 org.springframework.jmx.support.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.

Functions

afterPropertiesSet

open fun afterPropertiesSet(): Unit

destroy

open fun destroy(): Unit

Unexport the RMI registry on bean factory shutdown, provided that this bean actually created a registry.

getHost

open fun getHost(): String

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

getObject

open fun getObject(): Registry

getObjectType

open fun getObjectType(): Class<out Registry>

getPort

open fun getPort(): Int

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

isSingleton

open fun isSingleton(): Boolean

setAlwaysCreate

open fun setAlwaysCreate(alwaysCreate: Boolean): Unit

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.

setClientSocketFactory

open fun setClientSocketFactory(clientSocketFactory: RMIClientSocketFactory): Unit

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.

setHost

open fun setHost(host: String): Unit

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

Default is localhost.

setPort

open fun setPort(port: Int): Unit

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

Default is Registry.REGISTRY_PORT (1099).

setServerSocketFactory

open fun setServerSocketFactory(serverSocketFactory: RMIServerSocketFactory): Unit

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.