Search in sources :

Example 1 with Disposable

use of org.xwiki.component.phase.Disposable in project xwiki-platform by xwiki.

the class ScriptingIntegrationTest method cleanUp.

@After
public void cleanUp() throws Exception {
    // Make sure we stop the Mail Sender thread after each test (since it's started automatically when looking
    // up the MailSender component.
    Disposable listener = this.componentManager.getInstance(EventListener.class, MailSenderInitializerListener.LISTENER_NAME);
    listener.dispose();
}
Also used : Disposable(org.xwiki.component.phase.Disposable) After(org.junit.After)

Example 2 with Disposable

use of org.xwiki.component.phase.Disposable in project xwiki-platform by xwiki.

the class AuthenticatingIntegrationTest method cleanUp.

@After
public void cleanUp() throws Exception {
    // Make sure we stop the Mail Sender thread after each test (since it's started automatically when looking
    // up the MailSender component.
    Disposable listener = this.componentManager.getInstance(EventListener.class, MailSenderInitializerListener.LISTENER_NAME);
    listener.dispose();
}
Also used : Disposable(org.xwiki.component.phase.Disposable) After(org.junit.After)

Example 3 with Disposable

use of org.xwiki.component.phase.Disposable in project xwiki-platform by xwiki.

the class JavaIntegrationTest method cleanUp.

@After
public void cleanUp() throws Exception {
    // Make sure we stop the Mail Sender thread after each test (since it's started automatically when looking
    // up the MailSender component.
    Disposable listener = this.componentManager.getInstance(EventListener.class, MailSenderInitializerListener.LISTENER_NAME);
    listener.dispose();
}
Also used : Disposable(org.xwiki.component.phase.Disposable) After(org.junit.After)

Example 4 with Disposable

use of org.xwiki.component.phase.Disposable 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 5 with Disposable

use of org.xwiki.component.phase.Disposable 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

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