Class JndiRmiServiceExporter
- java.lang.Object
- org.springframework.remoting.support.RemotingSupport
- org.springframework.remoting.support.RemoteExporter
- org.springframework.remoting.support.RemoteInvocationBasedExporter
- org.springframework.remoting.rmi.RmiBasedExporter
- org.springframework.remoting.rmi.JndiRmiServiceExporter
- All Implemented Interfaces:
Aware,BeanClassLoaderAware,DisposableBean,InitializingBean
public class JndiRmiServiceExporter extends RmiBasedExporter implements InitializingBean, DisposableBean
Service exporter which binds RMI services to JNDI. Typically used for RMI-IIOP (CORBA).Exports services via the
javax.rmi.PortableRemoteObjectclass. You need to run "rmic" with the "-iiop" option to generate corresponding stubs and skeletons for each exported service.Also supports exposing any non-RMI service via RMI invokers, to be accessed via
JndiRmiClientInterceptor/JndiRmiProxyFactoryBean's automatic detection of such invokers.With an RMI invoker, RMI communication works on the
RmiInvocationHandlerlevel, needing only one stub for any service. Service interfaces do not have to extendjava.rmi.Remoteor throwjava.rmi.RemoteExceptionon all methods, but in and out parameters have to be serializable.The JNDI environment can be specified as "jndiEnvironment" bean property, or be configured in a
jndi.propertiesfile or as system properties. For example:<property name="jndiEnvironment"> <props> <prop key="java.naming.factory.initial">com.sun.jndi.cosnaming.CNCtxFactory</prop> <prop key="java.naming.provider.url">iiop://localhost:1050</prop> </props> </property>- Since:
- 1.1
- Author:
- Juergen Hoeller
- See Also:
RemoteExporter.setService(java.lang.Object),setJndiTemplate(org.springframework.jndi.JndiTemplate),setJndiEnvironment(java.util.Properties),setJndiName(java.lang.String),JndiRmiClientInterceptor,JndiRmiProxyFactoryBean,javax.rmi.PortableRemoteObject#exportObject
Field Summary
Fields inherited from class org.springframework.remoting.support.RemotingSupport
logger
Constructor Summary
Constructors Constructor Description JndiRmiServiceExporter()
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidafterPropertiesSet()Invoked by the containingBeanFactoryafter it has set all bean properties and satisfiedBeanFactoryAware,ApplicationContextAwareetc.voiddestroy()Unbind the RMI service from JNDI on bean factory shutdown.voidprepare()Initialize this service exporter, binding the specified service to JNDI.voidrebind()Rebind the specified service to JNDI, for recovering in case of the target registry having been restarted.voidsetJndiEnvironment(Properties jndiEnvironment)Set the JNDI environment to use for JNDI lookups.voidsetJndiName(String jndiName)Set the JNDI name of the exported RMI service.voidsetJndiTemplate(JndiTemplate jndiTemplate)Set the JNDI template to use for JNDI lookups.Methods inherited from class org.springframework.remoting.rmi.RmiBasedExporter
getObjectToExport, invoke
Methods inherited from class org.springframework.remoting.support.RemoteInvocationBasedExporter
getRemoteInvocationExecutor, invokeAndCreateResult, setRemoteInvocationExecutor
Methods inherited from class org.springframework.remoting.support.RemoteExporter
checkService, checkServiceInterface, getExporterName, getProxyForService, getService, getServiceInterface, setInterceptors, setRegisterTraceInterceptor, setService, setServiceInterface
Methods inherited from class org.springframework.remoting.support.RemotingSupport
getBeanClassLoader, overrideThreadContextClassLoader, resetThreadContextClassLoader, setBeanClassLoader
Constructor Detail
JndiRmiServiceExporter
public JndiRmiServiceExporter()
Method Detail
setJndiTemplate
public void setJndiTemplate(JndiTemplate jndiTemplate)
Set the JNDI template to use for JNDI lookups. You can also specify JNDI environment settings via "jndiEnvironment".
setJndiEnvironment
public void setJndiEnvironment(Properties jndiEnvironment)
Set the JNDI environment to use for JNDI lookups. Creates a JndiTemplate with the given environment settings.
setJndiName
public void setJndiName(String jndiName)
Set the JNDI name of the exported RMI service.
afterPropertiesSet
public void afterPropertiesSet() throws NamingException, RemoteException
Description copied from interface:InitializingBeanInvoked by the containingBeanFactoryafter it has set all bean properties and satisfiedBeanFactoryAware,ApplicationContextAwareetc.This method allows the bean instance to perform validation of its overall configuration and final initialization when all bean properties have been set.
- Specified by:
afterPropertiesSetin interfaceInitializingBean- Throws:
NamingExceptionRemoteException
prepare
public void prepare() throws NamingException, RemoteException
Initialize this service exporter, binding the specified service to JNDI.- Throws:
NamingException- if service binding failedRemoteException- if service export failed
rebind
public void rebind() throws NamingException
Rebind the specified service to JNDI, for recovering in case of the target registry having been restarted.- Throws:
NamingException- if service binding failed
destroy
public void destroy() throws NamingException, NoSuchObjectException
Unbind the RMI service from JNDI on bean factory shutdown.- Specified by:
destroyin interfaceDisposableBean- Throws:
NamingExceptionNoSuchObjectException