jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1582707 - in /jackrabbit/trunk: jackrabbit-api/src/main/java/org/apache/jackrabbit/api/observation/ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/
Date Fri, 28 Mar 2014 11:25:00 GMT
Author: mduerig
Date: Fri Mar 28 11:24:59 2014
New Revision: 1582707

URL: http://svn.apache.org/r1582707
Log:
JCR-3759: Add noInternal flag to JackrabbitEventFilter

Modified:
    jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/observation/JackrabbitEventFilter.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventFilter.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/ObservationManagerImpl.java

Modified: jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/observation/JackrabbitEventFilter.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/observation/JackrabbitEventFilter.java?rev=1582707&r1=1582706&r2=1582707&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/observation/JackrabbitEventFilter.java
(original)
+++ jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/observation/JackrabbitEventFilter.java
Fri Mar 28 11:24:59 2014
@@ -72,6 +72,10 @@ import static java.util.Arrays.copyOf;
  * <code>noExternal</code>: if <code>true</code>, then events
  * from external cluster nodes are ignored. Otherwise, they are not ignored.
  * </li>
+ * <li>
+ * <code>noInternal</code>: if <code>true</code>, then events
+ * from this cluster node are ignored. Otherwise, they are not ignored.
+ * </li>
  * </ul>
  * The restrictions are "ANDed" together. In other words, for a particular node to be "listened
to" it
  * must meet all the restrictions.
@@ -86,6 +90,7 @@ public class JackrabbitEventFilter {  //
     private boolean noLocal;
     private String[] absPaths = new String[]{};
     private boolean noExternal;
+    private boolean noInternal;
 
     /**
      * Sets the <code>eventTypes</code> parameter of the filter.
@@ -254,4 +259,26 @@ public class JackrabbitEventFilter {  //
     public boolean getNoExternal() {
         return noExternal;
     }
+
+    /**
+     * Sets the <code>noInternal</code> parameter of the filter.
+     * If left unset, this parameter defaults to <code>false</code>.
+     *
+     * @param noInternal a <code>boolean</code>.
+     * @return This EventFilter object with the <code>noExternal</code> parameter
set.
+     */
+    public JackrabbitEventFilter setNoInternal(boolean noInternal) {
+        this.noInternal = noInternal;
+        return this;
+    }
+
+    /**
+     * Returns the <code>noInternal</code> parameter of the filter.
+     *
+     * @return a <code>boolean</code>.
+     */
+    public boolean getNoInternal() {
+        return noInternal;
+    }
+
 }
\ No newline at end of file

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventFilter.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventFilter.java?rev=1582707&r1=1582706&r2=1582707&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventFilter.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventFilter.java
Fri Mar 28 11:24:59 2014
@@ -82,6 +82,12 @@ public class EventFilter {
     private final boolean noExternal;
 
     /**
+     * If <code>noInternal</code> is true this filter will block events from
+     * this cluster nodes.
+     */
+    private final boolean noInternal;
+
+    /**
      * Creates a new <code>EventFilter</code> instance.
      *
      * @param session    the <code>Session</code> that registered the {@link
@@ -100,6 +106,10 @@ public class EventFilter {
      * @param noLocal    if <code>true</code> no events are allowed that were
      *                   created from changes related to the <code>Session</code>
      *                   that registered the {@link javax.jcr.observation.EventListener}.
+     * @param noExternal if <code>true</code> no events are allowed that were
+     *                   created from changes on an external cluster node.
+     * @param noInternal if <code>true</code> no events are allowed that were
+     *                   created from changes on the local cluster node.
      */
     EventFilter(SessionImpl session,
                 long eventTypes,
@@ -108,7 +118,8 @@ public class EventFilter {
                 NodeId[] ids,
                 NodeTypeImpl[] nodeTypes,
                 boolean noLocal,
-                boolean noExternal) {
+                boolean noExternal,
+                boolean noInternal) {
         this.session = session;
         this.eventTypes = eventTypes;
         this.paths = paths;
@@ -116,6 +127,7 @@ public class EventFilter {
         this.ids = ids;
         this.noLocal = noLocal;
         this.noExternal = noExternal;
+        this.noInternal = noInternal;
         this.nodeTypes = nodeTypes;
     }
 
@@ -147,6 +159,10 @@ public class EventFilter {
             return true;
         }
 
+        if (noInternal && !eventState.isExternal()) {
+            return true;
+        }
+
         // UUIDs, types, and paths do not need to match for persist
         if (eventState.getType() == Event.PERSIST) {
             return false;
@@ -203,7 +219,7 @@ public class EventFilter {
          * Creates a new <code>BlockAllFilter</code>.
          */
         BlockAllFilter() {
-            super(null, 0, Collections.<Path>emptyList(), true, null, null, true, true);
+            super(null, 0, Collections.<Path>emptyList(), true, null, null, true, true,
true);
         }
 
         /**

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/ObservationManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/ObservationManagerImpl.java?rev=1582707&r1=1582706&r2=1582707&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/ObservationManagerImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/ObservationManagerImpl.java
Fri Mar 28 11:24:59 2014
@@ -119,7 +119,7 @@ public class ObservationManagerImpl impl
 
         // create filter
         EventFilter filter = createEventFilter(eventTypes, Collections.singletonList(absPath),
-                isDeep, uuid, nodeTypeName, noLocal, false);
+                isDeep, uuid, nodeTypeName, noLocal, false, false);
 
         dispatcher.addConsumer(new EventConsumer(session, listener, filter));
     }
@@ -135,7 +135,7 @@ public class ObservationManagerImpl impl
 
         EventFilter f = createEventFilter(filter.getEventTypes(), absPaths,
                 filter.getIsDeep(), filter.getIdentifiers(), filter.getNodeTypes(),
-                filter.getNoLocal(), filter.getNoExternal());
+                filter.getNoLocal(), filter.getNoExternal(), filter.getNoInternal());
 
         dispatcher.addConsumer(new EventConsumer(session, listener, f));
     }
@@ -202,6 +202,7 @@ public class ObservationManagerImpl impl
      * @param nodeTypeName array of node type names.
      * @param noLocal a <code>boolean</code>.
      * @param noExternal a <code>boolean</code>.
+     * @param noInternal a <code>boolean</code>.
      * @return the event filter with the given restrictions.
      * @throws RepositoryException if an error occurs.
      */
@@ -211,7 +212,8 @@ public class ObservationManagerImpl impl
                                          String[] uuid,
                                          String[] nodeTypeName,
                                          boolean noLocal,
-                                         boolean noExternal)
+                                         boolean noExternal,
+                                         boolean noInternal)
             throws RepositoryException {
         // create NodeType instances from names
         NodeTypeImpl[] nodeTypes;
@@ -248,7 +250,7 @@ public class ObservationManagerImpl impl
         }
         // create filter
         return new EventFilter(
-                session, eventTypes, paths, isDeep, ids, nodeTypes, noLocal, noExternal);
+                session, eventTypes, paths, isDeep, ids, nodeTypes, noLocal, noExternal,
noInternal);
     }
 
     /**
@@ -280,7 +282,7 @@ public class ObservationManagerImpl impl
         }
 
         EventFilter filter = createEventFilter(
-                eventTypes, Collections.singletonList(absPath), isDeep, uuid, nodeTypeName,
false, false);
+                eventTypes, Collections.singletonList(absPath), isDeep, uuid, nodeTypeName,
false, false, false);
         return new EventJournalImpl(
                 filter, clusterNode.getJournal(), clusterNode.getId(), session);
     }



Mime
View raw message