Search in sources :

Example 1 with ComponentLifecycleException

use of org.xwiki.component.manager.ComponentLifecycleException in project xwiki-platform by xwiki.

the class WikiDeletedListener method onEvent.

@Override
public void onEvent(Event event, Object o, Object context) {
    String wiki = ((WikiDeletedEvent) event).getWikiId();
    ComponentManager componentManager = this.componentManagerManager.getComponentManager(new WikiNamespace(wiki).serialize(), false);
    if (componentManager instanceof Disposable) {
        try {
            ((Disposable) componentManager).dispose();
        } catch (ComponentLifecycleException e) {
            this.logger.error(String.format("Failed to dispose component manager for wiki [%s]", wiki), e);
        }
    }
}
Also used : Disposable(org.xwiki.component.phase.Disposable) WikiNamespace(org.xwiki.model.namespace.WikiNamespace) ComponentManager(org.xwiki.component.manager.ComponentManager) ComponentLifecycleException(org.xwiki.component.manager.ComponentLifecycleException) WikiDeletedEvent(org.xwiki.bridge.event.WikiDeletedEvent)

Example 2 with ComponentLifecycleException

use of org.xwiki.component.manager.ComponentLifecycleException in project xwiki-platform by xwiki.

the class DocumentDeletedListener method onEvent.

@Override
public void onEvent(Event event, Object o, Object context) {
    String document = ((DocumentDeletedEvent) event).getEventFilter().getFilter();
    ComponentManager componentManager = this.componentManagerManager.getComponentManager(new DocumentNamespace(document).serialize(), false);
    if (componentManager instanceof Disposable) {
        try {
            ((Disposable) componentManager).dispose();
        } catch (ComponentLifecycleException e) {
            this.logger.error(String.format("Failed to dispose component manager for document [%s]", document), e);
        }
    }
}
Also used : Disposable(org.xwiki.component.phase.Disposable) DocumentNamespace(org.xwiki.model.namespace.DocumentNamespace) ComponentManager(org.xwiki.component.manager.ComponentManager) ComponentLifecycleException(org.xwiki.component.manager.ComponentLifecycleException)

Aggregations

ComponentLifecycleException (org.xwiki.component.manager.ComponentLifecycleException)2 ComponentManager (org.xwiki.component.manager.ComponentManager)2 Disposable (org.xwiki.component.phase.Disposable)2 WikiDeletedEvent (org.xwiki.bridge.event.WikiDeletedEvent)1 DocumentNamespace (org.xwiki.model.namespace.DocumentNamespace)1 WikiNamespace (org.xwiki.model.namespace.WikiNamespace)1