jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r677261 - in /jackrabbit/trunk: jackrabbit-api/src/main/java/org/apache/jackrabbit/api/observation/ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/ jackrabbit-core/src/main/resources-filtered/org/apache/jackrabbit/core/
Date Wed, 16 Jul 2008 12:38:30 GMT
Author: mreutegg
Date: Wed Jul 16 05:38:30 2008
New Revision: 677261

URL: http://svn.apache.org/viewvc?rev=677261&view=rev
Log:
JCR-1672: Adding Event interface and isLocal()

Added:
    jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/observation/
    jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/observation/LocalEventListener.java
  (with props)
Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventConsumer.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/FilteredEventIterator.java
    jackrabbit/trunk/jackrabbit-core/src/main/resources-filtered/org/apache/jackrabbit/core/repository.properties

Added: jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/observation/LocalEventListener.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/observation/LocalEventListener.java?rev=677261&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/observation/LocalEventListener.java
(added)
+++ jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/observation/LocalEventListener.java
Wed Jul 16 05:38:30 2008
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.api.observation;
+
+import javax.jcr.observation.EventListener;
+
+/**
+ * This is a marker interface that can be used by client code
+ * to inform the repository that this listener should only be
+ * invoked for local changes.
+ * Local changes are changes happening on the same node in a 
+ * clustered environment.
+ * If there is no clustered environment, changes are always
+ * happening on the "current node" and therefore this listener
+ * is treated like a usual event listener.
+ * 
+ * Please note: if the jcr implementation does not value this
+ *              interface, the listener is still invoked for
+ *              all changes happening in the repository.
+ *              Therefore it is advisable to check the repository
+ *              implementation on startup if this feature is
+ *              required! The {@link javax.jcr.Repository#getDescriptor(String)}
+ *              method with {@link #OPTION_LOCAL_EVENT_LISTENER} can
+ *              be used to test the implementation.
+ */
+public interface LocalEventListener extends EventListener {
+
+    /**
+     * The presence of this key indicates that this implementation
+     * supports local event listeners.
+     */
+     String OPTION_LOCAL_EVENT_LISTENER = "option.observation.localeventlistener";
+    
+}

Propchange: jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/observation/LocalEventListener.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventConsumer.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventConsumer.java?rev=677261&r1=677260&r2=677261&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventConsumer.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventConsumer.java
Wed Jul 16 05:38:30 2008
@@ -16,6 +16,7 @@
  */
 package org.apache.jackrabbit.core.observation;
 
+import org.apache.jackrabbit.api.observation.LocalEventListener;
 import org.apache.jackrabbit.core.ItemId;
 import org.apache.jackrabbit.core.SessionImpl;
 import org.apache.jackrabbit.core.state.ItemState;
@@ -238,7 +239,7 @@
             return;
         }
         // check if filtered iterator has at least one event
-        EventIterator it = new FilteredEventIterator(events, filter, denied);
+        EventIterator it = new FilteredEventIterator(events, filter, denied, listener instanceof
LocalEventListener);
         if (it.hasNext()) {
             listener.onEvent(it);
         } else {

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/FilteredEventIterator.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/FilteredEventIterator.java?rev=677261&r1=677260&r2=677261&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/FilteredEventIterator.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/FilteredEventIterator.java
Wed Jul 16 05:38:30 2008
@@ -63,6 +63,10 @@
     private long pos = 0;
 
     /**
+     * Is this a local event listener
+     */
+    private final boolean isLocalEventListener;
+    /**
      * Creates a new <code>FilteredEventIterator</code>.
      *
      * @param c      an unmodifiable Collection of {@link javax.jcr.observation.Event}s.
@@ -74,10 +78,12 @@
      */
     public FilteredEventIterator(EventStateCollection c,
                                  EventFilter filter,
-                                 Set denied) {
+                                 Set denied,
+                                 boolean isLocalEventListener) {
         actualEvents = c.iterator();
         this.filter = filter;
         this.denied = denied;
+        this.isLocalEventListener = isLocalEventListener;
         fetchNext();
     }
 
@@ -155,12 +161,14 @@
         next = null;
         while (next == null && actualEvents.hasNext()) {
             state = (EventState) actualEvents.next();
-            // check denied set
-            if (denied == null || !denied.contains(state.getTargetId())) {
-                try {
-                    next = filter.blocks(state) ? null : new EventImpl(filter.getSession(),
state);
-                } catch (RepositoryException e) {
-                    log.error("Exception while applying filter.", e);
+            if ( !state.isExternal() || !isLocalEventListener ) {
+                // check denied set
+                if (denied == null || !denied.contains(state.getTargetId())) {
+                    try {
+                        next = filter.blocks(state) ? null : new EventImpl(filter.getSession(),
state);
+                    } catch (RepositoryException e) {
+                        log.error("Exception while applying filter.", e);
+                    }
                 }
             }
         }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/resources-filtered/org/apache/jackrabbit/core/repository.properties
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/resources-filtered/org/apache/jackrabbit/core/repository.properties?rev=677261&r1=677260&r2=677261&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/resources-filtered/org/apache/jackrabbit/core/repository.properties
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/resources-filtered/org/apache/jackrabbit/core/repository.properties
Wed Jul 16 05:38:30 2008
@@ -69,3 +69,6 @@
 query.xpath.doc.order = false
 # Disabled since in default configuration document order is not supported.
 # See https://issues.apache.org/jira/browse/JCR-1237 for details
+
+# The presence of this key indicates that this implementation supports local event listeners.
+option.observation.localeventlistener = true



Mime
View raw message