Author: stefanegli Date: Mon Oct 17 11:36:15 2016 New Revision: 1765246 URL: http://svn.apache.org/viewvc?rev=1765246&view=rev Log: SLING-6164 : Introduce support for an optional property names hint to ResourceChangeListener
Modified: sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/observation/ResourceChangeListener.java sling/trunk/bundles/api/src/main/java/org/apache/sling/spi/resource/provider/ObserverConfiguration.java sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/AbstractListenerTest.java sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/JcrResourceListenerScalabilityTest.java sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/observation/BasicObserverConfiguration.java Modified: sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/observation/ResourceChangeListener.java URL: http://svn.apache.org/viewvc/sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/observation/ResourceChangeListener.java?rev=1765246&r1=1765245&r2=1765246&view=diff ============================================================================== --- sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/observation/ResourceChangeListener.java (original) +++ sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/observation/ResourceChangeListener.java Mon Oct 17 11:36:15 2016 @@ -93,6 +93,16 @@ public interface ResourceChangeListener * {@link ResourceChange.ChangeType}. */ String CHANGES = "resource.change.types"; + + /** + * An optional hint indicating to the underlying that for + * changes regarding properties (added/removed/changed) the listener + * is only interested in those property names listed inhere. + * If the underlying supports this, events for property names that + * are not enlisted here will not be delivered, however events + * concerning nodes are not affected by this hint. + */ + String PROPERTY_NAMES_HINT = "resource.property.names.hint"; /** * Report resource changes based on the filter properties of this listener. Modified: sling/trunk/bundles/api/src/main/java/org/apache/sling/spi/resource/provider/ObserverConfiguration.java URL: http://svn.apache.org/viewvc/sling/trunk/bundles/api/src/main/java/org/apache/sling/spi/resource/provider/ObserverConfiguration.java?rev=1765246&r1=1765245&r2=1765246&view=diff ============================================================================== --- sling/trunk/bundles/api/src/main/java/org/apache/sling/spi/resource/provider/ObserverConfiguration.java (original) +++ sling/trunk/bundles/api/src/main/java/org/apache/sling/spi/resource/provider/ObserverConfiguration.java Mon Oct 17 11:36:15 2016 @@ -61,6 +61,15 @@ public interface ObserverConfiguration { @Nonnull Set<ResourceChange.ChangeType> getChangeTypes(); /** + * Set containing the set of property names which + * serves as an optional hint for the underlying to + * only report property changes enlisted, ie the + * underlying might ignore this. + * @return set containing the set of property names + */ + @Nonnull Set<String> getPropertyNamesHint(); + + /** * Checks whether a path matches one of the paths of this configuration * but is not in the excluded paths set. * @param path The path to check Modified: sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/AbstractListenerTest.java URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/AbstractListenerTest.java?rev=1765246&r1=1765245&r2=1765246&view=diff ============================================================================== --- sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/AbstractListenerTest.java (original) +++ sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/AbstractListenerTest.java Mon Oct 17 11:36:15 2016 @@ -164,6 +164,11 @@ public abstract class AbstractListenerTe public boolean matches(String path) { return true; } + + @Override + public Set<String> getPropertyNamesHint() { + return new HashSet<String>(); + } }; return Collections.singletonList(config); } Modified: sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/JcrResourceListenerScalabilityTest.java URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/JcrResourceListenerScalabilityTest.java?rev=1765246&r1=1765245&r2=1765246&view=diff ============================================================================== --- sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/JcrResourceListenerScalabilityTest.java (original) +++ sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/JcrResourceListenerScalabilityTest.java Mon Oct 17 11:36:15 2016 @@ -21,6 +21,7 @@ import static org.mockito.Mockito.when; import java.util.Collections; import java.util.EnumSet; +import java.util.HashSet; import java.util.List; import java.util.Set; @@ -138,6 +139,11 @@ public class JcrResourceListenerScalabil public boolean matches(String path) { return true; } + + @Override + public Set<String> getPropertyNamesHint() { + return new HashSet<String>(); + } }; return Collections.singletonList(config); } Modified: sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/observation/BasicObserverConfiguration.java URL: http://svn.apache.org/viewvc/sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/observation/BasicObserverConfiguration.java?rev=1765246&r1=1765245&r2=1765246&view=diff ============================================================================== --- sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/observation/BasicObserverConfiguration.java (original) +++ sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/observation/BasicObserverConfiguration.java Mon Oct 17 11:36:15 2016 @@ -33,6 +33,8 @@ public class BasicObserverConfiguration private final PathSet paths; private final PathSet excludedPaths; + + private final Set<String> propertyNamesHint = new HashSet<String>(); private final Set<ChangeType> changeTypes; @@ -81,4 +83,9 @@ public class BasicObserverConfiguration } return false; } + + @Override + public Set<String> getPropertyNamesHint() { + return propertyNamesHint; + } }