Interface ComponentRegistry
-
- All Superinterfaces:
AutoCloseable
,Closeable
- All Known Implementing Classes:
DefaultComponentRegistry
public interface ComponentRegistry extends Closeable
TheComponentRegistry
is the main interface for managing components used in an Azkarra application.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description <T> Collection<ComponentDescriptor<T>>
findAllDescriptorByAlias(String alias)
Finds aComponentDescriptor
for the specified class or alias.<T> Collection<ComponentDescriptor<T>>
findAllDescriptorsByType(Class<T> type)
Finds all registered providers for the specified type.<T> Optional<ComponentDescriptor<T>>
findDescriptorByAlias(String alias)
Finds aComponentDescriptor
for the specified class or alias.<T> Optional<ComponentDescriptor<T>>
findLatestDescriptorByAlias(String alias)
Finds aComponentDescriptor
for the specified class or alias.<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(String alias, Conf conf)
Gets all instances, which may be shared or independent, for the specified type.<T> T
getComponent(Class<T> type, Conf conf)
Gets an instance, which may be shared or independent, for the specified type.<T> T
getComponent(String alias, Conf conf)
Gets an instance, which may be shared or independent, for the specified type.<T> T
getLatestComponent(Class<T> type, Conf conf)
Gets an instance, which may be shared or independent, for the specified type.<T> T
getLatestComponent(String alias, Conf conf)
Gets an instance, which may be shared or independent, for the specified type.<T> T
getVersionedComponent(String alias, String version, Conf conf)
Gets an instance, which may be shared or independent, for the specified type.boolean
isRegistered(String alias)
Checks whether the specified components class or alias is already registered.<T> void
registerComponent(ComponentDescriptor<T> descriptor)
Registers the specifiedComponentDescriptor
to thisComponentRegistry
.<T> void
registerComponent(ComponentDescriptor<T> descriptor, ComponentFactory<T> factory)
Registers the specifiedComponentDescriptor
to thisComponentRegistry
.ComponentRegistry
setComponentAliasesGenerator(ComponentAliasesGenerator generator)
Sets theComponentAliasesGenerator
instance.
-
-
-
Method Detail
-
isRegistered
boolean isRegistered(String alias)
Checks whether the specified components class or alias is already registered.- Parameters:
alias
- the fully qualified class name or an alias of the component.- Returns:
true
if a provider exist, {code false} otherwise.
-
findDescriptorByAlias
<T> Optional<ComponentDescriptor<T>> findDescriptorByAlias(String alias)
Finds aComponentDescriptor
for the specified class or alias.- Type Parameters:
T
- the component type.- Parameters:
alias
- the fully qualified class name or an alias of the component.- Returns:
- the optional
ComponentDescriptor
instance. - Throws:
NoUniqueComponentException
- if more than one component is registered for the given type.
-
findLatestDescriptorByAlias
<T> Optional<ComponentDescriptor<T>> findLatestDescriptorByAlias(String alias)
Finds aComponentDescriptor
for the specified class or alias. If more than one component is registered for the given alias, the latest version is returned.- Type Parameters:
T
- the component type.- Parameters:
alias
- the fully qualified class name or an alias of the component.- Returns:
- the optional
ComponentDescriptor
instance.
-
findAllDescriptorByAlias
<T> Collection<ComponentDescriptor<T>> findAllDescriptorByAlias(String alias)
Finds aComponentDescriptor
for the specified class or alias.- Type Parameters:
T
- the component type.- Parameters:
alias
- the fully qualified class name or an alias of the component.- Returns:
- the optional
ComponentDescriptor
instance.
-
findAllDescriptorsByType
<T> Collection<ComponentDescriptor<T>> findAllDescriptorsByType(Class<T> type)
Finds all registered providers for the specified type.- Type Parameters:
T
- the component type.- Parameters:
type
- the component class.- Returns:
- the collection of
ComponentDescriptor
.
-
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 implementConfigurable
.- Returns:
- the instance of type
ComponentRegistry
. - Throws:
NoUniqueComponentException
- if more than one component is registered for the given type.NoSuchComponentException
- if no component is registered for the given type.
-
getLatestComponent
<T> T getLatestComponent(Class<T> type, Conf conf)
Gets an instance, which may be shared or independent, for the specified type. If more than one component is registered for the given type, the latest version is returned.- Type Parameters:
T
- the component-type.- Parameters:
type
- the component class.conf
- the configuration used if the component implementConfigurable
.- Returns:
- the instance of type
ComponentRegistry
. - Throws:
NoSuchComponentException
- if no component is registered for the given type.
-
getComponent
<T> T getComponent(String alias, Conf conf)
Gets an instance, which may be shared or independent, for the specified type.- Type Parameters:
T
- the component-type.- Parameters:
alias
- the fully qualified class name or an alias of the component.conf
- the configuration used if the component implementConfigurable
.- Returns:
- the instance of type
ComponentRegistry
. - 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..
-
getLatestComponent
<T> T getLatestComponent(String alias, Conf conf)
Gets an instance, which may be shared or independent, for the specified type. If more than one component is registered for the given type, the latest version is returned.- Type Parameters:
T
- the component-type.- Parameters:
alias
- the fully qualified class name or an alias of the component.conf
- the configuration used if the component implementConfigurable
.- Returns:
- the instance of type
ComponentRegistry
. - Throws:
NoSuchComponentException
- if no component is registered for the given type.
-
getVersionedComponent
<T> T getVersionedComponent(String alias, String version, Conf conf)
Gets an instance, which may be shared or independent, for the specified type. If more than one component is registered for the given type, the latest version is returned.- Type Parameters:
T
- the component-type.- Parameters:
alias
- the fully qualified class name or an alias of the component.conf
- the configuration used if the component implementConfigurable
.- Returns:
- the instance of type
ComponentRegistry
. - Throws:
NoSuchComponentException
- if no component is registered for the given type.
-
getAllComponents
<T> Collection<T> getAllComponents(String alias, Conf conf)
Gets all instances, which may be shared or independent, for the specified type.- Type Parameters:
T
- the component-type.- Parameters:
alias
- the fully qualified class name or an alias of the component.conf
- the configuration used if the component implementConfigurable
.- Returns:
- the instance of type
ComponentRegistry
. - 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(Class<T> type, Conf conf)
Gets all instances, 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 implementConfigurable
.- Returns:
- the instance of type
ComponentRegistry
.
-
registerComponent
<T> void registerComponent(ComponentDescriptor<T> descriptor)
Registers the specifiedComponentDescriptor
to thisComponentRegistry
.- Type Parameters:
T
- the component type.- Parameters:
descriptor
- theComponentDescriptor
instance to be registered.
-
registerComponent
<T> void registerComponent(ComponentDescriptor<T> descriptor, ComponentFactory<T> factory)
Registers the specifiedComponentDescriptor
to thisComponentRegistry
.- Type Parameters:
T
- the component type.- Parameters:
descriptor
- theComponentDescriptor
instance to be registered.factory
- theComponentFactory
instance.
-
setComponentAliasesGenerator
ComponentRegistry setComponentAliasesGenerator(ComponentAliasesGenerator generator)
Sets theComponentAliasesGenerator
instance.- Parameters:
generator
- theComponentAliasesGenerator
used for generating provider aliases.
-
-