RunReferencesDecorator

References decorator that automatically opens to newly added components that implement the IOpenable interface and closes removed components that implement the IClosable interface.

Extends: ReferencesDecorator

Implements: IOpenable

Description

The RunReferencesDecorator class allows you to create a references decorator that automatically opens to newly added components that implement the IOpenable interface and closes removed components that implement the IClosable interface.

Constructors

Creates a new instance of the decorator.

public RunReferencesDecorator(IReferences nextReferences, IReferences topReferences)

  • nextReferences: IReferences - next references or decorator in the chain.
  • topReferences: IReferences - decorator at the top of the chain.

Fields

_opened

Flag of the component state

private boolean _opened = false

Instance methods

isOpen

Checks if the component is opened.

public boolean isOpen()

open

Opens the component.

public void open(IContext context) throws ApplicationException

  • context: IContext - (optional) a context to trace execution through a call chain.

close

Closes a component and frees used resources.

public void close(IContext context) throws ApplicationException

  • context: IContext - (optional) a context to trace execution through a call chain.

put

Puts a new reference into the reference map.

public void put(Object locator, Object component) throws ApplicationException

  • locator: Object - locator to find the reference by.
  • reference: Object - component reference to be added.

remove

Removes a previously added component that matches the specified locator. If many references match the locator, it removes only the first one. When all references shall be removed, use the removeAll method instead.

public Object remove(Object locator) throws ApplicationException

  • locator: Object - locator to remove component
  • returns: Object - removed component.

removeAll

Removes all component references that match the specified locator.

public List removeAll(Object locator) throws ApplicationException

  • locator: Object - locator to remove references by.
  • returns: List - list containing all removed references.

    See also