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 ofComponentRegistryused 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 ofComponentSourceandFrameworkComponentSourcebeans.FrameworkComponentSourcebeans will be processed prior to theComponentSourcebeans, which allowsComponentSourcebeans 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 anIllegalStateExceptionto 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 Radd(Component<?> component)Radd(String id, Component<?> component)RaddComponent(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()ComponentValidatorManagergetValidatorManager()booleanhas(String id)booleanhasComponent(String id)voidinitialize(List<FrameworkComponentSource> frameworkComponentSources, List<ComponentSource> componentSources)Primary method of initializing the registry with components.booleanisFailOnValidationError()Rremove(String id)RremoveComponent(String id)protected Rself()voidsetFailOnValidationError(boolean failOnValidationError)voidvalidateRegistry()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
FrameworkComponentSourcewill be used to register any frameworkComponents. Second, the list ofComponentSourcewill be used to register new components and extend any framework components. Lastly, theComponentValidatorManagerwill 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 anIllegalStateExceptionto 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:
addComponentin interfaceComponentRegistry<R extends AbstractComponentRegistry<R>>
-
add
public R add(String id, Component<?> component)
- Specified by:
addin interfaceComponentRegistry<R extends AbstractComponentRegistry<R>>
-
add
public R add(Component<?> component)
- Specified by:
addin interfaceComponentRegistry<R extends AbstractComponentRegistry<R>>
-
removeComponent
public R removeComponent(String id)
- Specified by:
removeComponentin interfaceComponentRegistry<R extends AbstractComponentRegistry<R>>
-
remove
public R remove(String id)
- Specified by:
removein interfaceComponentRegistry<R extends AbstractComponentRegistry<R>>
-
hasComponent
public boolean hasComponent(String id)
- Specified by:
hasComponentin interfaceComponentRegistry<R extends AbstractComponentRegistry<R>>
-
has
public boolean has(String id)
- Specified by:
hasin interfaceComponentRegistry<R extends AbstractComponentRegistry<R>>
-
getComponent
public Component<?> getComponent(String id)
- Specified by:
getComponentin interfaceComponentRegistry<R extends AbstractComponentRegistry<R>>
-
getComponent
public <T extends Component<T>> T getComponent(String id, Class<T> clazz)
- Specified by:
getComponentin interfaceComponentRegistry<R extends AbstractComponentRegistry<R>>
-
get
public Component<?> get(String id)
- Specified by:
getin interfaceComponentRegistry<R extends AbstractComponentRegistry<R>>
-
get
public <T extends Component<T>> T get(String key, Class<T> clazz)
- Specified by:
getin interfaceComponentRegistry<R extends AbstractComponentRegistry<R>>
-
getValidatorManager
public ComponentValidatorManager getValidatorManager()
-
getComponents
public Map<String,Component<?>> getComponents()
- Specified by:
getComponentsin interfaceComponentRegistry<R extends AbstractComponentRegistry<R>>
-
isFailOnValidationError
public boolean isFailOnValidationError()
-
setFailOnValidationError
public void setFailOnValidationError(boolean failOnValidationError)
-
-