EventListener questionseldaryus Jul 24, 2014 3:25 PM
I've been trying to use EventListeners with ModeShape 3.8 and I have several questions regarding it:
1. ObservationManager.addEventListener JavaDoc says that nodeTypeName restrictions
are "ANDed" together. In other words, for a particular node to be "listened to" it must meet all the restrictions
however JCR 2.0 spec says that
Only events whose associated parent node is of one of the node types in the nodeTypeNames String array will be received.
That is, restricions are ORed. Which one is correct? It seems that ModeShape implements it as in the spec.
2. noLocal restriction doesn't seem to be working in ModeShape. I've created a dedicated session for event handling and registered the listener via eventSession.getWorkspace().getObservationManager() with noLocal = true
However, when I'm updating the repository via the other session, the event doesn't get triggered at all.
I tried to debug this a little and the session comparison in JcrObservationManager is being done using session.context().getProcessId(), however this parameter is the same for all the sessions that I create. As far as I understand, whenever a new session is created, an ExecutionContext is copied from the repository one, and it seems that the processId gets copied too, so perhaps this is the reason?
3. My listener creates additional nodes (using the eventSession), and this triggers events. Since I can't use noLocal flag, JcrObservationManager tries to see if it should notify my listeners about these nodes creation. However, at this point I'm getting the following exception:
javax.jcr.PathNotFoundException: No node exists at path '/repository/newNode' in workspace "default"
Is this expected behaviour? Am I allowed to create new nodes in the Event Listeners?