Class ServiceRegistryKF

    • Constructor Detail

      • ServiceRegistryKF

        public ServiceRegistryKF()
        Instantiates a new service registry KF.
    • Method Detail

      • getService

        public <T> T getService​(Class<T> service)
        Description copied from interface: ServiceLoader
        Gets the instance of the given service.

        If there is already an instance in cache, it is returned otherwise a new one is created.

        May return null if the service is not defined.

        Specified by:
        getService in interface ServiceLoader
        Overrides:
        getService in class SimpleServiceLoader
        Type Parameters:
        T - the service type.
        Parameters:
        service - the service.
        Returns:
        the instance of the given service.
      • register

        public <T> void register​(Class<T> service,
                                 T instance)
        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
        Overrides:
        register in class SimpleServiceRegistry
        Type Parameters:
        T - the service type.
        Parameters:
        service - the implemented service.
        instance - the service instance.
      • register

        public <T> void register​(Class<T> service,
                                 T instance,
                                 boolean isKernelLocal)
        Registers a Service Instance for the Kernel.
        Parameters:
        service - the class type of the service
        instance - the instance of the service
        isKernelLocal - if the service should be stored in the local context of the Kernel or shared with other features
      • unregister

        public <T> void unregister​(Class<T> service,
                                   T instance)
        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
        Overrides:
        unregister in class SimpleServiceRegistry
        Type Parameters:
        T - the service type.
        Parameters:
        service - the implemented service.
        instance - the service instance.
      • unregister

        public <T> void unregister​(Class<T> service,
                                   T instance,
                                   boolean isKernelLocal)
        Unregisters a Service Instance from the Kernel.
        Parameters:
        service - the class type of the service
        instance - the instance of the service
        isKernelLocal - if the service should be removed from the local context of the Kernel or shared with other features