sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1685501 - in /sling/trunk/bundles/api/src/main/java/org/apache/sling: api/resource/observation/ spi/resource/provider/
Date Mon, 15 Jun 2015 06:25:38 GMT
Author: cziegeler
Date: Mon Jun 15 06:25:38 2015
New Revision: 1685501

URL: http://svn.apache.org/r1685501
Log:
SLING-4751 : New observation API: Add external/local support and distribution of events

Added:
    sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/observation/ExternalResourceListener.java
  (with props)
Modified:
    sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/observation/ResourceChange.java
    sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/observation/ResourceListener.java
    sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/observation/UserAwareResourceListener.java
    sling/trunk/bundles/api/src/main/java/org/apache/sling/spi/resource/provider/ObservationReporter.java

Added: sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/observation/ExternalResourceListener.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/observation/ExternalResourceListener.java?rev=1685501&view=auto
==============================================================================
--- sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/observation/ExternalResourceListener.java
(added)
+++ sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/observation/ExternalResourceListener.java
Mon Jun 15 06:25:38 2015
@@ -0,0 +1,30 @@
+/*
+ * 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.sling.api.resource.observation;
+
+import aQute.bnd.annotation.ConsumerType;
+
+/**
+ * This is a marker interface to receive external events.
+ */
+@ConsumerType
+public interface ExternalResourceListener {
+
+    // marker interface
+}

Propchange: sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/observation/ExternalResourceListener.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/observation/ExternalResourceListener.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision rev url

Modified: sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/observation/ResourceChange.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/observation/ResourceChange.java?rev=1685501&r1=1685500&r2=1685501&view=diff
==============================================================================
--- sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/observation/ResourceChange.java
(original)
+++ sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/observation/ResourceChange.java
Mon Jun 15 06:25:38 2015
@@ -40,15 +40,19 @@ public abstract class ResourceChange {
 
     private final String path;
     private final ChangeType changeType;
+    private final boolean isExternal;
 
     /**
      * Create a new change object
      * @param changeType The change type
      * @param path The resource path
      */
-    public ResourceChange(final @Nonnull ChangeType changeType, final @Nonnull String path)
{
+    public ResourceChange(final @Nonnull ChangeType changeType,
+            final @Nonnull String path,
+            final boolean isExternal) {
         this.path = path;
         this.changeType = changeType;
+        this.isExternal = isExternal;
     }
 
     /**
@@ -68,6 +72,13 @@ public abstract class ResourceChange {
     }
 
     /**
+     * Is this an external event?
+     * @return {@code true} if the event is external.
+     */
+    public boolean isExternal() {
+        return this.isExternal;
+    }
+    /**
      * Get the resource type.
      * TODO Clarify when this might be available - and as this is lazy
      *      it might not be available even for added/changed resources.

Modified: sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/observation/ResourceListener.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/observation/ResourceListener.java?rev=1685501&r1=1685500&r2=1685501&view=diff
==============================================================================
--- sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/observation/ResourceListener.java
(original)
+++ sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/observation/ResourceListener.java
Mon Jun 15 06:25:38 2015
@@ -39,6 +39,12 @@ import aQute.bnd.annotation.ConsumerType
  * {@code ResourceListener} objects must be registered with a service property
  * {@link ResourceListener#PATHS} whose value is the list of resource paths for which
  * the listener is interested in getting change events.
+ *
+ * <p>
+ * By default a resource listener gets only local events which means events
+ * caused by changes persisted on the same instance as this listener is registered.
+ * If the resource listener is interested in external events, the implementation
+ * should implement the {@link ExternalResourceListener} interface.
  */
 @ConsumerType
 public interface ResourceListener {

Modified: sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/observation/UserAwareResourceListener.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/observation/UserAwareResourceListener.java?rev=1685501&r1=1685500&r2=1685501&view=diff
==============================================================================
--- sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/observation/UserAwareResourceListener.java
(original)
+++ sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/observation/UserAwareResourceListener.java
Mon Jun 15 06:25:38 2015
@@ -30,6 +30,11 @@ import aQute.bnd.annotation.ConsumerType
  * A resource listener which allows to act on the changes in the context of the user
  * who initiated the changes. If that information is not known, a resolver using the
  * access rights of a configured service user is used.
+ * <p>
+ * By default a resource listener gets only local events which means events
+ * caused by changes persisted on the same instance as this listener is registered.
+ * If the resource listener is interested in external events, the implementation
+ * should implement the {@link ExternalResourceListener} interface.
  */
 @ConsumerType
 public interface UserAwareResourceListener {

Modified: sling/trunk/bundles/api/src/main/java/org/apache/sling/spi/resource/provider/ObservationReporter.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/api/src/main/java/org/apache/sling/spi/resource/provider/ObservationReporter.java?rev=1685501&r1=1685500&r2=1685501&view=diff
==============================================================================
--- sling/trunk/bundles/api/src/main/java/org/apache/sling/spi/resource/provider/ObservationReporter.java
(original)
+++ sling/trunk/bundles/api/src/main/java/org/apache/sling/spi/resource/provider/ObservationReporter.java
Mon Jun 15 06:25:38 2015
@@ -33,5 +33,14 @@ import aQute.bnd.annotation.ProviderType
 @ProviderType
 public interface ObservationReporter {
 
-    void reportChanges(@Nonnull List<ResourceChange> changes);
+    /**
+     * A resource provider can inform about a list of changes.
+     * If the resource provider is not able to report external events on other instances,
+     * it should set the distribute flag. In this case the resource resolver implementation
+     * will distribute the events to all other instances.
+     *
+     * @param changes The list of changes.
+     * @param distribute Whether the changes should be distributed to other instances.
+     */
+    void reportChanges(@Nonnull List<ResourceChange> changes, boolean distribute);
 }



Mime
View raw message