Class SimpleRMI.Registry

  • Enclosing class:
    SimpleRMI

    public static final class SimpleRMI.Registry
    extends Object
    Registry of services. Services are always keyed by the interface that they implement. That is, for a given interface we can have only one implementation of that interface in the registry.
    • Constructor Detail

      • Registry

        public Registry()
        Create an empty registry
      • Registry

        public Registry​(SimpleRMI.Registry reg)
        Create a clone of an existing registry
        Parameters:
        reg - the registry to clone
    • Method Detail

      • register

        public <T> void register​(Class<T> clazz,
                                 T object)
        Registers the single implementation of the given service interface.
        Type Parameters:
        T - the type of service
        Parameters:
        clazz - the service interface
        object - an object implementing the service interface
      • get

        public <T> T get​(Class<T> clazz)
        Returns the registered implementation of the given interface.
        Type Parameters:
        T - the service interface
        Parameters:
        clazz - the service interface
        Returns:
        the implementation or null of none exists