Class SimpleServiceRegistry

    • Constructor Detail

      • SimpleServiceRegistry

        public SimpleServiceRegistry()
    • Method Detail

      • register

        public <T> void register​(Class<T> service,
                                 T implementation)
        Description copied from interface: ServiceRegistry
        Registers a service instance.

        The given instance is returned each time the service is requested by ServiceLoader.getService(Class).

        If the service already has a registered instance, the previous one is replaced.

        Specified by:
        register in interface ServiceRegistry
        Type Parameters:
        T - the service type.
        Parameters:
        service - the implemented service.
        implementation - the service instance.
      • unregister

        public <T> void unregister​(Class<T> service,
                                   T implementation)
        Description copied from interface: ServiceRegistry
        Unregisters a service instance.

        If the given instance is not the one currently registered for the given service, nothing is done.

        Specified by:
        unregister in interface ServiceRegistry
        Type Parameters:
        T - the service type.
        Parameters:
        service - the implemented service.
        implementation - the service instance.