You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Sridhar Raman <sr...@gmail.com> on 2007/12/13 07:34:29 UTC
Observation (Eventlistener) in Jackrabbit
I am a bit confused about what Event.PROPERTY_CHANGED stands for. Is it
triggered whenever a node.setProperty is called? Or is it triggered _only_
if the previous value and the new value of the property do not match?
Thanks,
Sridhar
Re: Observation (Eventlistener) in Jackrabbit
Posted by Marcel Reutegger <ma...@gmx.net>.
Sridhar Raman wrote:
> Hmm ... in that case is there any way I can check in the event listener
> whether the value has changed? Does the event (or any other object, for
> that matter) give me a handle on the older property value?
no it doesn't. when the event listener is called, the change has already been
committed and the old value is gone.
regards
marcel
Re: Observation (Eventlistener) in Jackrabbit
Posted by Sridhar Raman <sr...@gmail.com>.
Hmm ... in that case is there any way I can check in the event listener
whether the value has changed? Does the event (or any other object, for
that matter) give me a handle on the older property value?
On Dec 14, 2007 6:00 PM, Marcel Reutegger <ma...@gmx.net> wrote:
> Julian Reschke wrote:
> > Sridhar Raman wrote:
> >> That's what I assumed would happen, but when I ran this particular test
> >> case, I got different results.
> >> ...
> >
> > I would not make the assumption that the event can only be sent when the
> > value actually *changes* -- as a matter of fact, none of the servers
> > I've been developing for in the past makes a guarantee like that.
>
> the same holds for jackrabbit. if you set a value for an existing
> property,
> jackrabbit does not check if the value is equal to the existing one. the
> property is marked modified in any case.
>
> regards
> marcel
>
Re: Observation (Eventlistener) in Jackrabbit
Posted by Marcel Reutegger <ma...@gmx.net>.
Julian Reschke wrote:
> Sridhar Raman wrote:
>> That's what I assumed would happen, but when I ran this particular test
>> case, I got different results.
>> ...
>
> I would not make the assumption that the event can only be sent when the
> value actually *changes* -- as a matter of fact, none of the servers
> I've been developing for in the past makes a guarantee like that.
the same holds for jackrabbit. if you set a value for an existing property,
jackrabbit does not check if the value is equal to the existing one. the
property is marked modified in any case.
regards
marcel
Re: Observation (Eventlistener) in Jackrabbit
Posted by Julian Reschke <ju...@gmx.de>.
Sridhar Raman wrote:
> That's what I assumed would happen, but when I ran this particular test
> case, I got different results.
> ...
I would not make the assumption that the event can only be sent when the
value actually *changes* -- as a matter of fact, none of the servers
I've been developing for in the past makes a guarantee like that.
(This may be something where we want JSR-283 to be rephrased).
BR, Julian
Re: Observation (Eventlistener) in Jackrabbit
Posted by Sridhar Raman <sr...@gmail.com>.
That's what I assumed would happen, but when I ran this particular test
case, I got different results.
> PropChangeEventListener nodeEventListener = new PropChangeEventListener();
> ObservationManager observationManager = session.getWorkspace()
>
> .getObservationManager();
> observationManager.addEventListener(nodeEventListener,
> Event.PROPERTY_CHANGED,
> "/", true, null, null,
> false);
>
> // Create node
> Node root = session.getRootNode();
> Node temp = root.addNode("nodeA", "typeA");
> temp.setProperty("author", "Stephen King");
> root.save();
>
> // Set author property to the same value
> Node nodeA = root.getNode("nodeA");
> nodeA.setProperty("author", "Stephen King");
> nodeA.save();
>
This is the listener class:
> public class PropChangeEventListener implements EventListener
> {
> public void onEvent(EventIterator events)
> {
> while (events.hasNext())
> {
> Event event = events.nextEvent();
> int eventType = event.getType();
> System.out.println("Type " + eventType);
> }
> }
> }
>
The onEvent method is called even though the value of author is the same.
Any idea why?
On Dec 14, 2007 2:27 PM, Marcel Reutegger <ma...@gmx.net> wrote:
> Sridhar Raman wrote:
> > I am a bit confused about what Event.PROPERTY_CHANGED stands for. Is it
> > triggered whenever a node.setProperty is called? Or is it triggered
> _only_
> > if the previous value and the new value of the property do not match?
>
> it is the latter. see also section 8.3 in the specification.
>
> regards
> marcel
>
Re: Observation (Eventlistener) in Jackrabbit
Posted by Marcel Reutegger <ma...@gmx.net>.
Sridhar Raman wrote:
> I am a bit confused about what Event.PROPERTY_CHANGED stands for. Is it
> triggered whenever a node.setProperty is called? Or is it triggered _only_
> if the previous value and the new value of the property do not match?
it is the latter. see also section 8.3 in the specification.
regards
marcel