Search in sources :

Example 1 with WikiReadyEvent

use of org.xwiki.bridge.event.WikiReadyEvent in project xwiki-platform by xwiki.

the class WikiInitializerJob method runInternal.

@Override
protected void runInternal() throws Exception {
    String wikiId = getRequest().getWikiId();
    this.logger.info("Start initialization of wiki [{}]", wikiId);
    XWikiContext xcontext = this.xcontextProvider.get();
    // Set proper context
    xcontext.setWikiId(wikiId);
    xcontext.setOriginalWikiId(wikiId);
    this.progressManager.pushLevelProgress(3, this);
    try {
        this.progressManager.startStep(this, "Initialize mandatory document");
        // Initialize mandatory document
        xcontext.getWiki().initializeMandatoryDocuments(xcontext);
        this.progressManager.startStep(this, "Initialize plugins");
        // Initialize plugins
        xcontext.getWiki().getPluginManager().virtualInit(xcontext);
        this.logger.info("Initialization if wiki [{}] done", wikiId);
        this.progressManager.startStep(this, "Call listeners");
        // Send event to notify listeners that the subwiki is ready
        this.observation.notify(new WikiReadyEvent(wikiId), wikiId, xcontext);
    } finally {
        this.progressManager.popLevelProgress(this);
    }
}
Also used : WikiReadyEvent(org.xwiki.bridge.event.WikiReadyEvent) XWikiContext(com.xpn.xwiki.XWikiContext)

Example 2 with WikiReadyEvent

use of org.xwiki.bridge.event.WikiReadyEvent in project xwiki-platform by xwiki.

the class DefaultWikiObjectComponentManagerEventListenerTest method testComponentInitializationOnWikiReady.

@Test
public void testComponentInitializationOnWikiReady() throws Exception {
    this.mocker.getComponentUnderTest().onEvent(new WikiReadyEvent(), null, null);
    verify(this.wikiObjectComponentManagerEventListenerProxy, times(1)).registerAllObjectComponents();
}
Also used : WikiReadyEvent(org.xwiki.bridge.event.WikiReadyEvent) Test(org.junit.Test)

Example 3 with WikiReadyEvent

use of org.xwiki.bridge.event.WikiReadyEvent in project xwiki-platform by xwiki.

the class DefaultWikiObjectComponentManagerEventListenerTest method testComponentInitializationOnApplicationReady.

@Test
public void testComponentInitializationOnApplicationReady() throws Exception {
    this.mocker.getComponentUnderTest().onEvent(new WikiReadyEvent(), null, null);
    verify(this.wikiObjectComponentManagerEventListenerProxy, times(1)).registerAllObjectComponents();
}
Also used : WikiReadyEvent(org.xwiki.bridge.event.WikiReadyEvent) Test(org.junit.Test)

Example 4 with WikiReadyEvent

use of org.xwiki.bridge.event.WikiReadyEvent in project xwiki-platform by xwiki.

the class DefaultWikiComponentManagerEventListener method onEvent.

@Override
public void onEvent(Event event, Object source, Object data) {
    if (source instanceof DocumentModelBridge) {
        // Get the document reference
        DocumentModelBridge document = (DocumentModelBridge) source;
        DocumentReference documentReference = document.getDocumentReference();
        if (event instanceof DocumentCreatedEvent || event instanceof DocumentUpdatedEvent) {
            registerDocumentComponents(document.getDocumentReference());
        } else if (event instanceof DocumentDeletedEvent) {
            // Unregister components from the deleted document, if any
            this.wikiComponentManagerEventListenerHelper.unregisterComponents(documentReference);
        }
    /* If we are at application startup time, we have to instanciate every document or object that we can find
         * in the wiki */
    } else if (event instanceof ApplicationReadyEvent || event instanceof WikiReadyEvent) {
        // These 2 events are created when the database is ready. We register all wiki components.
        registerAllDocumentComponents();
    }
}
Also used : DocumentDeletedEvent(org.xwiki.bridge.event.DocumentDeletedEvent) DocumentModelBridge(org.xwiki.bridge.DocumentModelBridge) ApplicationReadyEvent(org.xwiki.bridge.event.ApplicationReadyEvent) DocumentCreatedEvent(org.xwiki.bridge.event.DocumentCreatedEvent) WikiReadyEvent(org.xwiki.bridge.event.WikiReadyEvent) DocumentUpdatedEvent(org.xwiki.bridge.event.DocumentUpdatedEvent) DocumentReference(org.xwiki.model.reference.DocumentReference)

Aggregations

WikiReadyEvent (org.xwiki.bridge.event.WikiReadyEvent)4 Test (org.junit.Test)2 XWikiContext (com.xpn.xwiki.XWikiContext)1 DocumentModelBridge (org.xwiki.bridge.DocumentModelBridge)1 ApplicationReadyEvent (org.xwiki.bridge.event.ApplicationReadyEvent)1 DocumentCreatedEvent (org.xwiki.bridge.event.DocumentCreatedEvent)1 DocumentDeletedEvent (org.xwiki.bridge.event.DocumentDeletedEvent)1 DocumentUpdatedEvent (org.xwiki.bridge.event.DocumentUpdatedEvent)1 DocumentReference (org.xwiki.model.reference.DocumentReference)1