org.nuiton.util.rmi
Class ServiceExporter

java.lang.Object
  extended by org.nuiton.util.rmi.ServiceExporter

public final class ServiceExporter
extends 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

Constructor Summary
ServiceExporter()
           
 
Method Summary
protected static Registry getRegistry()
          Will look for the RMI registry.
static
<E> void
registerService(Class<E> serviceInterface, E instance)
          Will register a service using the default name.
static
<E> void
registerService(String rmiName, E instance)
          Will register a service using the given RMI name.
protected static void testRmiConfig()
          Does some checks on RMI configuration
static void unregisterService(Class<?> serviceInterface)
          Will unregister a service using the default name.
static void unregisterService(String rmiName)
          Will unregister a service using the given RMI name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServiceExporter

public ServiceExporter()
Method Detail

testRmiConfig

protected static void testRmiConfig()
Does some checks on RMI configuration


getRegistry

protected static Registry getRegistry()
                               throws RemoteException
Will 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:
RemoteException - in case it is not possible to get the registry

registerService

public static <E> void registerService(Class<E> serviceInterface,
                                       E instance)
                            throws RemoteException
Will 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 name
instance - the service instance to bind
Throws:
RemoteException - in case the registry is not reachable

registerService

public static <E> void registerService(String rmiName,
                                       E instance)
                            throws RemoteException
Will 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 registry
instance - the service instance to bind
Throws:
RemoteException - in case the registry is not reachable

unregisterService

public static void unregisterService(Class<?> serviceInterface)
                              throws RemoteException,
                                     NotBoundException
Will 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:
RemoteException - in case the registry is not reachable
NotBoundException - in case the given name is not bound

unregisterService

public static void unregisterService(String rmiName)
                              throws RemoteException,
                                     NotBoundException
Will unregister a service using the given RMI name.

Parameters:
rmiName - the RMI name used to unbind the service in the registry
Throws:
RemoteException - in case the registry is not reachable
NotBoundException - in case the given name is not bound


Copyright © 2004-2011 CodeLutin. All Rights Reserved.