Package org.pipservices3.container.refer
Class BuildReferencesDecorator
java.lang.Object
org.pipservices3.container.refer.ReferencesDecorator
org.pipservices3.container.refer.BuildReferencesDecorator
- All Implemented Interfaces:
org.pipservices3.commons.refer.IReferences
References decorator that automatically creates missing components using
available component factories upon component retrival.
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new instance of the decorator.BuildReferencesDecorator
(org.pipservices3.commons.refer.IReferences baseReferences) Creates a new instance of the decorator.BuildReferencesDecorator
(org.pipservices3.commons.refer.IReferences baseReferences, org.pipservices3.commons.refer.IReferences parentReferences) Creates a new instance of the decorator. -
Method Summary
Modifier and TypeMethodDescriptionclarifyLocator
(Object locator, org.pipservices3.components.build.IFactory factory) Clarifies a component locator by merging two descriptors into one to replace missing fields.Creates a component identified by given locator.<T> List<T>
Gets all component references that match specified locator.org.pipservices3.components.build.IFactory
findFactory
(Object locator) Finds a factory capable creating component by given descriptor from the components registered in the references.Methods inherited from class org.pipservices3.container.refer.ReferencesDecorator
find, getAll, getAllLocators, getNextReferences, getOneOptional, getOneOptional, getOneRequired, getOneRequired, getOptional, getOptional, getRequired, getRequired, getTopReferences, put, remove, removeAll, setNextReferences, setTopReferences
-
Constructor Details
-
BuildReferencesDecorator
public BuildReferencesDecorator()Creates a new instance of the decorator. -
BuildReferencesDecorator
public BuildReferencesDecorator(org.pipservices3.commons.refer.IReferences baseReferences) Creates a new instance of the decorator.- Parameters:
baseReferences
- the next references or decorator in the chain.
-
BuildReferencesDecorator
public BuildReferencesDecorator(org.pipservices3.commons.refer.IReferences baseReferences, org.pipservices3.commons.refer.IReferences parentReferences) Creates a new instance of the decorator.- Parameters:
baseReferences
- the next references or decorator in the chain.parentReferences
- the decorator at the top of the chain.
-
-
Method Details
-
findFactory
Finds a factory capable creating component by given descriptor from the components registered in the references.- Parameters:
locator
- a locator of component to be created.- Returns:
- found factory or null if factory was not found.
-
create
Creates a component identified by given locator.- Parameters:
locator
- a locator to identify component to be created.- Returns:
- the created component.
- See Also:
-
clarifyLocator
Clarifies a component locator by merging two descriptors into one to replace missing fields. That allows to get a more complete descriptor that includes all possible fields.- Parameters:
locator
- a component locator to clarify.factory
- a factory that shall create the component.- Returns:
- clarified component descriptor (locator)
-
find
public <T> List<T> find(Class<T> type, Object locator, boolean required) throws org.pipservices3.commons.refer.ReferenceException Gets all component references that match specified locator.- Specified by:
find
in interfaceorg.pipservices3.commons.refer.IReferences
- Overrides:
find
in classReferencesDecorator
- Parameters:
type
- the class type.locator
- the locator to find a reference by.required
- forces to raise an exception if no reference is found.- Returns:
- a list with matching component references.
- Throws:
org.pipservices3.commons.refer.ReferenceException
- when required is set to true but no references found.
-