jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1536813 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation/ oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/observation/
Date Tue, 29 Oct 2013 17:05:28 GMT
Author: mduerig
Date: Tue Oct 29 17:05:27 2013
New Revision: 1536813

URL: http://svn.apache.org/r1536813
Log:
OAK-144 Implement observation
Clarify noLocal logic

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation/ChangeProcessor.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation/EventFilter.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/observation/ObservationManagerImpl.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation/ChangeProcessor.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation/ChangeProcessor.java?rev=1536813&r1=1536812&r2=1536813&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation/ChangeProcessor.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation/ChangeProcessor.java
Tue Oct 29 17:05:27 2013
@@ -136,7 +136,7 @@ public class ChangeProcessor {
                     EventFilter filter = filterRef.get();
                     // FIXME don't rely on toString for session id
                     if (changes != null &&
-                            !(filter.excludeLocal() && changes.isLocal(contentSession.toString())))
{
+                            filter.include(changes.isLocal(contentSession.toString()))) {
                         String path = namePathMapper.getOakPath(filter.getPath());
                         ImmutableTree beforeTree = getTree(changes.getBeforeState(), path);
                         ImmutableTree afterTree = getTree(changes.getAfterState(), path);

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation/EventFilter.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation/EventFilter.java?rev=1536813&r1=1536812&r2=1536813&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation/EventFilter.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation/EventFilter.java
Tue Oct 29 17:05:27 2013
@@ -18,7 +18,10 @@
  */
 package org.apache.jackrabbit.oak.plugins.observation;
 
+import static com.google.common.base.Objects.toStringHelper;
+
 import java.util.Arrays;
+
 import javax.annotation.CheckForNull;
 import javax.jcr.RepositoryException;
 import javax.jcr.nodetype.NoSuchNodeTypeException;
@@ -30,8 +33,6 @@ import org.apache.jackrabbit.oak.api.Typ
 import org.apache.jackrabbit.oak.commons.PathUtils;
 import org.apache.jackrabbit.oak.plugins.nodetype.ReadOnlyNodeTypeManager;
 
-import static com.google.common.base.Objects.toStringHelper;
-
 /**
  * Filter for filtering observation events according to a certain criterion.
  */
@@ -42,7 +43,7 @@ public class EventFilter {
     private final boolean deep;
     private final String[] uuids;
     private final String[] nodeTypeOakName;
-    private final boolean noLocal;
+    private final boolean includeLocal;
 
     /**
      * Create a new instance of a filter for a certain criterion
@@ -53,21 +54,21 @@ public class EventFilter {
      * @param deep        {@code true} if descendants of {@code path} should be included.
{@code false} otherwise.
      * @param uuids       uuids to include
      * @param nodeTypeName  node type names to include
-     * @param noLocal       exclude session local events if {@code true}. Include otherwise.
+     * @param includeLocal  include session local events if {@code true}. Exclude otherwise.
      * @throws NoSuchNodeTypeException  if any of the node types in {@code nodeTypeName}
does not exist
      * @throws RepositoryException      if an error occurs while reading from the node type
manager.
      * @see javax.jcr.observation.ObservationManager#addEventListener(javax.jcr.observation.EventListener,
      * int, String, boolean, String[], String[], boolean)
      */
     public EventFilter(ReadOnlyNodeTypeManager ntMgr, int eventTypes, String path, boolean
deep, String[] uuids,
-            String[] nodeTypeName, boolean noLocal) {
+            String[] nodeTypeName, boolean includeLocal) {
         this.ntMgr = ntMgr;
         this.eventTypes = eventTypes;
         this.path = path;
         this.deep = deep;
         this.uuids = uuids;
         this.nodeTypeOakName = nodeTypeName;
-        this.noLocal = noLocal;
+        this.includeLocal = includeLocal;
     }
 
     /**
@@ -85,6 +86,15 @@ public class EventFilter {
     }
 
     /**
+     * Determine whether session local changes should be included.
+     * @param local  {@code true} for session local changes, {@code false} otherwise.
+     * @return  {@code true} if the changes are included with this filter. {@code false}
otherwise.
+     */
+    public boolean include(boolean local) {
+        return includeLocal || !local;
+    }
+
+    /**
      * Determine whether the children of a {@code path} would be matched by this filter
      * @param path  path whose children to test
      * @return  {@code true} if the children of {@code path} could be matched by this filter
@@ -96,13 +106,6 @@ public class EventFilter {
     }
 
     /**
-     * @return  the no local flag of this filter
-     */
-    public boolean excludeLocal() {
-        return noLocal;
-    }
-
-    /**
      * @return  path of this filter
      */
     public String getPath() {
@@ -117,7 +120,7 @@ public class EventFilter {
                 .add("deep", deep)
                 .add("uuids", Arrays.toString(uuids))
                 .add("node types", Arrays.toString(nodeTypeOakName))
-                .add("noLocal", noLocal)
+                .add("includeLocal", includeLocal)
             .toString();
     }
 

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/observation/ObservationManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/observation/ObservationManagerImpl.java?rev=1536813&r1=1536812&r2=1536813&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/observation/ObservationManagerImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/observation/ObservationManagerImpl.java
Tue Oct 29 17:05:27 2013
@@ -18,9 +18,12 @@
  */
 package org.apache.jackrabbit.oak.jcr.observation;
 
+import static com.google.common.collect.Lists.newArrayList;
+
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+
 import javax.annotation.CheckForNull;
 import javax.annotation.Nullable;
 import javax.jcr.RepositoryException;
@@ -46,8 +49,6 @@ import org.slf4j.LoggerFactory;
 import org.slf4j.Marker;
 import org.slf4j.MarkerFactory;
 
-import static com.google.common.collect.Lists.newArrayList;
-
 public class ObservationManagerImpl implements ObservationManager {
 
     private static final Logger log = LoggerFactory.getLogger(ObservationManagerImpl.class);
@@ -104,7 +105,7 @@ public class ObservationManagerImpl impl
     public synchronized void addEventListener(EventListener listener, int eventTypes, String
absPath,
             boolean isDeep, String[] uuid, String[] nodeTypeName, boolean noLocal) throws
RepositoryException {
         EventFilter filter = new EventFilter(ntMgr, eventTypes, oakPath(absPath), isDeep,
-                uuid, validateNodeTypeNames(nodeTypeName), noLocal);
+                uuid, validateNodeTypeNames(nodeTypeName), !noLocal);
         ChangeProcessor processor = processors.get(listener);
         if (processor == null) {
             log.info(OBSERVATION, "Registering event listener {} with filter {}", listener,
filter);



Mime
View raw message