Re: [xwiki-devs] [Proposal] Add a WikiReadyEvent?
Am 13.04.2012 17:43 schrieb "Vincent Massol" <[email protected]>:
Hi devs,
We already have ApplicationStartedEvent and ApplicationReadyEvent (when
DB is ready). We also need an event when the wiki is ready since in s a multiwiki environment when you create a new wiki for example, you might need to init some stuff (like initialize mandatory classes). It's also needed the first time a request comes in for a given wiki.
Thus I propose to add a WikiReadyEvent next to ApplicationStartedEvent
and to send it in XWiki.updateDatabase():
... synchronized (wikiName) { if (!wikiList.contains(wikiName)) { wikiList.add(wikiName);
// Make sure these classes exists if (initClasses) { initializeMandatoryClasses(context); getPluginManager().virtualInit(context); getRenderingEngine().virtualInit(context); }
--> send WikiReadyEvent here
} }
Is it a good practise to call event listeners in the synchronized block? (see Brian Götz, Java Concurrence in Practise, never call alien code from a synchronized block) My 2cents Richard
WDYT?
Note that I was tempted to have a WikiCreatedEvent event sent when creating a wiki but that wouldn't fill the use case of initializing the wiki on the first request to it.
Thanks -Vincent _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
On Apr 16, 2012, at 4:52 PM, Richard Hierlmeier wrote:
Am 13.04.2012 17:43 schrieb "Vincent Massol" <[email protected]>:
Hi devs,
We already have ApplicationStartedEvent and ApplicationReadyEvent (when
DB is ready). We also need an event when the wiki is ready since in s a multiwiki environment when you create a new wiki for example, you might need to init some stuff (like initialize mandatory classes). It's also needed the first time a request comes in for a given wiki.
Thus I propose to add a WikiReadyEvent next to ApplicationStartedEvent
and to send it in XWiki.updateDatabase():
... synchronized (wikiName) { if (!wikiList.contains(wikiName)) { wikiList.add(wikiName);
// Make sure these classes exists if (initClasses) { initializeMandatoryClasses(context); getPluginManager().virtualInit(context); getRenderingEngine().virtualInit(context); }
--> send WikiReadyEvent here
} }
Is it a good practise to call event listeners in the synchronized block? (see Brian Götz, Java Concurrence in Practise, never call alien code from a synchronized block)
Good point. Although it's very unlikely it's going to cause trouble it's better to move the call just after the synchronized block. Thanks -Vincent
My 2cents
Richard
WDYT?
Note that I was tempted to have a WikiCreatedEvent event sent when creating a wiki but that wouldn't fill the use case of initializing the wiki on the first request to it.
Thanks -Vincent
participants (2)
-
Richard Hierlmeier -
Vincent Massol