Interface ComponentFactory

    • Method Detail

      • containsComponent

        boolean containsComponent​(String type)
        Checks if at least one component is registered for the given type.
        Parameters:
        type - the fully qualified class name or an alias of the component.
        Returns:
        true if a provider exist, false otherwise.
      • containsComponent

        <T> boolean containsComponent​(String type,
                                      Qualifier<T> qualifier)
        Checks if at least one component is registered for the given type and qualifier.
        Parameters:
        type - the component type.
        qualifier - the options to qualified the component.
        Returns:
        true if a provider exist, false otherwise.
      • containsComponent

        <T> boolean containsComponent​(Class<T> type)
        Checks if at least one component is registered for the given type.
        Parameters:
        type - the component type.
        Returns:
        true if a provider exist, false otherwise.
      • containsComponent

        <T> boolean containsComponent​(Class<T> type,
                                      Qualifier<T> qualifier)
        Checks if at least one component is registered for the given type and qualifier.
        Parameters:
        type - the component type.
        qualifier - the options to qualified the component.
        Returns:
        true if a provider exist, false otherwise.
      • getComponent

        <T> T getComponent​(Class<T> type,
                           Conf conf)
        Gets an instance, which may be shared or independent, for the specified type.
        Type Parameters:
        T - the component-type.
        Parameters:
        type - the component class.
        conf - the configuration used if the component implement Configurable.
        Returns:
        the instance of type ComponentFactory.
        Throws:
        NoUniqueComponentException - if more than one component is registered for the given type.
        NoSuchComponentException - if no component is registered for the given type.
      • getComponent

        <T> T getComponent​(Class<T> type,
                           Conf conf,
                           Qualifier<T> qualifier)
        Gets an instance, which may be shared or independent, for the specified type.
        Type Parameters:
        T - the component-type.
        Parameters:
        type - the component class.
        conf - the configuration used if the component implement Configurable.
        qualifier - the options used to qualify the component.
        Returns:
        the instance of type ComponentFactory.
        Throws:
        NoUniqueComponentException - if more than one component is registered for the given type.
        NoSuchComponentException - if no component is registered for the given type.
      • getComponentProvider

        <T> GettableComponent<T> getComponentProvider​(Class<T> type,
                                                      Qualifier<T> qualifier)
        Gets an instance, which may be shared or independent, for the specified type.
        Type Parameters:
        T - the component-type.
        Parameters:
        type - the component class.
        qualifier - the options used to qualified the component.
        Returns:
        the instance of type ComponentFactory.
        Throws:
        NoUniqueComponentException - if more than one component is registered for the given type.
        NoSuchComponentException - if no component is registered for the given type.
      • getComponent

        <T> T getComponent​(String type,
                           Conf conf)
        Gets an instance, which may be shared or independent, for the specified type. If the object, returned from that method, implements the Configurable interface, then the factory will invoke the method Configurable.configure(Conf) with the given Conf. For a shared object, the method will be invoked only the first time it is returned.
        Type Parameters:
        T - the component-type.
        Parameters:
        type - the fully qualified class name or an alias of the component.
        conf - the configuration used if the component implement Configurable.
        Returns:
        the instance of type ComponentFactory.
        Throws:
        NoUniqueComponentException - if more than one component is registered for the given type.
        NoSuchComponentException - if no component is registered for the given class or alias..
      • getComponent

        <T> T getComponent​(String type,
                           Conf conf,
                           Qualifier<T> qualifier)
        Gets an instance, which may be shared or independent, for the specified type. If the object, returned from that method, implements the Configurable interface, then the factory will invoke the method Configurable.configure(Conf) with the given Conf. For a shared object, the method will be invoked only the first time it is returned.
        Type Parameters:
        T - the component-type.
        Parameters:
        type - the fully qualified class name or an alias of the component.
        conf - the configuration used if the component implement Configurable.
        qualifier - the options used to qualify the component.
        Returns:
        the instance of type ComponentFactory.
        Throws:
        NoUniqueComponentException - if more than one component is registered for the given type.
        NoSuchComponentException - if no component is registered for the given class or alias..
      • getAllComponents

        <T> Collection<T> getAllComponents​(String type,
                                           Conf conf)
        Gets all instances, which may be shared or independent, for the specified type. If one of the objects, returned from that method, implements the Configurable interface, then the factory will invoke the method Configurable.configure(Conf) with the given Conf. For a shared object, the method will be invoked only the first time it is returned.
        Type Parameters:
        T - the component-type.
        Parameters:
        type - the fully qualified class name or an alias of the component.
        conf - the configuration used if the component implement Configurable.
        Returns:
        all instances of type ComponentFactory.
      • getAllComponents

        <T> Collection<T> getAllComponents​(String type,
                                           Conf conf,
                                           Qualifier<T> qualifier)
        Gets all instances, which may be shared or independent, for the specified type. If one of the objects, returned from that method, implements the Configurable interface, then the factory will invoke the method Configurable.configure(Conf) with the given Conf. For a shared object, the method will be invoked only the first time it is returned.
        Type Parameters:
        T - the component-type.
        Parameters:
        type - the fully qualified class name or an alias of the component.
        conf - the configuration used if the component implement Configurable.
        qualifier - the options used to qualify the component.
        Returns:
        all instances of type ComponentFactory.
      • getAllComponents

        <T> Collection<T> getAllComponents​(Class<T> type,
                                           Conf conf)
        Gets all instances, which may be shared or independent, for the specified type. If one of the objects, returned from that method, implements the Configurable interface, then the factory will invoke the method Configurable.configure(Conf) with the given Conf. For a shared object, the method will be invoked only the first time it is returned.
        Type Parameters:
        T - the component-type.
        Parameters:
        type - the component class.
        conf - the configuration used if the component implement Configurable.
        Returns:
        all instances of type ComponentFactory.
      • getAllComponents

        <T> Collection<T> getAllComponents​(Class<T> type,
                                           Conf conf,
                                           Qualifier<T> qualifier)
        Gets all instances, which may be shared or independent, for the specified type. If one of the objects, returned from that method, implements the Configurable interface, then the factory will invoke the method Configurable.configure(Conf) with the given Conf. For a shared object, the method will be invoked only the first time it is returned.
        Type Parameters:
        T - the component-type.
        Parameters:
        type - the component class.
        conf - the configuration used if the component implement Configurable.
        conf - the Conf that may be used to match components Condition.
        qualifier - the options used to qualify the component.
        Returns:
        all instances of type ComponentFactory.
      • getAllComponentProviders

        <T> Collection<GettableComponent<T>> getAllComponentProviders​(Class<T> type,
                                                                      Qualifier<T> qualifier)
        Gets all instances, which may be shared or independent, for the specified type.
        Type Parameters:
        T - the component-type.
        Parameters:
        type - the component class.
        qualifier - the options used to qualify the component.
        Returns:
        all instances of type ComponentFactory.
      • init

        void init​(Conf conf)
        Initialize the component factory for the given configuration.
        Parameters:
        conf - the configuration.
      • loadAllServices

        default <T> List<T> loadAllServices​(Class<T> type)
        Loads all services for the given type using the standard Java ServiceLoader mechanism.
        Type Parameters:
        T - the service type.
        Parameters:
        type - the service Class type.
        Returns:
        the services implementing the given type.