Hi Tharindu,

On Thu, Apr 30, 2009 at 12:21 PM, Tharindu Madushanka <[email protected]
> wrote:

> Hi,
> I was little bit busy this week with University just started for us. And I
> am having 3 days holiday from tomorrow. Therefore, I thought I use that
> time
> to fix JIRA issue on my work.
>
> Steps Revised
>
> 1. Create a LoginListener class that implements EventListener
> can I use the package org.xwiki.observation.event to add this class ?
>

Yes, but it should be LoginEvent. You see we fire events through the
ObservationManager and we implement EventListener only at the destination
where we want to receive the event.


>
> 2. I do not need to create any DefaultObservationManager instance.
> components.xml file is defined with DefaultObservationManager
> implementation.
> I get reference to it by calling (Step 5) when ever nececary
> ObservationManager om = (ObservationManager)
> Utils.getComponent(ObservationManager.class);


Ummm, if you are already inside a component you should not use
Utils.getComponent() method. Instead you should wire the observation manager
via dependancy injection. But if you are working on some old code
(xwiki-core and the like) you may use Utils.getComponent().


>
>
> 3. Define class UserLoginEvent similar to DocumentSaveEvent
>     in package org.xwiki.observation.event
>

I think this is what i described above.


>
> 4. Need to find the place where I call the addListener() of
> ObservationManager with parameters - object of UserLoginEvent and reference
> to login listener. I think when user initiated login I need to add the
> listener. I looked at LoginAction class, but could not figure out a way.


I think the registration (against events) can happen from any place within
your code. But I'm not esactly sure where to do this in your case. Better
wait for sergiu's comment :)


>
> 6. Need to find when to call notify() of DefaultObjectManager instance when
> user successfully logged in


Yes.


>
>
> 7. Implement notify() in LoginListener
>

Ummm, inside listener you have to implement onEvent() do whatever you need
to do when the event occurs.


>
> I think I need to get familiar with com.xpn.xwiki.web package to learn how
> to do steps 4 and 6. If anyone could point me some points to look for it
> would be really helpful.


Remote debugging is your friend :)

Thanks.

- Asiri
_______________________________________________
devs mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/devs

Reply via email to