Class AbstractComponentRegistry<R extends AbstractComponentRegistry<R>>
- All Implemented Interfaces:
ComponentRegistry<R>
- Direct Known Subclasses:
DefaultComponentRegistry
ComponentRegistry
used for storing and retrieving
Components
.
This registry is typically configured as a bean during the auto-configuration of a Spring Boot
application. In most cases, the initialize(List, List)
method will be called shortly
after instantiation to initialize the registry using a set of ComponentSource
and
FrameworkComponentSource
beans. FrameworkComponentSource
beans will be processed
prior to the ComponentSource
beans, which allows ComponentSource
beans to
potentially extend or modify the framework components.
Once the registry has been initialized by the component sources, the initialization will make a
call to validateRegistry()
in order to validate each and every component within the
registry using ComponentValidatorManager
. If isFailOnValidationError()
is true,
this will cause an IllegalStateException
to be thrown.
- Author:
- Nick Crum (ncrum)
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddComponent
(String id, Component<?> component) Component<?>
<T extends Component<T>>
TComponent<?>
getComponent
(String id) <T extends Component<T>>
TgetComponent
(String id, Class<T> clazz) boolean
boolean
hasComponent
(String id) void
initialize
(List<FrameworkComponentSource> frameworkComponentSources, List<ComponentSource> componentSources) Primary method of initializing the registry with components.boolean
protected R
self()
void
setFailOnValidationError
(boolean failOnValidationError) void
Validates each component within the registry using theComponentValidatorManager
.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.broadleafcommerce.metadata.dsl.registry.ComponentRegistry
reRegisterComponents
-
Constructor Details
-
AbstractComponentRegistry
-
-
Method Details
-
initialize
public void initialize(@Nullable List<FrameworkComponentSource> frameworkComponentSources, @Nullable List<ComponentSource> componentSources) Primary method of initializing the registry with components.First, the list of
FrameworkComponentSource
will be used to register any frameworkComponents
. Second, the list ofComponentSource
will be used to register new components and extend any framework components. Lastly, theComponentValidatorManager
will be used invalidateRegistry()
to validate every the components within the registry.- Parameters:
frameworkComponentSources
- the list of sources of framework componentscomponentSources
- the list of sources of components
-
validateRegistry
public void validateRegistry()Validates each component within the registry using theComponentValidatorManager
.If
isFailOnValidationError()
is set to true, then any validation errors will cause anIllegalStateException
to be thrown. If it is set to false, then no exception will be thrown, but debug logging may still occur within theComponentValidatorManager
. -
self
-
addComponent
- Specified by:
addComponent
in interfaceComponentRegistry<R extends AbstractComponentRegistry<R>>
-
add
- Specified by:
add
in interfaceComponentRegistry<R extends AbstractComponentRegistry<R>>
-
add
- Specified by:
add
in interfaceComponentRegistry<R extends AbstractComponentRegistry<R>>
-
removeComponent
- Specified by:
removeComponent
in interfaceComponentRegistry<R extends AbstractComponentRegistry<R>>
-
remove
- Specified by:
remove
in interfaceComponentRegistry<R extends AbstractComponentRegistry<R>>
-
hasComponent
- Specified by:
hasComponent
in interfaceComponentRegistry<R extends AbstractComponentRegistry<R>>
-
has
- Specified by:
has
in interfaceComponentRegistry<R extends AbstractComponentRegistry<R>>
-
getComponent
- Specified by:
getComponent
in interfaceComponentRegistry<R extends AbstractComponentRegistry<R>>
-
getComponent
- Specified by:
getComponent
in interfaceComponentRegistry<R extends AbstractComponentRegistry<R>>
-
get
- Specified by:
get
in interfaceComponentRegistry<R extends AbstractComponentRegistry<R>>
-
get
- Specified by:
get
in interfaceComponentRegistry<R extends AbstractComponentRegistry<R>>
-
getValidatorManager
-
getComponents
- Specified by:
getComponents
in interfaceComponentRegistry<R extends AbstractComponentRegistry<R>>
-
isFailOnValidationError
public boolean isFailOnValidationError() -
setFailOnValidationError
public void setFailOnValidationError(boolean failOnValidationError)
-