jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tobias Bocanegra" <tobias.bocane...@day.com>
Subject Re: Observation mechanism bug?
Date Thu, 08 Mar 2007 09:30:03 GMT
hi,
NODE_ADDED and NODE_REMOVED events are filtered on the parent node
from which a node was added or removed (thats how it's defined in the
spec).

imo, this is not very helpful for applications, especially with the
NODE_REMOVED event where you can't figure out what nodetype the
removed node had.

regards, toby

On 3/8/07, Martijn Hendriks <martijnh@gx.nl> wrote:
> Hi,
>
> We want to use the observation mechanism of Jackrabbit to keep track of
> additions of nodes of a certain type. We've created an observation
> manager and added a listener like this:
>
> observationManager.addEventListener(myListener,
>         Event.NODE_ADDED, prefix, true, null, new String[] {"my:type"},
> true);
>
> On addition of a node of type my:type, however (from another session
> than the observation manager session), the onEvent method of the
> listener is not called. It seems that the following code from
> EventStateCollection.createEventStates is responsible for this:
>
>         // 3. added items
>
>         for (Iterator it = changes.addedStates(); it.hasNext();) {
>             ItemState state = (ItemState) it.next();
>             if (state.isNode()) {
>                 // node created
>                 NodeState n = (NodeState) state;
>                 NodeId parentId = n.getParentId();
>                 // the parent of an added item is always modified or new
>                 NodeState parent = (NodeState) changes.get(parentId);
>                 NodeTypeImpl nodeType = getNodeType(parent, session);
>                 Set mixins = parent.getMixinTypeNames();
>                 Path path = getPath(n.getNodeId(), hmgr);
>                 events.add(EventState.childNodeAdded(parentId,
>                         getParent(path),
>                         n.getNodeId(),
>                         path.getNameElement(),
>                         nodeType.getQName(),
>                         mixins,
>                         session));
>
> I.e., not the node type of the added node is added to the EventState,
> but the node type of the parent node. This seems to conflict with the
> spec (copied from the addEventListener JavaDoc):
>
> The set of events can be filtered by specifying restrictions based on
> characteristics of the node associated with the event. In the case of
> event types NODE_ADDED and NODE_REMOVED, the node associated with an
> event is the node at (or formerly at) the path returned by
> Event.getPath. In the case of event types PROPERTY_ADDED,
> PROPERTY_REMOVED and PROPERTY_CHANGED, the node associated with an event
> is the parent node of the property at (or formerly at) the path returned
> by Event.getPath:
>
> So is this really a bug, or am I missing something?
>
> Regards,
>
> Martijn Hendriks
> <GX> creative online development B.V.
>
> t: 024 - 3888 261
> f: 024 - 3888 621
> e: martijnh@gx.nl
>
> Wijchenseweg 111
> 6538 SW Nijmegen
> http://www.gx.nl/
>


-- 
-----------------------------------------< tobias.bocanegra@day.com >---
Tobias Bocanegra, Day Management AG, Barfuesserplatz 6, CH - 4001 Basel
T +41 61 226 98 98, F +41 61 226 98 97
-----------------------------------------------< http://www.day.com >---

Mime
View raw message