You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2017/11/07 09:19:21 UTC

[sling-org-apache-sling-caconfig-spi] 05/14: SLING-6244 : Provide an SPI for influencing the collection inheritance

This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.caconfig.spi-1.1.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-caconfig-spi.git

commit a314df0ae1080f5bd18bc0f4efd42e6c74ab3e6e
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Fri Nov 4 15:17:44 2016 +0000

    SLING-6244 : Provide an SPI for influencing the collection inheritance
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/contextaware-config/spi@1768050 13f79535-47bb-0310-9956-ffa450edef68
---
 ...info.java => CollectionInheritanceDecider.java} | 26 +++++++++++++++++++---
 .../ConfigurationResourceResolvingStrategy.java    | 20 ++++++++++-------
 ...{package-info.java => InheritanceDecision.java} | 14 +++++++++---
 .../sling/caconfig/resource/spi/package-info.java  |  2 +-
 4 files changed, 47 insertions(+), 15 deletions(-)

diff --git a/src/main/java/org/apache/sling/caconfig/resource/spi/package-info.java b/src/main/java/org/apache/sling/caconfig/resource/spi/CollectionInheritanceDecider.java
similarity index 54%
copy from src/main/java/org/apache/sling/caconfig/resource/spi/package-info.java
copy to src/main/java/org/apache/sling/caconfig/resource/spi/CollectionInheritanceDecider.java
index 37d917c..0620967 100644
--- a/src/main/java/org/apache/sling/caconfig/resource/spi/package-info.java
+++ b/src/main/java/org/apache/sling/caconfig/resource/spi/CollectionInheritanceDecider.java
@@ -16,8 +16,28 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+package org.apache.sling.caconfig.resource.spi;
+
+import org.apache.sling.api.resource.Resource;
+import org.osgi.annotation.versioning.ConsumerType;
+
 /**
- * SPI for applications hooking into the configuration resource infrastructure for parameterizing and customizing.
+ * The {@code CollectionInheritanceDecider} is an SPI which should be used by
+ * all {@link ConfigurationResourceResolvingStrategy} implementations if they
+ * support inheritance for collections.
+ *
+ * @since 1.1
  */
-@org.osgi.annotation.versioning.Version("1.0.0")
-package org.apache.sling.caconfig.resource.spi;
+@ConsumerType
+public interface CollectionInheritanceDecider {
+
+    /**
+     * Decide whether the provided resource should be included in the collection.
+     * The provided resource can either be included, excluded or blocked.
+     *
+     * @param bucketName The bucket name
+     * @param resource The resource
+     * @return The decision.
+     */
+    InheritanceDecision decide(String bucketName, Resource resource);
+}
diff --git a/src/main/java/org/apache/sling/caconfig/resource/spi/ConfigurationResourceResolvingStrategy.java b/src/main/java/org/apache/sling/caconfig/resource/spi/ConfigurationResourceResolvingStrategy.java
index d39814f..1618d3c 100644
--- a/src/main/java/org/apache/sling/caconfig/resource/spi/ConfigurationResourceResolvingStrategy.java
+++ b/src/main/java/org/apache/sling/caconfig/resource/spi/ConfigurationResourceResolvingStrategy.java
@@ -29,6 +29,10 @@ import org.osgi.annotation.versioning.ConsumerType;
 /**
  * Defines how and where the configuration resources are looked up.
  * This SPI allows application to define their own configuration storage and inheritance strategies.
+ *
+ * If this strategy supports inheritance for collections, it should use the optional
+ * {@link CollectionInheritanceDecider} SPI interface. If such a service is available, it should
+ * be called.
  */
 @ConsumerType
 public interface ConfigurationResourceResolvingStrategy {
@@ -36,7 +40,7 @@ public interface ConfigurationResourceResolvingStrategy {
     /**
      * Get a context-aware singleton configuration resource defined by the given configuration name.
      * @param resource Context resource to fetch configuration for
-     * @param bucketName Configuration "bucket" name. Each high-level configuration resolver should store 
+     * @param bucketName Configuration "bucket" name. Each high-level configuration resolver should store
      *     it's configuration data grouped in a child resource of the configuration resource. This is what
      *     we call a "bucket", and the resource name is specified with this parameter.
      * @param configName Configuration name or relative path.
@@ -47,20 +51,20 @@ public interface ConfigurationResourceResolvingStrategy {
     /**
      * Get a collection of context-aware configuration resources defined by the given configuration name.
      * @param resource Context resource to fetch configuration for
-     * @param bucketName Configuration "bucket" name. Each high-level configuration resolver should store 
+     * @param bucketName Configuration "bucket" name. Each high-level configuration resolver should store
      *     it's configuration data grouped in a child resource of the configuration resource. This is what
      *     we call a "bucket", and the resource name is specified with this parameter.
      * @param configName Configuration name or relative path.
      * @return Collection of configuration resources, the collection might be empty.
      */
     @Nonnull Collection<Resource> getResourceCollection(@Nonnull Resource resource, @Nonnull String bucketName, @Nonnull String configName);
-    
+
     /**
      * Get the configuration resource path for storing configuration data for the given context resource and configuration name.
      * This path is used when no configuration resource exists yet, but new configuration data should be stored.
-     * So usually the returned path does not yet exist (and perhaps not even it's parents). 
+     * So usually the returned path does not yet exist (and perhaps not even it's parents).
      * @param resource Context resource to fetch configuration for
-     * @param bucketName Configuration "bucket" name. Each high-level configuration resolver should store 
+     * @param bucketName Configuration "bucket" name. Each high-level configuration resolver should store
      *     it's configuration data grouped in a child resource of the configuration resource. This is what
      *     we call a "bucket", and the resource name is specified with this parameter.
      * @param configName Configuration name or relative path.
@@ -71,14 +75,14 @@ public interface ConfigurationResourceResolvingStrategy {
     /**
      * Get the configuration resource collection parent path for storing configuration data for the given context resource and configuration name.
      * This path is used when no configuration resource collection exists yet, but new configuration data should be stored.
-     * So usually the returned path does not yet exist (and perhaps not even it's parents). 
+     * So usually the returned path does not yet exist (and perhaps not even it's parents).
      * @param resource Context resource to fetch configuration for
-     * @param bucketName Configuration "bucket" name. Each high-level configuration resolver should store 
+     * @param bucketName Configuration "bucket" name. Each high-level configuration resolver should store
      *     it's configuration data grouped in a child resource of the configuration resource. This is what
      *     we call a "bucket", and the resource name is specified with this parameter.
      * @param configName Configuration name or relative path.
      * @return Resource path, or null if no matching configuration resource path can be determined
      */
     @CheckForNull String getResourceCollectionParentPath(@Nonnull Resource resource, @Nonnull String bucketName, @Nonnull String configName);
-    
+
 }
diff --git a/src/main/java/org/apache/sling/caconfig/resource/spi/package-info.java b/src/main/java/org/apache/sling/caconfig/resource/spi/InheritanceDecision.java
similarity index 75%
copy from src/main/java/org/apache/sling/caconfig/resource/spi/package-info.java
copy to src/main/java/org/apache/sling/caconfig/resource/spi/InheritanceDecision.java
index 37d917c..ce60f5f 100644
--- a/src/main/java/org/apache/sling/caconfig/resource/spi/package-info.java
+++ b/src/main/java/org/apache/sling/caconfig/resource/spi/InheritanceDecision.java
@@ -16,8 +16,16 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+package org.apache.sling.caconfig.resource.spi;
+
 /**
- * SPI for applications hooking into the configuration resource infrastructure for parameterizing and customizing.
+ * Return values for {@link CollectionInheritanceDecider}.
+ *
+ * @since 1.1
  */
-@org.osgi.annotation.versioning.Version("1.0.0")
-package org.apache.sling.caconfig.resource.spi;
+public enum InheritanceDecision {
+
+    INCLUDE, // include the resource.
+    EXCLUDE, // exclude the resource, but allow others to provide it.
+    BLOCK    // exclude the resource, no one else can provide it.
+}
diff --git a/src/main/java/org/apache/sling/caconfig/resource/spi/package-info.java b/src/main/java/org/apache/sling/caconfig/resource/spi/package-info.java
index 37d917c..64c8fa3 100644
--- a/src/main/java/org/apache/sling/caconfig/resource/spi/package-info.java
+++ b/src/main/java/org/apache/sling/caconfig/resource/spi/package-info.java
@@ -19,5 +19,5 @@
 /**
  * SPI for applications hooking into the configuration resource infrastructure for parameterizing and customizing.
  */
-@org.osgi.annotation.versioning.Version("1.0.0")
+@org.osgi.annotation.versioning.Version("1.1.0")
 package org.apache.sling.caconfig.resource.spi;

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.