Class DelegatingComponentFactory
- java.lang.Object
-
- io.streamthoughts.azkarra.api.components.DelegatingComponentFactory
-
- All Implemented Interfaces:
ComponentDescriptorRegistry,ComponentFactory,ComponentRegistry,ConditionalDescriptorRegistry,Closeable,AutoCloseable
- Direct Known Subclasses:
ContextAwareComponentFactory
public class DelegatingComponentFactory extends Object implements ComponentFactory
A delegatingComponentFactoryimplementation.
-
-
Field Summary
Fields Modifier and Type Field Description protected ComponentFactoryfactory
-
Constructor Summary
Constructors Modifier Constructor Description protectedDelegatingComponentFactory(ComponentFactory factory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()<T> booleancontainsComponent(Class<T> type)Checks if at least one component is registered for the given type.<T> booleancontainsComponent(Class<T> type, Qualifier<T> qualifier)Checks if at least one component is registered for the given type and qualifier.booleancontainsComponent(String type)Checks if at least one component is registered for the given type.<T> booleancontainsComponent(String type, Qualifier<T> qualifier)Checks if at least one component is registered for the given type and qualifier.<T> Collection<ComponentDescriptor<T>>findAllDescriptorsByAlias(String alias)Finds allComponentDescriptorregistered for the specified alias.<T> Collection<ComponentDescriptor<T>>findAllDescriptorsByAlias(String alias, ComponentConditionalContext context)Finds allComponentDescriptorregistered for the specified alias.<T> Collection<ComponentDescriptor<T>>findAllDescriptorsByAlias(String alias, ComponentConditionalContext context, Qualifier<T> qualifier)Finds allComponentDescriptorregistered for the specified alias.<T> Collection<ComponentDescriptor<T>>findAllDescriptorsByAlias(String alias, Qualifier<T> qualifier)Finds allComponentDescriptorregistered for the specified alias.<T> Collection<ComponentDescriptor<T>>findAllDescriptorsByClass(Class<T> type)Finds allComponentDescriptorregistered for the specified type.<T> Collection<ComponentDescriptor<T>>findAllDescriptorsByClass(Class<T> type, ComponentConditionalContext context)Finds allComponentDescriptorregistered for the specified type.<T> Collection<ComponentDescriptor<T>>findAllDescriptorsByClass(Class<T> type, ComponentConditionalContext context, Qualifier<T> qualifier)Finds allComponentDescriptorregistered for the specified type.<T> Collection<ComponentDescriptor<T>>findAllDescriptorsByClass(Class<T> type, Qualifier<T> qualifier)Finds allComponentDescriptorregistered for the specified type.<T> Optional<ComponentDescriptor<T>>findDescriptorByAlias(String alias)Finds aComponentDescriptorfor the specified type.<T> Optional<ComponentDescriptor<T>>findDescriptorByAlias(String alias, ComponentConditionalContext context)Finds aComponentDescriptorfor the specified type.<T> Optional<ComponentDescriptor<T>>findDescriptorByAlias(String alias, ComponentConditionalContext context, Qualifier<T> qualifier)Finds aComponentDescriptorfor the specified type and options.<T> Optional<ComponentDescriptor<T>>findDescriptorByAlias(String alias, Qualifier<T> qualifier)Finds aComponentDescriptorfor the specified type and options.<T> Optional<ComponentDescriptor<T>>findDescriptorByClass(Class<T> type)Finds aComponentDescriptorfor the specified type.<T> Optional<ComponentDescriptor<T>>findDescriptorByClass(Class<T> type, ComponentConditionalContext context)Finds aComponentDescriptorfor the specified type.<T> Optional<ComponentDescriptor<T>>findDescriptorByClass(Class<T> type, ComponentConditionalContext context, Qualifier<T> qualifier)Finds aComponentDescriptorfor the specified type and options.<T> Optional<ComponentDescriptor<T>>findDescriptorByClass(Class<T> type, Qualifier<T> qualifier)Finds aComponentDescriptorfor the specified type and options.<T> Collection<GettableComponent<T>>getAllComponentProviders(Class<T> type, Qualifier<T> qualifier)Gets all instances, which may be shared or independent, for the specified type.<T> Collection<T>getAllComponents(Class<T> type, Conf conf)Gets all instances, which may be shared or independent, for the specified type.<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.<T> Collection<T>getAllComponents(String type, Conf conf)Gets all instances, which may be shared or independent, for the specified type.<T> Collection<T>getAllComponents(String type, Conf conf, Qualifier<T> qualifier)Gets all instances, which may be shared or independent, for the specified type.<T> TgetComponent(Class<T> type, Conf conf)Gets an instance, which may be shared or independent, for the specified type.<T> TgetComponent(Class<T> type, Conf conf, Qualifier<T> qualifier)Gets an instance, which may be shared or independent, for the specified type.<T> TgetComponent(String type, Conf conf)Gets an instance, which may be shared or independent, for the specified type.<T> TgetComponent(String type, Conf conf, Qualifier<T> qualifier)Gets an instance, which may be shared or independent, for the specified type.<T> GettableComponent<T>getComponentProvider(Class<T> type, Qualifier<T> qualifier)Gets an instance, which may be shared or independent, for the specified type.voidinit(Conf conf)Initialize the component factory for the given configuration.<T> voidregisterComponent(String componentName, Class<T> componentClass, ComponentDescriptorModifier... modifiers)Registers the component supplier for the specified type and name.<T> voidregisterComponent(String componentName, Class<T> componentClass, Supplier<T> supplier, ComponentDescriptorModifier... modifiers)Registers the component supplier for the specified type and name.<T> voidregisterDescriptor(ComponentDescriptor<T> descriptor)Registers the specifiedComponentDescriptorto thisComponentRegistry.<T> voidregisterSingleton(String componentName, Class<T> componentClass, ComponentDescriptorModifier... modifiers)Registers a singleton no-arg constructor component supplier for the specified type.<T> voidregisterSingleton(String componentName, Class<T> componentClass, Supplier<T> singleton, ComponentDescriptorModifier... modifiers)Registers the component supplier for the specified type and name.<T> voidregisterSingleton(T singleton)Register the specified shared instance.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.streamthoughts.azkarra.api.components.ComponentRegistry
registerComponent, registerComponent, registerSingleton, registerSingleton
-
-
-
-
Field Detail
-
factory
protected final ComponentFactory factory
-
-
Constructor Detail
-
DelegatingComponentFactory
protected DelegatingComponentFactory(ComponentFactory factory)
-
-
Method Detail
-
containsComponent
public boolean containsComponent(String type)
Description copied from interface:ComponentFactoryChecks if at least one component is registered for the given type.- Specified by:
containsComponentin interfaceComponentFactory- Parameters:
type- the fully qualified class name or an alias of the component.- Returns:
trueif a provider exist,falseotherwise.
-
containsComponent
public <T> boolean containsComponent(String type, Qualifier<T> qualifier)
Description copied from interface:ComponentFactoryChecks if at least one component is registered for the given type and qualifier.- Specified by:
containsComponentin interfaceComponentFactory- Parameters:
type- the component type.qualifier- the options to qualified the component.- Returns:
trueif a provider exist,falseotherwise.
-
containsComponent
public <T> boolean containsComponent(Class<T> type)
Description copied from interface:ComponentFactoryChecks if at least one component is registered for the given type.- Specified by:
containsComponentin interfaceComponentFactory- Parameters:
type- the component type.- Returns:
trueif a provider exist,falseotherwise.
-
containsComponent
public <T> boolean containsComponent(Class<T> type, Qualifier<T> qualifier)
Description copied from interface:ComponentFactoryChecks if at least one component is registered for the given type and qualifier.- Specified by:
containsComponentin interfaceComponentFactory- Parameters:
type- the component type.qualifier- the options to qualified the component.- Returns:
trueif a provider exist,falseotherwise.
-
getComponent
public <T> T getComponent(Class<T> type, Conf conf)
Description copied from interface:ComponentFactoryGets an instance, which may be shared or independent, for the specified type.- Specified by:
getComponentin interfaceComponentFactory- Type Parameters:
T- the component-type.- Parameters:
type- the component class.conf- the configuration used if the component implementConfigurable.- Returns:
- the instance of type
ComponentFactory.
-
getComponent
public <T> T getComponent(Class<T> type, Conf conf, Qualifier<T> qualifier)
Description copied from interface:ComponentFactoryGets an instance, which may be shared or independent, for the specified type.- Specified by:
getComponentin interfaceComponentFactory- Type Parameters:
T- the component-type.- Parameters:
type- the component class.conf- the configuration used if the component implementConfigurable.qualifier- the options used to qualify the component.- Returns:
- the instance of type
ComponentFactory.
-
getComponentProvider
public <T> GettableComponent<T> getComponentProvider(Class<T> type, Qualifier<T> qualifier)
Description copied from interface:ComponentFactoryGets an instance, which may be shared or independent, for the specified type.- Specified by:
getComponentProviderin interfaceComponentFactory- 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.
-
getComponent
public <T> T getComponent(String type, Conf conf)
Description copied from interface:ComponentFactoryGets an instance, which may be shared or independent, for the specified type. If the object, returned from that method, implements theConfigurableinterface, then the factory will invoke the methodConfigurable.configure(Conf)with the givenConf. For a shared object, the method will be invoked only the first time it is returned.- Specified by:
getComponentin interfaceComponentFactory- 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 implementConfigurable.- Returns:
- the instance of type
ComponentFactory.
-
getComponent
public <T> T getComponent(String type, Conf conf, Qualifier<T> qualifier)
Description copied from interface:ComponentFactoryGets an instance, which may be shared or independent, for the specified type. If the object, returned from that method, implements theConfigurableinterface, then the factory will invoke the methodConfigurable.configure(Conf)with the givenConf. For a shared object, the method will be invoked only the first time it is returned.- Specified by:
getComponentin interfaceComponentFactory- 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 implementConfigurable.qualifier- the options used to qualify the component.- Returns:
- the instance of type
ComponentFactory.
-
getAllComponents
public <T> Collection<T> getAllComponents(String type, Conf conf)
Description copied from interface:ComponentFactoryGets all instances, which may be shared or independent, for the specified type. If one of the objects, returned from that method, implements theConfigurableinterface, then the factory will invoke the methodConfigurable.configure(Conf)with the givenConf. For a shared object, the method will be invoked only the first time it is returned.- Specified by:
getAllComponentsin interfaceComponentFactory- 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 implementConfigurable.- Returns:
- all instances of type
ComponentFactory.
-
getAllComponents
public <T> Collection<T> getAllComponents(String type, Conf conf, Qualifier<T> qualifier)
Description copied from interface:ComponentFactoryGets all instances, which may be shared or independent, for the specified type. If one of the objects, returned from that method, implements theConfigurableinterface, then the factory will invoke the methodConfigurable.configure(Conf)with the givenConf. For a shared object, the method will be invoked only the first time it is returned.- Specified by:
getAllComponentsin interfaceComponentFactory- 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 implementConfigurable.qualifier- the options used to qualify the component.- Returns:
- all instances of type
ComponentFactory.
-
getAllComponents
public <T> Collection<T> getAllComponents(Class<T> type, Conf conf)
Description copied from interface:ComponentFactoryGets all instances, which may be shared or independent, for the specified type. If one of the objects, returned from that method, implements theConfigurableinterface, then the factory will invoke the methodConfigurable.configure(Conf)with the givenConf. For a shared object, the method will be invoked only the first time it is returned.- Specified by:
getAllComponentsin interfaceComponentFactory- Type Parameters:
T- the component-type.- Parameters:
type- the component class.conf- the configuration used if the component implementConfigurable.- Returns:
- all instances of type
ComponentFactory.
-
getAllComponents
public <T> Collection<T> getAllComponents(Class<T> type, Conf conf, Qualifier<T> qualifier)
Description copied from interface:ComponentFactoryGets all instances, which may be shared or independent, for the specified type. If one of the objects, returned from that method, implements theConfigurableinterface, then the factory will invoke the methodConfigurable.configure(Conf)with the givenConf. For a shared object, the method will be invoked only the first time it is returned.- Specified by:
getAllComponentsin interfaceComponentFactory- Type Parameters:
T- the component-type.- Parameters:
type- the component class.conf- the configuration used if the component implementConfigurable.qualifier- the options used to qualify the component.- Returns:
- all instances of type
ComponentFactory.
-
getAllComponentProviders
public <T> Collection<GettableComponent<T>> getAllComponentProviders(Class<T> type, Qualifier<T> qualifier)
Description copied from interface:ComponentFactoryGets all instances, which may be shared or independent, for the specified type.- Specified by:
getAllComponentProvidersin interfaceComponentFactory- 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
public void init(Conf conf)
Description copied from interface:ComponentFactoryInitialize the component factory for the given configuration.- Specified by:
initin interfaceComponentFactory- Parameters:
conf- the configuration.
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceComponentFactory- Throws:
IOException
-
findAllDescriptorsByClass
public <T> Collection<ComponentDescriptor<T>> findAllDescriptorsByClass(Class<T> type)
Description copied from interface:ComponentDescriptorRegistryFinds allComponentDescriptorregistered for the specified type.- Specified by:
findAllDescriptorsByClassin interfaceComponentDescriptorRegistry- Type Parameters:
T- the component type.- Parameters:
type- the component class.- Returns:
- the collection of
ComponentDescriptor.
-
findAllDescriptorsByClass
public <T> Collection<ComponentDescriptor<T>> findAllDescriptorsByClass(Class<T> type, Qualifier<T> qualifier)
Description copied from interface:ComponentDescriptorRegistryFinds allComponentDescriptorregistered for the specified type.- Specified by:
findAllDescriptorsByClassin interfaceComponentDescriptorRegistry- Type Parameters:
T- the component type.- Parameters:
type- the component class.- Returns:
- the collection of
ComponentDescriptor.
-
findAllDescriptorsByAlias
public <T> Collection<ComponentDescriptor<T>> findAllDescriptorsByAlias(String alias)
Description copied from interface:ComponentDescriptorRegistryFinds allComponentDescriptorregistered for the specified alias.- Specified by:
findAllDescriptorsByAliasin interfaceComponentDescriptorRegistry- Type Parameters:
T- the component type.- Parameters:
alias- the fully qualified class name or an alias of the component.- Returns:
- the collection of
ComponentDescriptor.
-
findAllDescriptorsByAlias
public <T> Collection<ComponentDescriptor<T>> findAllDescriptorsByAlias(String alias, Qualifier<T> qualifier)
Description copied from interface:ComponentDescriptorRegistryFinds allComponentDescriptorregistered for the specified alias.- Specified by:
findAllDescriptorsByAliasin interfaceComponentDescriptorRegistry- Type Parameters:
T- the component type.- Parameters:
alias- the fully qualified class name or an alias of the component.- Returns:
- the collection of
ComponentDescriptor.
-
findDescriptorByAlias
public <T> Optional<ComponentDescriptor<T>> findDescriptorByAlias(String alias)
Description copied from interface:ComponentDescriptorRegistryFinds aComponentDescriptorfor the specified type.- Specified by:
findDescriptorByAliasin interfaceComponentDescriptorRegistry- Type Parameters:
T- the component type.- Parameters:
alias- the fully qualified class name or an alias of the component.- Returns:
- the optional
ComponentDescriptorinstance.
-
findDescriptorByAlias
public <T> Optional<ComponentDescriptor<T>> findDescriptorByAlias(String alias, Qualifier<T> qualifier)
Description copied from interface:ComponentDescriptorRegistryFinds aComponentDescriptorfor the specified type and options.- Specified by:
findDescriptorByAliasin interfaceComponentDescriptorRegistry- Type Parameters:
T- the component type.- Parameters:
alias- the fully qualified class name or an alias of the component.qualifier- the options used to qualified the component.- Returns:
- the optional
ComponentDescriptorinstance.
-
findDescriptorByClass
public <T> Optional<ComponentDescriptor<T>> findDescriptorByClass(Class<T> type)
Description copied from interface:ComponentDescriptorRegistryFinds aComponentDescriptorfor the specified type.- Specified by:
findDescriptorByClassin interfaceComponentDescriptorRegistry- Type Parameters:
T- the component type.- Parameters:
type- the component class.- Returns:
- the optional
ComponentDescriptorinstance.
-
findDescriptorByClass
public <T> Optional<ComponentDescriptor<T>> findDescriptorByClass(Class<T> type, Qualifier<T> qualifier)
Description copied from interface:ComponentDescriptorRegistryFinds aComponentDescriptorfor the specified type and options.- Specified by:
findDescriptorByClassin interfaceComponentDescriptorRegistry- Type Parameters:
T- the component type.- Parameters:
type- the fully qualified class name or an alias of the component.qualifier- the options used to qualified the component.- Returns:
- the optional
ComponentDescriptorinstance.
-
registerDescriptor
public <T> void registerDescriptor(ComponentDescriptor<T> descriptor)
Description copied from interface:ComponentDescriptorRegistryRegisters the specifiedComponentDescriptorto thisComponentRegistry.- Specified by:
registerDescriptorin interfaceComponentDescriptorRegistry- Type Parameters:
T- the component type.- Parameters:
descriptor- theComponentDescriptorinstance to be registered.
-
registerComponent
public <T> void registerComponent(String componentName, Class<T> componentClass, Supplier<T> supplier, ComponentDescriptorModifier... modifiers)
Description copied from interface:ComponentRegistryRegisters the component supplier for the specified type and name.- Specified by:
registerComponentin interfaceComponentRegistry- Type Parameters:
T- the component-type.- Parameters:
componentName- the name of the component.componentClass- the class-type of the component.supplier- the supplier of the component.modifiers- the component descriptor modifiers.
-
registerComponent
public <T> void registerComponent(String componentName, Class<T> componentClass, ComponentDescriptorModifier... modifiers)
Description copied from interface:ComponentRegistryRegisters the component supplier for the specified type and name.- Specified by:
registerComponentin interfaceComponentRegistry- Type Parameters:
T- the component-type.- Parameters:
componentName- the name of the component.componentClass- the class-type of the component.
-
registerSingleton
public <T> void registerSingleton(String componentName, Class<T> componentClass, Supplier<T> singleton, ComponentDescriptorModifier... modifiers)
Description copied from interface:ComponentRegistryRegisters the component supplier for the specified type and name. The given supplier will be used for creating a shared instance of typeComponentRegistry.- Specified by:
registerSingletonin interfaceComponentRegistry- Type Parameters:
T- the component-type.- Parameters:
componentName- the name of the component.componentClass- the class-type of the component.singleton- the supplier of the component.
-
registerSingleton
public <T> void registerSingleton(String componentName, Class<T> componentClass, ComponentDescriptorModifier... modifiers)
Description copied from interface:ComponentRegistryRegisters a singleton no-arg constructor component supplier for the specified type.- Specified by:
registerSingletonin interfaceComponentRegistry- Type Parameters:
T- the component-type.- Parameters:
componentName- the name of the component.componentClass- the class-type of the component.
-
registerSingleton
public <T> void registerSingleton(T singleton)
Description copied from interface:ComponentRegistryRegister the specified shared instance.- Specified by:
registerSingletonin interfaceComponentRegistry- Type Parameters:
T- the component-type.- Parameters:
singleton- the singleton component instance.
-
findAllDescriptorsByClass
public <T> Collection<ComponentDescriptor<T>> findAllDescriptorsByClass(Class<T> type, ComponentConditionalContext context)
Description copied from interface:ConditionalDescriptorRegistryFinds allComponentDescriptorregistered for the specified type.- Specified by:
findAllDescriptorsByClassin interfaceConditionalDescriptorRegistry- Type Parameters:
T- the component type.- Parameters:
type- the component class.- Returns:
- the collection of
ComponentDescriptor.
-
findAllDescriptorsByClass
public <T> Collection<ComponentDescriptor<T>> findAllDescriptorsByClass(Class<T> type, ComponentConditionalContext context, Qualifier<T> qualifier)
Description copied from interface:ConditionalDescriptorRegistryFinds allComponentDescriptorregistered for the specified type.- Specified by:
findAllDescriptorsByClassin interfaceConditionalDescriptorRegistry- Type Parameters:
T- the component type.- Parameters:
type- the component class.- Returns:
- the collection of
ComponentDescriptor.
-
findAllDescriptorsByAlias
public <T> Collection<ComponentDescriptor<T>> findAllDescriptorsByAlias(String alias, ComponentConditionalContext context)
Description copied from interface:ConditionalDescriptorRegistryFinds allComponentDescriptorregistered for the specified alias.- Specified by:
findAllDescriptorsByAliasin interfaceConditionalDescriptorRegistry- Type Parameters:
T- the component type.- Parameters:
alias- the fully qualified class name or an alias of the component.- Returns:
- the collection of
ComponentDescriptor.
-
findAllDescriptorsByAlias
public <T> Collection<ComponentDescriptor<T>> findAllDescriptorsByAlias(String alias, ComponentConditionalContext context, Qualifier<T> qualifier)
Description copied from interface:ConditionalDescriptorRegistryFinds allComponentDescriptorregistered for the specified alias.- Specified by:
findAllDescriptorsByAliasin interfaceConditionalDescriptorRegistry- Type Parameters:
T- the component type.- Parameters:
alias- the fully qualified class name or an alias of the component.- Returns:
- the collection of
ComponentDescriptor.
-
findDescriptorByAlias
public <T> Optional<ComponentDescriptor<T>> findDescriptorByAlias(String alias, ComponentConditionalContext context)
Description copied from interface:ConditionalDescriptorRegistryFinds aComponentDescriptorfor the specified type.- Specified by:
findDescriptorByAliasin interfaceConditionalDescriptorRegistry- Type Parameters:
T- the component type.- Parameters:
alias- the fully qualified class name or an alias of the component.- Returns:
- the optional
ComponentDescriptorinstance.
-
findDescriptorByAlias
public <T> Optional<ComponentDescriptor<T>> findDescriptorByAlias(String alias, ComponentConditionalContext context, Qualifier<T> qualifier)
Description copied from interface:ConditionalDescriptorRegistryFinds aComponentDescriptorfor the specified type and options.- Specified by:
findDescriptorByAliasin interfaceConditionalDescriptorRegistry- Type Parameters:
T- the component type.- Parameters:
alias- the fully qualified class name or an alias of the component.qualifier- the options used to qualified the component.- Returns:
- the optional
ComponentDescriptorinstance.
-
findDescriptorByClass
public <T> Optional<ComponentDescriptor<T>> findDescriptorByClass(Class<T> type, ComponentConditionalContext context)
Description copied from interface:ConditionalDescriptorRegistryFinds aComponentDescriptorfor the specified type.- Specified by:
findDescriptorByClassin interfaceConditionalDescriptorRegistry- Type Parameters:
T- the component type.- Parameters:
type- the component class.- Returns:
- the optional
ComponentDescriptorinstance.
-
findDescriptorByClass
public <T> Optional<ComponentDescriptor<T>> findDescriptorByClass(Class<T> type, ComponentConditionalContext context, Qualifier<T> qualifier)
Description copied from interface:ConditionalDescriptorRegistryFinds aComponentDescriptorfor the specified type and options.- Specified by:
findDescriptorByClassin interfaceConditionalDescriptorRegistry- Type Parameters:
T- the component type.- Parameters:
type- the fully qualified class name or an alias of the component.qualifier- the options used to qualified the component.- Returns:
- the optional
ComponentDescriptorinstance.
-
-