use of org.xwiki.bridge.event.ApplicationReadyEvent in project xwiki-platform by xwiki.
the class ScriptingIntegrationTest method initialize.
@Before
public void initialize() throws Exception {
this.scriptService = this.componentManager.getInstance(ScriptService.class, "mailsender");
// Set the EC
Execution execution = this.componentManager.getInstance(Execution.class);
ExecutionContext executionContext = new ExecutionContext();
XWikiContext xContext = new XWikiContext();
xContext.setWikiId("wiki");
executionContext.setProperty(XWikiContext.EXECUTIONCONTEXT_KEY, xContext);
execution.setContext(executionContext);
Copier<ExecutionContext> executionContextCloner = this.componentManager.getInstance(new DefaultParameterizedType(null, Copier.class, ExecutionContext.class));
// Just return the same execution context
when(executionContextCloner.copy(executionContext)).thenReturn(executionContext);
// Simulate receiving the Application Ready Event to start the mail threads
MailSenderInitializerListener listener = this.componentManager.getInstance(EventListener.class, MailSenderInitializerListener.LISTENER_NAME);
listener.onEvent(new ApplicationReadyEvent(), null, null);
}
use of org.xwiki.bridge.event.ApplicationReadyEvent in project xwiki-platform by xwiki.
the class XWikiInitializerJob method runInternal.
@Override
protected void runInternal() throws Exception {
this.logger.info("Start XWiki initialization");
this.progressManager.pushLevelProgress(2, this);
try {
this.progressManager.startStep(this);
XWikiContext xcontext = this.xcontextProvider.get();
XWiki xwiki = new XWiki(xcontext, xcontext.getEngineContext(), true);
// initialize stub context here instead of during Execution context initialization because
// during Execution context initialization, the XWikiContext is not fully initialized (does not
// contains XWiki object) which make it unusable
this.stubContextProvider.initialize(xcontext);
this.progressManager.endStep(this);
this.progressManager.startStep(this);
this.logger.info("XWiki initialization done");
// Send Event to signal that the application is ready to service requests.
this.observation.notify(new ApplicationReadyEvent(), xwiki, xcontext);
// Make XWiki class available to others (among other things it unlock page loading)
xcontext.getEngineContext().setAttribute(XWiki.DEFAULT_MAIN_WIKI, xwiki);
} finally {
this.progressManager.popLevelProgress(this);
}
}
use of org.xwiki.bridge.event.ApplicationReadyEvent 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