jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Martijn Hendriks" <marti...@gx.nl>
Subject Observation mechanism bug?
Date Thu, 08 Mar 2007 08:08:02 GMT

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:

	Event.NODE_ADDED, prefix, true, null, new String[] {"my:type"},

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);

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?


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

View raw message