One particular strength of Java Content Repositories is that they provide so much infrastructure for developing content centric applications. Today, I discovered another hidden gem in JCR2 (JSR-283) that can come in very handy for app development:
In JCR1 the class ObservationManager used to manage EventListeners that get triggered immediately when an event like a property change occurs. Starting from JCR2 the ObservationManager also provides an EventJournal for each node that can be retrieved without having to register a listener first. The EventJournal is a list of events, e.g. addition, moves or removal(!) of child nodes, complete with user id and timestamp.
Attached to this post is a little CRX package with a servlet that renders the events for a given node. The relevant lines are:
Install the package and point your browser to http://localhost:7402/apps/eventy.html?path=/content (the path parameter specifies the node you are interested in). You should see a list of entries like:
And from the Javadoc:
Events returned in the EventJournal instance will be filtered according to [...] the current session's access restrictions
I am delighted.