Class SharedServiceRegistryKF

  • All Implemented Interfaces:
    SharedServiceRegistry, ej.kf.FeatureStateListener, ej.service.ServiceLoader, ej.service.ServiceRegistry

    public class SharedServiceRegistryKF
    extends ej.service.registry.SimpleServiceRegistry
    implements SharedServiceRegistry, ej.kf.FeatureStateListener
    Implementation of the shared service registry over Kernel and Features.

    This service registry is able to handle the following kind of services:

    • Services owned by the kernel, available to the kernel and the features (provided that the type is part of the API)
    • Services owned by a feature using shared interfaces mechanism, available to other features through Proxy instances
    • Services owned by a feature using an interface owned by the kernel, only available to the kernel (kernel extensions)
    • Services owned by a feature using a type owned by the feature, only available to the feature
    • Field Summary

      • Fields inherited from class ej.service.loader.SimpleServiceLoader

        services
    • Constructor Summary

      Constructors 
      Constructor Description
      SharedServiceRegistryKF()
      Creates a shared service registry.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      <T> T getService​(java.lang.Class<T> serviceClass)
      Gets the registered implementation for the given service.
      <T> void register​(java.lang.Class<T> serviceClass, T implementation)  
      void stateChanged​(ej.kf.Feature feature, ej.kf.Feature.State previousState)  
      <T> void unregister​(java.lang.Class<T> serviceClass, T implementation)  
      • Methods inherited from class ej.service.loader.SimpleServiceLoader

        checkServicePermission, createAlternativeImplementation, putService
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • SharedServiceRegistryKF

        public SharedServiceRegistryKF()
        Creates a shared service registry.
    • Method Detail

      • register

        public <T> void register​(java.lang.Class<T> serviceClass,
                                 T implementation)
        Specified by:
        register in interface ej.service.ServiceRegistry
        Overrides:
        register in class ej.service.registry.SimpleServiceRegistry
      • unregister

        public <T> void unregister​(java.lang.Class<T> serviceClass,
                                   T implementation)
        Specified by:
        unregister in interface ej.service.ServiceRegistry
        Overrides:
        unregister in class ej.service.registry.SimpleServiceRegistry
      • getService

        @Nullable
        public <T> T getService​(java.lang.Class<T> serviceClass)
        Gets the registered implementation for the given service. This implementation depends on who request it. if it is a feature we search the service with the following order:
        • We search it in the shared services provided by the current feature.
        • We search it in the shared services provided by the kernel.
        • We search it in the shared services provided by the trusted features.
        • We search it in the shared services provided by the non trusted features.
        if it is the kernel, we search the service with the following order:
        • We search it in the shared services provided by the kernel.
        • We search it in the shared services provided by the trusted features.
        • We search it in the shared services provided by the non trusted features.
        Specified by:
        getService in interface ej.service.ServiceLoader
        Overrides:
        getService in class ej.service.loader.SimpleServiceLoader
        Type Parameters:
        T - the service type.
        Parameters:
        serviceClass - the service to found.
        Returns:
        an instance of the given service or null if no implementation is available.
      • stateChanged

        public void stateChanged​(@Nullable
                                 ej.kf.Feature feature,
                                 @Nullable
                                 ej.kf.Feature.State previousState)
        Specified by:
        stateChanged in interface ej.kf.FeatureStateListener