jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "hsp" <piccina...@ibest.com.br>
Subject Re: event listener not getting any events..
Date Fri, 28 Jul 2006 14:47:49 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.
>  marcel
Many thanks Marcel. I need to log out all operations in all nodes of certains types, to do
an audit trail. So, It must log in every operations for all nodes affected by the session.
I did the test for implementing SynchronousEventListener and it was ok. In this situation
I can even do some operations such charge a value in properties in thes situations  (behaviour
I hoped to work in onParentVersion=COMPUTE...), and log the audit.

By the way, about the assyncronous, for me it is not interesting, but could you tell me in
what kind of situations this funcionallity would be appreciate?


View raw message