Hi!,
The lifecycle extension was just an easy entry point to register the
listener, if you're doing it elsewhere it should be fine, you should be
receiving the events as soon as you've registered it.
Regarding the registration,
WikiEventManager.addWikiEventListener(org.apache.wiki.WikiEngine.class, new
WikiEventListener() {
Having skimmed the code this morning, I think it should use the engine
instance, something like
WikiEventManager.addWikiEventListener(m_engine, new
WikiEventListener() {
As this is where WikiJSPFilter send the events. Would you mind trying to
debug inside WikiEventManager.fireEvent to see where the events are being
dispatched? I'll try to look into this throughout the week, but can't
promise anything.
Best regards,
juan pablo
El mié, 22 nov 2023, 16:52, Ulf Dittmer <[email protected]>
escribió:
> Hm, creating an extension seems like a lot of effort for something that
> should -from my reading of the javadocs- be relatively simple to do.
>
> I'm beefing up the CoreBean with page view statistics. So the code I posted
> before would be run as part of the CoreBean constructor, which should
> ensure that it is run during startup time.
>
> Based on what you said I just tried
>
WikiEventManager.addWikiEventListener(org.apache.wiki.WikiEngine.class, new
WikiEventListener() {
>
but some (non-) result: The listener is just not called. I feel like I'm
> missing something very simple, but I have experimented a lot, and can't
> figure out what it is.
>
> Thanks,
> Ulf
>
> On Wed, Nov 22, 2023 at 3:33 PM Juan Pablo Santos Rodríguez <
> [email protected]> wrote:
>
> > Hi Ulf,
> >
> > I haven't had time to look into this in detail, but I'd try to register
> the
> > listener through an Engine lifecycle extension (#1), from there you
> should
> > be able to register your listener as soon as the Engine is instantiated.
> >
> > WikiJSPFilter fires some Page events, but fires them to the running
> > WikiEngine, so it's there where you should listen to.
> >
> > WikiEventUtils disappeared long ago, IIRC due to a refactor so that the
> > jspwiki-event could be extracted to it's own module. Don't remember very
> > well, but its methods ended up mostly in WiliEventManager
> >
> >
> > HTH,
> > juan pablo
> >
> > #1:
> >
> >
> https://jspwiki-wiki.apache.org/Wiki.jsp?page=HowToWriteAnEngineLifecycleExtension
> >
> >
> > El mié, 22 nov 2023, 10:49, Ulf Dittmer <[email protected]
> > .invalid>
> > escribió:
> >
> > > I also tried
> > >
> > >
> > >
> >
> WikiEventManager.addWikiEventListener(org.apache.wiki.ui.WikiServletFilter.class,
> > > new WikiEventListener() {
> > > ...
> > >
> > > but that doesn't get called, either. Does anyone know how that is
> > supposed
> > > to work?
> > >
> > > If I understand
> https://jspwiki-wiki.apache.org/Wiki.jsp?page=WikiEvent
> > > correctly, that might need to be done BEFORE WikiServletFilter in
> > > instantiated, but I don't see how that is possible. But then, I'm not
> > sure
> > > how accurate that page is - some of the other pages describing event
> > > handling some out of date.
> > >
> > > Thanks,
> > > Ulf
> > >
> > > On Tue, Nov 21, 2023 at 11:10 AM Ulf Dittmer <
> [email protected]
> > >
> > > wrote:
> > >
> > > > Hi-
> > > >
> > > > I'm trying to get notified whenever a page is delivered by listening
> to
> > > > WikiPageEvent.PAGE_DELIVERED events. To that end I implemented a
> > > > WikiEventListener like this
> > > >
> > > > engine.addWikiEventListener(new WikiEventListener() {
> > > > @Override
> > > > public void actionPerformed (WikiEvent event) {
> > > > log.info(event.toString());
> > > > if (event instanceof WikiPageEvent) {
> > > > ...
> > > > }
> > > > }
> > > > });
> > > > }
> > > >
> > > > But the listener is never called with WikiPageEvents. According to
> > > > https://jspwiki-wiki.apache.org/Wiki.jsp?page=WikiEventUtils (a
> class
> > > > which apparently no longer exists) I may have to register the
> listener
> > > with
> > > > WikiServletFilter rather than WikiEngine. How would I go about that?
> > > >
> > > > Thanks,
> > > > Ulf
> > > >
> > >
> >
>