def close(self, correlation_id: Optional[str]): """ Closes component and frees used resources. :param correlation_id: (optional) transaction id to trace execution through call chain. """ if self.__opened: components = self.get_all() Referencer.unset_references(components) self.__opened = False
def open(self, correlation_id: Optional[str]): """ Opens the component. :param correlation_id: (optional) transaction id to trace execution through call chain. """ if not self.__opened: components = self.get_all() Referencer.set_references(self.parent_references, components) self.__opened = True
def put(self, locator: Any = None, component: Any = None) -> Any: """ Puts a new component into this component map. :param locator: a locator to find the component by. :param component: a component component to be added. """ super(LinkReferencesDecorator, self).put(locator, component) if self.__opened: Referencer.set_references_for_one(self.parent_references, component)
def put(self, locator=None, component=None): """ Puts a new reference into this reference map. :param locator: a locator to find the reference by. :param component: a component reference to be added. """ super(LinkReferencesDecorator, self).put(locator, component) if self._opened: Referencer.set_references_for_one(self.parent_references, component)
def remove_all(self, locator: Any) -> List[Any]: """ Removes all component references that match the specified locator. :param locator: the locator to remove references by. :return: a list, containing all removed references. """ components = super(LinkReferencesDecorator, self).remove_all(locator) if self.__opened: Referencer.unset_references(components) return components
def remove(self, locator: Any) -> Any: """ Removes a previously added component that matches specified locator. If many references match the locator, it removes only the first one. When all references shall be removed, use :func:`remove_all` method instead. :param locator: a locator to remove component :return: the removed component component. """ component = super(LinkReferencesDecorator, self).remove(locator) if self.__opened: Referencer.unset_references_for_one(component) return component