Implements: ReferencesDecorator
Description
The BuildReferencesDecorator class allows you to create a references decorator that automatically creates missing components using availale component factories upon component retrieval.
Constructors
Creates a new instance of the decorator.
public
BuildReferencesDecorator(IReferences baseReferences, IReferences parentReferences)
- nextReferences: IReferences - the next references or decorator in the chain.
- topReferences: IReferences - the decorator at the top of the chain.
Instance methods
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.
public
Object clarifyLocator(Object locator, IFactory factory)
- locator: Object - component locator to clarify.
- factory: IFactory - factory that shall create the component.
- returns: Object - clarified component descriptor (locator)
create
Creates a component identified by the given locator.
public
Object create(Object locator)
- locator: Object - locator used to identify the component to be created.
- returns: Object - created component.
find
Gets all component references that match the specified locator. Throws a ReferenceException when required is set to True but no references are found.
public
List find(Class type, Object locator, boolean required) throws ReferenceException
- type: Class
- type. - locator: Object - locator to find a reference by.
- required: boolean - it True, it forces to raise an exception when no reference is found.
- returns:
List - list with matching component references.
findFactory
Finds a factory capable creating a component by given descriptor from the components registered in the references.
public
IFactory findFactory(Object locator)
- locator: Object - locator of the component to be created.
- returns: IFactory - found factory or null if no factory was found.