Class AbstractComponentRegistry<R extends AbstractComponentRegistry<R>>
- java.lang.Object
-
- com.broadleafcommerce.metadata.dsl.registry.AbstractComponentRegistry<R>
-
- All Implemented Interfaces:
ComponentRegistry<R>
- Direct Known Subclasses:
DefaultComponentRegistry
public abstract class AbstractComponentRegistry<R extends AbstractComponentRegistry<R>> extends Object implements ComponentRegistry<R>
An abstract implementation ofComponentRegistry
used for storing and retrievingComponents
.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 ofComponentSource
andFrameworkComponentSource
beans.FrameworkComponentSource
beans will be processed prior to theComponentSource
beans, which allowsComponentSource
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 usingComponentValidatorManager
. IfisFailOnValidationError()
is true, this will cause anIllegalStateException
to be thrown.- Author:
- Nick Crum (ncrum)
-
-
Constructor Summary
Constructors Constructor Description AbstractComponentRegistry(ComponentValidatorManager validatorManager)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description R
add(Component<?> component)
R
add(String id, Component<?> component)
R
addComponent(String id, Component<?> component)
Component<?>
get(String id)
<T extends Component<T>>
Tget(String key, Class<T> clazz)
Component<?>
getComponent(String id)
<T extends Component<T>>
TgetComponent(String id, Class<T> clazz)
Map<String,Component<?>>
getComponents()
ComponentValidatorManager
getValidatorManager()
boolean
has(String id)
boolean
hasComponent(String id)
void
initialize(List<FrameworkComponentSource> frameworkComponentSources, List<ComponentSource> componentSources)
Primary method of initializing the registry with components.boolean
isFailOnValidationError()
R
remove(String id)
R
removeComponent(String id)
protected R
self()
void
setFailOnValidationError(boolean failOnValidationError)
void
validateRegistry()
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 Detail
-
AbstractComponentRegistry
public AbstractComponentRegistry(ComponentValidatorManager validatorManager)
-
-
Method Detail
-
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
protected R self()
-
addComponent
public R addComponent(String id, Component<?> component)
- Specified by:
addComponent
in interfaceComponentRegistry<R extends AbstractComponentRegistry<R>>
-
add
public R add(String id, Component<?> component)
- Specified by:
add
in interfaceComponentRegistry<R extends AbstractComponentRegistry<R>>
-
add
public R add(Component<?> component)
- Specified by:
add
in interfaceComponentRegistry<R extends AbstractComponentRegistry<R>>
-
removeComponent
public R removeComponent(String id)
- Specified by:
removeComponent
in interfaceComponentRegistry<R extends AbstractComponentRegistry<R>>
-
remove
public R remove(String id)
- Specified by:
remove
in interfaceComponentRegistry<R extends AbstractComponentRegistry<R>>
-
hasComponent
public boolean hasComponent(String id)
- Specified by:
hasComponent
in interfaceComponentRegistry<R extends AbstractComponentRegistry<R>>
-
has
public boolean has(String id)
- Specified by:
has
in interfaceComponentRegistry<R extends AbstractComponentRegistry<R>>
-
getComponent
public Component<?> getComponent(String id)
- Specified by:
getComponent
in interfaceComponentRegistry<R extends AbstractComponentRegistry<R>>
-
getComponent
public <T extends Component<T>> T getComponent(String id, Class<T> clazz)
- Specified by:
getComponent
in interfaceComponentRegistry<R extends AbstractComponentRegistry<R>>
-
get
public Component<?> get(String id)
- Specified by:
get
in interfaceComponentRegistry<R extends AbstractComponentRegistry<R>>
-
get
public <T extends Component<T>> T get(String key, Class<T> clazz)
- Specified by:
get
in interfaceComponentRegistry<R extends AbstractComponentRegistry<R>>
-
getValidatorManager
public ComponentValidatorManager getValidatorManager()
-
getComponents
public Map<String,Component<?>> getComponents()
- Specified by:
getComponents
in interfaceComponentRegistry<R extends AbstractComponentRegistry<R>>
-
isFailOnValidationError
public boolean isFailOnValidationError()
-
setFailOnValidationError
public void setFailOnValidationError(boolean failOnValidationError)
-
-