jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marcel Reutegger <marcel.reuteg...@gmx.net>
Subject Re: event listener not getting any events..
Date Fri, 28 Jul 2006 14:17:12 GMT
hsp wrote:
> session.getWorkspace().getObservationManager().addEventListener(
> 		ListenerNodeAddEscribaBase.getInstance(),
> 		Event.NODE_ADDED,
> 		"/",
> 		true,
> 		null,
> 		new String[] {"nt:base"},
> 		false
> );
> Node nodeGrupo = (Node)session.getItem("/");
> nodeGrupo.addNode(nomeNode, "nt:folder");
> session.save();
> session.logout();

Events are delivered with an asynchronous background thread. This way 
the internals of jackrabbit do not have to wait for listener 
implementations to complete the commit of changes.

because your code logs out the session immediately after save() it may 
happen that the notification of your listener does not happen within 
that short period of time. As soon as a session is logged out all its 
associated EventListeners are invalidated and are not notified 
anymore. This is because the Event instances are bound to the 
namespace mappings of the current session. Event.getPath() must return 
the namespace prefixes according to the currently set mapping in the 
Session. When the session is gone, Event.getPath() would not be able 
to return any sensible value anymore.

I doubt there is a practical use case, which requires what you are 
doing in your code.

If you really need such a functionality, which I doubt, you may write 
an event listener that implements 

Implementing classes are guaranteed to get events before save() returns.


View raw message