Class ServiceExporter

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

public final class ServiceExporter extends Object
This class allows to make some service available through 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 Details

    • ServiceExporter

      public ServiceExporter()
  • Method Details

    • 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