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);
}
}
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();
}
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();
}
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();
}
}
Aggregations