On Fri, Mar 18, 2016 at 4:14 PM, abtv <andreybutov(a)mail.ru> wrote:
1. I'm implementing custom xwiki plugin
installations without user
interaction in java (I planned to do it with REST API, but after testing I
have found it's not so convenient as java code). I use the following:
ExtensionManagerScriptService manager =
(ExtensionManagerScriptService)Utils.getComponent(ScriptService.class,
"extension");
InstalledExtensionScriptService installed =
(InstalledExtensionScriptService)Utils.getComponent(ScriptService.class,
"extension.installed");
The problem is that I do it in my custom auth module when user logins into
system. I do this check only once but it smells for 2 reasons:
Utils.getComponent method is deprecated
Yes Utils.getComponent is indeed deprecated and should only be used in
places where you really don't ave any choice which is old style non
component based stuff... like authenticators unfortunately. Now since
your code is about initializing stuff only once it would probably be
better to move that in a listener called at startup. See below.
and I think there is an entry point
which I can override to run my code on xwiki start. Could you propose any
solution for this? I have also concern about xwiki start: I use Jetty and
every time I start xwiki I see a message "xwiki is loading..." and percent
counter.
It seems that xwiki loads only for the first request.
Is it true?
Yes and no. You do have a lots of stuff initialized during application
startup (extensions, listeners, etc.) but you also have important
things for XWiki initialized only during the first request which are
mostly the database and stuff that need to access the database.
If you don't need the database (or you don't need something that needs
the database) you should listen to
org.xwiki.observation.event.ApplicationStartedEvent event (from module
xwiki-commons-observation-api). If you need the database, you can
listen to org.xwiki.bridge.event.ApplicationReadyEvent event (from
module xwiki-platform-bridge)
See
http://extensions.xwiki.org/xwiki/bin/view/Extension/Observation+Module+Loc…
for more about listeners.
Can I change the behaviour?
--
View this message in context:
http://xwiki.475771.n2.nabble.com/How-to-run-custom-code-on-xwiki-start-in-…
Sent from the XWiki- Dev mailing list archive at
Nabble.com.
_______________________________________________
devs mailing list
devs(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/devs
--
Thomas Mortagne