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:33 UTC
[sling-org-apache-sling-caconfig-spi] 02/23: SLING-6293 refactor
property inheritance out of DefaultConfigurationResourceResolvingStrategy
and create separate SPI and impl for it *this breaks backward compatibility
of package org.apache.sling.caconfig.resource.spi -> major version
increase*
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.2.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-caconfig-spi.git
commit 4e90c741cb79eb9d68bb29a1a57d2de9e87d9dce
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Thu Nov 17 17:50:36 2016 +0000
SLING-6293 refactor property inheritance out of DefaultConfigurationResourceResolvingStrategy and create separate SPI and impl for it
*this breaks backward compatibility of package org.apache.sling.caconfig.resource.spi -> major version increase*
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/contextaware-config/spi@1770249 13f79535-47bb-0310-9956-ffa450edef68
---
.../ConfigurationResourceResolvingStrategy.java | 31 +++++++++++++--
.../sling/caconfig/resource/spi/package-info.java | 4 +-
.../spi/ConfigurationInheritanceStrategy.java | 44 ++++++++++++++++++++++
.../apache/sling/caconfig/spi/package-info.java | 2 +-
4 files changed, 75 insertions(+), 6 deletions(-)
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 b639d3c..e161a36 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
@@ -19,6 +19,7 @@
package org.apache.sling.caconfig.resource.spi;
import java.util.Collection;
+import java.util.Iterator;
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
@@ -46,7 +47,7 @@ public interface ConfigurationResourceResolvingStrategy {
* 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 Configuration resource or {@code null}.
+ * @return Configuration resource or {@code null} if this strategy did not found matching resources.
*/
@CheckForNull Resource getResource(@Nonnull Resource resource, @Nonnull String bucketName, @Nonnull String configName);
@@ -57,9 +58,33 @@ public interface ConfigurationResourceResolvingStrategy {
* 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.
+ * @return Collection of configuration resources or {@code null} if this strategy did not found matching resources.
*/
- @Nonnull Collection<Resource> getResourceCollection(@Nonnull Resource resource, @Nonnull String bucketName, @Nonnull String configName);
+ @CheckForNull Collection<Resource> getResourceCollection(@Nonnull Resource resource, @Nonnull String bucketName, @Nonnull String configName);
+
+ /**
+ * Get a context-aware singleton configuration resource inheritance chain defined by the given configuration name.
+ * The first item of the inheritance chain it the same resource returned by {@link #getResource(Resource, String, String)}.
+ * @param resource Context resource to fetch configuration for
+ * @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 Configuration resource inheritance chain or {@code null} if this strategy did not found matching resources.
+ */
+ @CheckForNull Iterator<Resource> getResourceInheritanceChain(@Nonnull Resource resource, @Nonnull String bucketName, @Nonnull String configName);
+
+ /**
+ * Get a collection of context-aware configuration resource inheritance chains defined by the given configuration name.
+ * The first item of each inheritance chain is the same item returned by {@link #getResourceCollection(Resource, String, String)}.
+ * @param resource Context resource to fetch configuration for
+ * @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 resource inheritance chains or {@code null} if this strategy did not found matching resources.
+ */
+ @CheckForNull Collection<Iterator<Resource>> getResourceCollectionInheritanceChain(@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.
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 64c8fa3..28049c1 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
@@ -1,4 +1,4 @@
-/*
+ /*
* 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
@@ -19,5 +19,5 @@
/**
* SPI for applications hooking into the configuration resource infrastructure for parameterizing and customizing.
*/
-@org.osgi.annotation.versioning.Version("1.1.0")
+@org.osgi.annotation.versioning.Version("2.0.0")
package org.apache.sling.caconfig.resource.spi;
diff --git a/src/main/java/org/apache/sling/caconfig/spi/ConfigurationInheritanceStrategy.java b/src/main/java/org/apache/sling/caconfig/spi/ConfigurationInheritanceStrategy.java
new file mode 100644
index 0000000..3ad58d7
--- /dev/null
+++ b/src/main/java/org/apache/sling/caconfig/spi/ConfigurationInheritanceStrategy.java
@@ -0,0 +1,44 @@
+/*
+ * 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.caconfig.spi;
+
+import java.util.Iterator;
+
+import javax.annotation.CheckForNull;
+import javax.annotation.Nonnull;
+
+import org.apache.sling.api.resource.Resource;
+import org.osgi.annotation.versioning.ConsumerType;
+
+/**
+ * Defines how (and if) resources in a resource hierarchy should inherit form each other.
+ * Primary use case is property inheritance over the inheritance chain.
+ */
+@ConsumerType
+public interface ConfigurationInheritanceStrategy {
+
+ /**
+ * Pick or merge resources for inheritance.
+ * @param configResources Iterator of configuration resources that form the inheritance hierarchy.
+ * First resource is the "closest" match, the other resources may be used to inherit from.
+ * @return Inherited resource or null if this strategy does not support the given resources
+ */
+ @CheckForNull Resource getResource(@Nonnull Iterator<Resource> configResources);
+
+}
diff --git a/src/main/java/org/apache/sling/caconfig/spi/package-info.java b/src/main/java/org/apache/sling/caconfig/spi/package-info.java
index a127939..69d6ad1 100644
--- a/src/main/java/org/apache/sling/caconfig/spi/package-info.java
+++ b/src/main/java/org/apache/sling/caconfig/spi/package-info.java
@@ -19,5 +19,5 @@
/**
* SPI for applications hooking into the configuration 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.spi;
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.