jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1498950 - /jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/observation/ListenerTracker.java
Date Tue, 02 Jul 2013 14:17:46 GMT
Author: jukka
Date: Tue Jul  2 14:17:46 2013
New Revision: 1498950

URL: http://svn.apache.org/r1498950
Log:
JCR-3608: MBeans for tracking event listeners

Add before/afterEventDelivery() methods that subclasses can use to decorate event delivery
with custom processing

Modified:
    jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/observation/ListenerTracker.java

Modified: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/observation/ListenerTracker.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/observation/ListenerTracker.java?rev=1498950&r1=1498949&r2=1498950&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/observation/ListenerTracker.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/observation/ListenerTracker.java
Tue Jul  2 14:17:46 2013
@@ -104,6 +104,25 @@ public class ListenerTracker {
         // do nothing
     }
 
+    /**
+     * Called just before the {@link EventListener#onEvent(EventIterator)}
+     * method is called. The default implementation of this method does
+     * nothing, but subclasses can override it to add custom processing.
+     */
+    protected void beforeEventDelivery() {
+        // do nothing
+    }
+
+    /**
+     * Called just after the {@link EventListener#onEvent(EventIterator)}
+     * method has been called (even if the call threw an exception). The
+     * default implementation of this method does nothing, but subclasses
+     * can override it to add custom processing.
+     */
+    protected void afterEventDelivery() {
+        // do nothing
+    }
+
     public EventListener getTrackedListener() {
         return new EventListener() {
             @Override
@@ -111,6 +130,7 @@ public class ListenerTracker {
                 eventDeliveries.incrementAndGet();
                 long start = nanoTime();
                 try {
+                    beforeEventDelivery();
                     listener.onEvent(new EventIteratorAdapter(events) {
                         @Override
                         public Object next() {
@@ -128,6 +148,7 @@ public class ListenerTracker {
                         }
                     });
                 } finally {
+                    afterEventDelivery();
                     eventDeliveryTime.addAndGet(nanoTime() - start);
                 }
             }



Mime
View raw message