jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sridhar Raman" <sridhar.ra...@gmail.com>
Subject Re: Observation (Eventlistener) in Jackrabbit
Date Fri, 14 Dec 2007 11:54:19 GMT
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 <marcel.reutegger@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
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message