Interface IServicesRegistry

  • All Known Implementing Classes:
    DefaultServicesRegistry

    public interface IServicesRegistry
    The ServicesRegistry, is to be able to manage and summarize implementations of interfaces and abstract classes in order to make them dynamically retrievable.
    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      <T> boolean containsService​(java.lang.Class<T> clazz, java.lang.String name)
      Request of a service with a specific name is already exists or not
      default <T> T getFirstService​(java.lang.Class<T> clazz)
      Returns the service implementation or null from this registry
      java.util.Collection<java.lang.Class<?>> getProvidedServices()
      Returns all provider classes that are actual contain in on this registry
      <T> T getService​(java.lang.Class<T> clazz, java.lang.String name)
      Returns the service implementation or null from this registry
      <T> java.util.Collection<T> getServices​(java.lang.Class<T> clazz)
      Returns all services implementation
      <T,​E extends T>
      IServicesRegistry
      registerService​(java.lang.Class<T> clazz, java.lang.String name, E service)
      Registers a new service from the basic parent class.
      IServicesRegistry unregisterAll()
      Unregister all services and provider classes from the registry
      IServicesRegistry unregisterAll​(java.lang.ClassLoader classLoader)
      Unregister all services which are loaded from that specific classLoader.
      <T,​E extends T>
      IServicesRegistry
      unregisterService​(java.lang.Class<T> clazz, E service)
      Unregister a all services which instance is equals one of this services that are already registered
      <T,​E extends T>
      IServicesRegistry
      unregisterService​(java.lang.Class<T> clazz, java.lang.Class<E> serviceClazz)
      Unregister a all services which class equals the E type of the registered services
      <T> IServicesRegistry unregisterService​(java.lang.Class<T> clazz, java.lang.String name)
      Unregisters a service by the name of the service on a specific class provider
      <T> IServicesRegistry unregisterServices​(java.lang.Class<T> clazz)
      Removes all services from the registry, which has the following provider class
    • Method Detail

      • registerService

        <T,​E extends T> IServicesRegistry registerService​(java.lang.Class<T> clazz,
                                                                java.lang.String name,
                                                                E service)
        Registers a new service from the basic parent class. and can get with the following key
        Type Parameters:
        T - the interface or abstract type which you want the implementation providing for
        E - the implementation of the service type T
        Parameters:
        clazz - the interface class, which should the provider of the service
        name - the name of the service, which should registered
        service - the service instance to register
        Returns:
        the current instance, of the class, which was used to offerTask this method
      • unregisterService

        <T,​E extends T> IServicesRegistry unregisterService​(java.lang.Class<T> clazz,
                                                                  java.lang.Class<E> serviceClazz)
        Unregister a all services which class equals the E type of the registered services
        Type Parameters:
        T - the interface or abstract type which you want the implementation providing for
        E - the implementation of the service type T
        Parameters:
        clazz - the interface class, which should the provider of the service
        serviceClazz - the class, of the services which should unregister
        Returns:
        the current instance of the ServiceRegistry
      • unregisterService

        <T,​E extends T> IServicesRegistry unregisterService​(java.lang.Class<T> clazz,
                                                                  E service)
        Unregister a all services which instance is equals one of this services that are already registered
        Type Parameters:
        T - the interface or abstract type which you want the implementation providing for
        E - the implementation of the service type T
        Parameters:
        clazz - the interface class, which should the provider of the service
        service - the instance
        Returns:
        the current instance of the ServiceRegistry
      • containsService

        <T> boolean containsService​(java.lang.Class<T> clazz,
                                    java.lang.String name)
        Request of a service with a specific name is already exists or not
        Type Parameters:
        T - the interface or abstract type which you want the implementation providing for
        Parameters:
        clazz - the provider class
        name - the name of the service, from that should be check
        Returns:
        true if a service from the provider is contain in this registry
      • unregisterService

        <T> IServicesRegistry unregisterService​(java.lang.Class<T> clazz,
                                                java.lang.String name)
        Unregisters a service by the name of the service on a specific class provider
        Type Parameters:
        T - the interface or abstract type which you want the implementation providing for
        Parameters:
        clazz - the base class from that the service should be removed
        name - the registered name from the service implementation
        Returns:
        the current instance of the ServiceRegistry
      • unregisterServices

        <T> IServicesRegistry unregisterServices​(java.lang.Class<T> clazz)
        Removes all services from the registry, which has the following provider class
        Type Parameters:
        T - the interface or abstract type which you want the implementation providing for
        Parameters:
        clazz - the provider base class from that should all services be removed
        Returns:
        the current instance of the ServiceRegistry
      • unregisterAll

        IServicesRegistry unregisterAll()
        Unregister all services and provider classes from the registry
        Returns:
        the current instance of the ServiceRegistry
      • unregisterAll

        IServicesRegistry unregisterAll​(java.lang.ClassLoader classLoader)
        Unregister all services which are loaded from that specific classLoader.
        Parameters:
        classLoader - the classLoader, from that all services should be removed
        Returns:
        the current instance of the ServiceRegistry
      • getProvidedServices

        java.util.Collection<java.lang.Class<?>> getProvidedServices()
        Returns all provider classes that are actual contain in on this registry
      • getService

        <T> T getService​(java.lang.Class<T> clazz,
                         java.lang.String name)
        Returns the service implementation or null from this registry
        Type Parameters:
        T - the interface or abstract type which you want the implementation providing for
        Parameters:
        clazz - the base provider class, from that the service should get
        name - the name of the service that should get
        Returns:
        the service implementation of the base class or the base class himself
      • getFirstService

        default <T> T getFirstService​(java.lang.Class<T> clazz)
        Returns the service implementation or null from this registry
        Type Parameters:
        T - the interface or abstract type which you want the implementation providing for
        Parameters:
        clazz - the base provider class, from that the service should get
        Returns:
        the first service implementation found registered for the provided class
      • getServices

        <T> java.util.Collection<T> getServices​(java.lang.Class<T> clazz)
        Returns all services implementation
        Type Parameters:
        T - the interface or abstract type which you want the implementation providing for
        Parameters:
        clazz - the base provider class, from that the service should get
        Returns:
        the service implementations of the base class or the base class himself