Author: cziegeler
Date: Tue May 12 07:21:03 2015
New Revision: 1678881

URL: http://svn.apache.org/r1678881
Log:
Update observation interfaces

Modified:
    
sling/whiteboard/cziegeler/api-v3/src/main/java/org/apache/sling/api/resource/observation/ResourceChange.java
    
sling/whiteboard/cziegeler/api-v3/src/main/java/org/apache/sling/api/resource/observation/ResourceListener.java
    
sling/whiteboard/cziegeler/api-v3/src/main/java/org/apache/sling/api/resource/observation/UserAwareResourceListener.java
    
sling/whiteboard/cziegeler/api-v3/src/main/java/org/apache/sling/api/resource/provider/ObservationReporter.java

Modified: 
sling/whiteboard/cziegeler/api-v3/src/main/java/org/apache/sling/api/resource/observation/ResourceChange.java
URL: 
http://svn.apache.org/viewvc/sling/whiteboard/cziegeler/api-v3/src/main/java/org/apache/sling/api/resource/observation/ResourceChange.java?rev=1678881&r1=1678880&r2=1678881&view=diff
==============================================================================
--- 
sling/whiteboard/cziegeler/api-v3/src/main/java/org/apache/sling/api/resource/observation/ResourceChange.java
 (original)
+++ 
sling/whiteboard/cziegeler/api-v3/src/main/java/org/apache/sling/api/resource/observation/ResourceChange.java
 Tue May 12 07:21:03 2015
@@ -21,36 +21,9 @@ package org.apache.sling.api.resource.ob
 /**
  * TODO properties, added/changed/removed, see SlingConstants
  *
- * TODO Should we make this an interface? This would allow lazy evaluation of 
information and
- * improve performance if the info is not needed
+ * TODO How do we handle resource provider changes? Currently we have two OSGi 
events: add/remove with the path
  */
-public class ResourceChange {
-
-    private final ChangeType type;
-
-    private final String path;
-
-    private final String userId;
-
-    private final String resourceType;
-
-    public String getPath() {
-        return path;
-    }
-
-    public String getUserId() {
-        return userId;
-    }
-
-    public String getResourceType() {
-        return resourceType;
-    }
-
-    public String getResourceSuperType() {
-        return resourceSuperType;
-    }
-
-    private final String resourceSuperType;
+public interface ResourceChange {
 
     public enum ChangeType {
         ADDED,
@@ -58,46 +31,54 @@ public class ResourceChange {
         CHANGED
     }
 
-    public ChangeType getType() {
-        return this.type;
-    }
-
-    private ResourceChange(final ChangeType type,
-            final String path,
-            final String userId,
-            final String resourceType,
-            final String resourceSuperType) {
-        this.type = type;
-        this.path = path;
-        this.userId = userId;
-        this.resourceType = resourceType;
-        this.resourceSuperType = resourceSuperType;
-    }
-
-    public static ResourceChange resourceChanged(String path,
-            String userId,
-            String resourceType,
-            String resourceSuperType) {
-        return new ResourceChange(ChangeType.CHANGED,
-                path,
-                userId, resourceType, resourceSuperType);
-    }
-
-    public static ResourceChange resourceAdded(String path,
-            String userId,
-            String resourceType,
-            String resourceSuperType) {
-        return new ResourceChange(ChangeType.ADDED,
-                path,
-                userId, resourceType, resourceSuperType);
-    }
-
-    public static ResourceChange resourceRemoved(String path,
-            String userId,
-            String resourceType,
-            String resourceSuperType) {
-        return new ResourceChange(ChangeType.REMOVED,
-                path,
-                userId, resourceType, resourceSuperType);
-    }
+    /**
+     * Get the resource path.
+     * @return The path to the resource.
+     */
+    String getPath();
+
+    /**
+     * Get the user id of the user initiating the change
+     * @return The user id or {@code null} if it's not available.
+     */
+    String getUserId();
+
+    /**
+     * 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.
+     * @return The resource type or {@code null}
+     */
+    String getResourceType();
+
+    /**
+     * Get the super resource type.
+     * @return The super resource type or {@code null}
+     * TODO Do we really need this?
+     */
+    String getResourceSuperType();
+
+    /**
+     * Get the type of change
+     * @return The type of change
+     */
+    ChangeType getType();
+
+    /**
+     * Optional information about changed properties.
+     * TODO Clarify when these might be available.
+     */
+    String[] getChangedAttributeNames();
+
+    /**
+     * Optional information about added properties.
+     * TODO Clarify when these might be available.
+     */
+    String[] getAddedAttributeNames();
+
+    /**
+     * Optional information about removed properties.
+     * TODO Clarify when these might be available.
+     */
+    String[] getRemovedAttributeNames();
 }

Modified: 
sling/whiteboard/cziegeler/api-v3/src/main/java/org/apache/sling/api/resource/observation/ResourceListener.java
URL: 
http://svn.apache.org/viewvc/sling/whiteboard/cziegeler/api-v3/src/main/java/org/apache/sling/api/resource/observation/ResourceListener.java?rev=1678881&r1=1678880&r2=1678881&view=diff
==============================================================================
--- 
sling/whiteboard/cziegeler/api-v3/src/main/java/org/apache/sling/api/resource/observation/ResourceListener.java
 (original)
+++ 
sling/whiteboard/cziegeler/api-v3/src/main/java/org/apache/sling/api/resource/observation/ResourceListener.java
 Tue May 12 07:21:03 2015
@@ -18,23 +18,41 @@
  */
 package org.apache.sling.api.resource.observation;
 
+import java.util.List;
+
 import javax.annotation.Nonnull;
 
 import aQute.bnd.annotation.ConsumerType;
 
+/**
+ * Listener for resource events.
+ *
+ * <p>
+ * {@code ResourceListener} objects are registered with the Framework service
+ * registry and are notified with {@code ResourceChange} objects when a
+ * change occurs.
+ * <p>
+ * {@code ResourceListener} objects can inspect the received {@code 
ResourceChange} objects to
+ * determine the type of change, location and other properties.
+ *
+ * <p>
+ * {@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.
+ */
 @ConsumerType
 public interface ResourceListener {
 
-    /** TODO - define service registration properties for filtering. */
-
     /** Array of paths - required. */
     String PATHS = "resource.paths";
 
-    /** Array of types, optional. */
+    /** Array of types, optional.
+     * TODO - does this make sense, as remove events usually do not have the 
info?
+     * */
     String TYPES = "resource.types";
 
     /** LDAP style filter matching against properties. - TODO do we need this? 
*/
     String FILTER = "resource.filter";
 
-    void onChange(@Nonnull ResourceChange change);
+    void onChange(@Nonnull List<ResourceChange> changes);
 }

Modified: 
sling/whiteboard/cziegeler/api-v3/src/main/java/org/apache/sling/api/resource/observation/UserAwareResourceListener.java
URL: 
http://svn.apache.org/viewvc/sling/whiteboard/cziegeler/api-v3/src/main/java/org/apache/sling/api/resource/observation/UserAwareResourceListener.java?rev=1678881&r1=1678880&r2=1678881&view=diff
==============================================================================
--- 
sling/whiteboard/cziegeler/api-v3/src/main/java/org/apache/sling/api/resource/observation/UserAwareResourceListener.java
 (original)
+++ 
sling/whiteboard/cziegeler/api-v3/src/main/java/org/apache/sling/api/resource/observation/UserAwareResourceListener.java
 Tue May 12 07:21:03 2015
@@ -18,6 +18,8 @@
  */
 package org.apache.sling.api.resource.observation;
 
+import java.util.List;
+
 import javax.annotation.Nonnull;
 
 import org.apache.sling.api.resource.ResourceResolver;
@@ -30,16 +32,7 @@ import aQute.bnd.annotation.ConsumerType
 @ConsumerType
 public interface UserAwareResourceListener {
 
-    /** TODO - define service registration properties for filtering. */
-
-    /** Array of paths - required. */
-    String PATHS = "resource.paths";
-
-    /** Array of types, optional. */
-    String TYPES = "resource.types";
-
-    /** LDAP style filter matching against properties. - TODO do we need this? 
*/
-    String FILTER = "resource.filter";
+    /** TODO - define service registration properties for filtering. we can 
copy those from ResourceListener */
 
-    void onChange(@Nonnull ResourceResolver resolver, @Nonnull ResourceChange 
change);
+    void onChange(@Nonnull ResourceResolver resolver, @Nonnull 
List<ResourceChange> changes);
 }

Modified: 
sling/whiteboard/cziegeler/api-v3/src/main/java/org/apache/sling/api/resource/provider/ObservationReporter.java
URL: 
http://svn.apache.org/viewvc/sling/whiteboard/cziegeler/api-v3/src/main/java/org/apache/sling/api/resource/provider/ObservationReporter.java?rev=1678881&r1=1678880&r2=1678881&view=diff
==============================================================================
--- 
sling/whiteboard/cziegeler/api-v3/src/main/java/org/apache/sling/api/resource/provider/ObservationReporter.java
 (original)
+++ 
sling/whiteboard/cziegeler/api-v3/src/main/java/org/apache/sling/api/resource/provider/ObservationReporter.java
 Tue May 12 07:21:03 2015
@@ -18,6 +18,8 @@
  */
 package org.apache.sling.api.resource.provider;
 
+import java.util.List;
+
 import javax.annotation.Nonnull;
 
 import org.apache.sling.api.resource.observation.ResourceChange;
@@ -29,5 +31,5 @@ import aQute.bnd.annotation.ProviderType
 @ProviderType
 public interface ObservationReporter {
 
-    void reportChanges(@Nonnull ResourceChange... changes);
+    void reportChanges(@Nonnull List<ResourceChange> changes);
 }


Reply via email to