Package org.pipservices3.container.refer
Class LinkReferencesDecorator
java.lang.Object
org.pipservices3.container.refer.ReferencesDecorator
org.pipservices3.container.refer.LinkReferencesDecorator
- All Implemented Interfaces:
org.pipservices3.commons.refer.IReferences,org.pipservices3.commons.run.IClosable,org.pipservices3.commons.run.IOpenable
public class LinkReferencesDecorator
extends ReferencesDecorator
implements org.pipservices3.commons.run.IOpenable
References decorator that automatically sets references to newly added components
that implement IReferenceable interface and unsets references from removed components
that implement IUnreferenceable interface.
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new instance of the decorator.LinkReferencesDecorator(org.pipservices3.commons.refer.IReferences baseReferences) Creates a new instance of the decorator.LinkReferencesDecorator(org.pipservices3.commons.refer.IReferences nextReferences, org.pipservices3.commons.refer.IReferences topReferences) Creates a new instance of the decorator. -
Method Summary
Modifier and TypeMethodDescriptionvoidCloses component and frees used resources.booleanisOpen()Checks if the component is opened.voidOpens the component.voidPuts a new reference into this reference map.Removes a previously added reference that matches specified locator.Removes all component references that match the specified locator.Methods inherited from class org.pipservices3.container.refer.ReferencesDecorator
find, find, getAll, getAllLocators, getNextReferences, getOneOptional, getOneOptional, getOneRequired, getOneRequired, getOptional, getOptional, getRequired, getRequired, getTopReferences, setNextReferences, setTopReferences
-
Constructor Details
-
LinkReferencesDecorator
public LinkReferencesDecorator()Creates a new instance of the decorator. -
LinkReferencesDecorator
public LinkReferencesDecorator(org.pipservices3.commons.refer.IReferences baseReferences) Creates a new instance of the decorator.- Parameters:
baseReferences- the next references or decorator in the chain.
-
LinkReferencesDecorator
public LinkReferencesDecorator(org.pipservices3.commons.refer.IReferences nextReferences, org.pipservices3.commons.refer.IReferences topReferences) Creates a new instance of the decorator.- Parameters:
nextReferences- the next references or decorator in the chain.topReferences- the decorator at the top of the chain.
-
-
Method Details
-
isOpen
public boolean isOpen()Checks if the component is opened.- Specified by:
isOpenin interfaceorg.pipservices3.commons.run.IOpenable- Returns:
- true if the component has been opened and false otherwise.
-
open
Opens the component.- Specified by:
openin interfaceorg.pipservices3.commons.run.IOpenable- Parameters:
correlationId- (optional) transaction id to trace execution through call chain.- Throws:
org.pipservices3.commons.errors.ApplicationException- when error occured.
-
close
Closes component and frees used resources.- Specified by:
closein interfaceorg.pipservices3.commons.run.IClosable- Parameters:
correlationId- (optional) transaction id to trace execution through call chain.- Throws:
org.pipservices3.commons.errors.ApplicationException- when error occured.
-
put
public void put(Object locator, Object component) throws org.pipservices3.commons.errors.ApplicationException Puts a new reference into this reference map.- Specified by:
putin interfaceorg.pipservices3.commons.refer.IReferences- Overrides:
putin classReferencesDecorator- Parameters:
locator- a locator to find the reference by.component- a component reference to be added.- Throws:
org.pipservices3.commons.errors.ApplicationException- when error occured.
-
remove
Removes a previously added reference that matches specified locator. If many references match the locator, it removes only the first one. When all references shall be removed, use removeAll() method instead.- Specified by:
removein interfaceorg.pipservices3.commons.refer.IReferences- Overrides:
removein classReferencesDecorator- Parameters:
locator- a locator to remove reference- Returns:
- the removed component reference.
- Throws:
org.pipservices3.commons.errors.ApplicationException- when error occured.- See Also:
-
removeAll
public List<Object> removeAll(Object locator) throws org.pipservices3.commons.errors.ApplicationException Removes all component references that match the specified locator.- Specified by:
removeAllin interfaceorg.pipservices3.commons.refer.IReferences- Overrides:
removeAllin classReferencesDecorator- Parameters:
locator- the locator to remove references by.- Returns:
- a list, containing all removed references.
- Throws:
org.pipservices3.commons.errors.ApplicationException- when error occured.
-