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.Registry getRegistry()
    Will look for the RMI registry.
    static <E> void registerService​(java.lang.Class<E> serviceInterface, E instance)
    Will register a service using the default name.
    static <E> void registerService​(java.lang.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​(java.lang.Class<?> serviceInterface)
    Will unregister a service using the default name.
    static void unregisterService​(java.lang.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 Details

  • Method Details

    • testRmiConfig

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

      protected static java.rmi.registry.Registry getRegistry() throws java.rmi.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:
      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.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:
      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.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:
      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.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:
      java.rmi.RemoteException - in case the registry is not reachable
      java.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.NotBoundException
      Will 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 reachable
      java.rmi.NotBoundException - in case the given name is not bound