You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Alfie Kirkpatrick <Al...@ioko.com> on 2009/03/30 23:24:16 UTC

Observing changes made to a single session

Hi, I am interested in having a listener that only reacts to changes
made in a given Jackrabbit session, rather than all changes across a
workspace. Is this possible?

 

I have found SynchronousEventListener which means that all events are
dispatched when save() is called, and this is close to what I want. But
there doesn't seem a simple/obvious way to ignore changes from another
session. It actually seems that all events are marshalled through the
workspace/session that registered the event listener, even those from
another session.

 

I thought of a horrible hacky way which is to register two listeners,
one with the noLocal flag set and then to 'diff' the two sets of
changes. Is there a neater way?!

 

Thanks,

Alfie.

 

 


Re: Observing changes made to a single session

Posted by Alexander Klimetschek <ak...@day.com>.
On Mon, Mar 30, 2009 at 11:24 PM, Alfie Kirkpatrick
<Al...@ioko.com> wrote:
> Hi, I am interested in having a listener that only reacts to changes
> made in a given Jackrabbit session, rather than all changes across a
> workspace. Is this possible?

You can use the standard JCR observation mechanism (section 8.3 of the
JSR-170 spec [1]):
session.getWorkspace().getObservationManager().addEventListener() [2]

But this will always give you all repository changes (in case of
clustering, the Jackrabbit-specific isExternal() method on
JackrabbitEvent [3] will mark events that are coming from another
cluster node). What is your use case for not seeing the changes of a
certain session? You should probably separate your "events" by using a
content hierarchy that allows that.

[1] http://www.day.com/specs/jcr/1.0/8.3_Observation.html
[2] http://day.com/maven/jsr170/javadocs/jcr-1.0/javax/jcr/observation/ObservationManager.html
[3] http://jackrabbit.apache.org/api/1.5/org/apache/jackrabbit/api/observation/JackrabbitEvent.html

Regards,
Alex

-- 
Alexander Klimetschek
alexander.klimetschek@day.com