Package org.nuiton.util.rmi
Class ServiceExporter
java.lang.Object
org.nuiton.util.rmi.ServiceExporter
public final class ServiceExporter
extends java.lang.Object
This class allows to make some service available throw RMI. For each service,
a wrapper will be created which will be put in the RMI registry. This wrapper
will intercept calls to the service and delegate them to it.
- Author:
- Arnaud Thimel - thimel@codelutin.com
-
Constructor Summary
Constructors Constructor Description ServiceExporter() -
Method Summary
Modifier and Type Method Description protected static java.rmi.registry.RegistrygetRegistry()Will look for the RMI registry.static <E> voidregisterService(java.lang.Class<E> serviceInterface, E instance)Will register a service using the default name.static <E> voidregisterService(java.lang.String rmiName, E instance)Will register a service using the given RMI name.protected static voidtestRmiConfig()Does some checks on RMI configurationstatic voidunregisterService(java.lang.Class<?> serviceInterface)Will unregister a service using the default name.static voidunregisterService(java.lang.String rmiName)Will unregister a service using the given RMI name.
-
Constructor Details
-
ServiceExporter
public ServiceExporter()
-
-
Method Details
-
testRmiConfig
protected static void testRmiConfig()Does some checks on RMI configuration -
getRegistry
protected static java.rmi.registry.Registry getRegistry() throws java.rmi.RemoteExceptionWill look for the RMI registry. It an external registry cannot be found, a new one will be created.- Returns:
- the registry found or created
- Throws:
java.rmi.RemoteException- in case it is not possible to get the registry
-
registerService
public static <E> void registerService(java.lang.Class<E> serviceInterface, E instance) throws java.rmi.RemoteExceptionWill register a service using the default name.- Type Parameters:
E- some interface class- Parameters:
serviceInterface- the interface used to bind the service. The RMI name will be generated from this class nameinstance- the service instance to bind- Throws:
java.rmi.RemoteException- in case the registry is not reachable
-
registerService
public static <E> void registerService(java.lang.String rmiName, E instance) throws java.rmi.RemoteExceptionWill register a service using the given RMI name.- Type Parameters:
E- some interface class- Parameters:
rmiName- the RMI name used to bind the service in the registryinstance- the service instance to bind- Throws:
java.rmi.RemoteException- in case the registry is not reachable
-
unregisterService
public static void unregisterService(java.lang.Class<?> serviceInterface) throws java.rmi.RemoteException, java.rmi.NotBoundExceptionWill unregister a service using the default name.- Parameters:
serviceInterface- the interface used to unbind the service. The RMI name will be generated from this class name- Throws:
java.rmi.RemoteException- in case the registry is not reachablejava.rmi.NotBoundException- in case the given name is not bound
-
unregisterService
public static void unregisterService(java.lang.String rmiName) throws java.rmi.RemoteException, java.rmi.NotBoundExceptionWill unregister a service using the given RMI name.- Parameters:
rmiName- the RMI name used to unbind the service in the registry- Throws:
java.rmi.RemoteException- in case the registry is not reachablejava.rmi.NotBoundException- in case the given name is not bound
-