sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From romb...@apache.org
Subject [sling-org-apache-sling-testing-caconfig-mock-plugin] 03/23: SLING-6670 Support CAConfig Impl 1.3.0
Date Wed, 18 Oct 2017 23:28:48 GMT
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-caconfig-mock-plugin.git

commit 1846e2d63808f6515d35636b01305aac4eff9d94
Author: Stefan Seifert <sseifert@apache.org>
AuthorDate: Sun Mar 19 14:59:51 2017 +0000

    SLING-6670 Support CAConfig Impl 1.3.0
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1787628 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml                                            | 53 ++++++++++++++++++++++
 .../testing/mock/caconfig/ContextPlugins.java      | 23 ++++++++--
 2 files changed, 71 insertions(+), 5 deletions(-)

diff --git a/pom.xml b/pom.xml
index d8ada57..9164f43 100644
--- a/pom.xml
+++ b/pom.xml
@@ -53,18 +53,21 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.caconfig.api</artifactId>
+            <!-- Stick with dependency version 1.1.0 as it was released with caconfig-mock-plugin
1.0.0 -->
             <version>1.1.0</version>
             <scope>compile</scope>
         </dependency>
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.caconfig.spi</artifactId>
+            <!-- Stick with dependency version 1.2.0 as it was released with caconfig-mock-plugin
1.0.0 -->
             <version>1.2.0</version>
             <scope>compile</scope>
         </dependency>
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.caconfig.impl</artifactId>
+            <!-- Stick with dependency version 1.2.0 as it was released with caconfig-mock-plugin
1.0.0 -->
             <version>1.2.0</version>
             <scope>compile</scope>
         </dependency>
@@ -115,6 +118,56 @@
             </dependencies>
         </profile>
 
+        <!-- Test with Sling CAConfig Impl/SPI 1.2 -->
+        <profile>
+            <id>caconfig-1.2</id>
+            <dependencies>
+                <dependency>
+                    <groupId>org.apache.sling</groupId>
+                    <artifactId>org.apache.sling.caconfig.api</artifactId>
+                    <version>1.1.0</version>
+                    <scope>compile</scope>
+                </dependency>
+                <dependency>
+                    <groupId>org.apache.sling</groupId>
+                    <artifactId>org.apache.sling.caconfig.spi</artifactId>
+                    <version>1.2.0</version>
+                    <scope>compile</scope>
+                </dependency>
+                <dependency>
+                    <groupId>org.apache.sling</groupId>
+                    <artifactId>org.apache.sling.caconfig.impl</artifactId>
+                    <version>1.2.0</version>
+                    <scope>compile</scope>
+                </dependency>
+            </dependencies>
+        </profile>
+
+        <!-- Test with Sling CAConfig Impl/SPI 1.3 -->
+        <profile>
+            <id>caconfig-1.3</id>
+            <dependencies>
+                <dependency>
+                    <groupId>org.apache.sling</groupId>
+                    <artifactId>org.apache.sling.caconfig.api</artifactId>
+                    <version>1.1.0</version>
+                    <scope>compile</scope>
+                </dependency>
+                <dependency>
+                    <groupId>org.apache.sling</groupId>
+                    <artifactId>org.apache.sling.caconfig.spi</artifactId>
+                    <version>1.2.1-SNAPSHOT</version>
+                    <scope>compile</scope>
+                </dependency>
+                <dependency>
+                    <groupId>org.apache.sling</groupId>
+                    <artifactId>org.apache.sling.caconfig.impl</artifactId>
+                    <version>1.2.1-SNAPSHOT</version>
+                    <scope>compile</scope>
+                </dependency>
+            </dependencies>
+        </profile>
+
     </profiles>
 
 </project>
diff --git a/src/main/java/org/apache/sling/testing/mock/caconfig/ContextPlugins.java b/src/main/java/org/apache/sling/testing/mock/caconfig/ContextPlugins.java
index dc06a59..6a24e0a 100644
--- a/src/main/java/org/apache/sling/testing/mock/caconfig/ContextPlugins.java
+++ b/src/main/java/org/apache/sling/testing/mock/caconfig/ContextPlugins.java
@@ -24,7 +24,6 @@ import org.apache.sling.caconfig.impl.def.DefaultConfigurationPersistenceStrateg
 import org.apache.sling.caconfig.impl.metadata.AnnotationClassConfigurationMetadataProvider;
 import org.apache.sling.caconfig.impl.metadata.ConfigurationMetadataProviderMultiplexer;
 import org.apache.sling.caconfig.management.impl.ConfigurationManagerImpl;
-import org.apache.sling.caconfig.management.impl.ConfigurationPersistenceStrategyMultiplexer;
 import org.apache.sling.caconfig.resource.impl.ConfigurationResourceResolverImpl;
 import org.apache.sling.caconfig.resource.impl.ConfigurationResourceResolvingStrategyMultiplexer;
 import org.apache.sling.caconfig.resource.impl.def.DefaultConfigurationResourceResolvingStrategy;
@@ -36,7 +35,7 @@ import org.osgi.annotation.versioning.ProviderType;
 
 /**
  * Mock context plugins.
- * The plugin supports both 1.0/1.1 and 1.2+ version of the Impl/SPI.
+ * The plugin supports all versions from 1.0 to the most recent versions of the Impl/SPI.
  */
 @ProviderType
 public final class ContextPlugins {
@@ -82,7 +81,7 @@ public final class ContextPlugins {
         
         if (!registerByClassName(context, "org.apache.sling.caconfig.management.impl.ContextPathStrategyMultiplexerImpl"))
{
             // fallback to impl 1.1
-            registerByClassName(context, "org.apache.sling.caconfig.resource.impl.ContextPathStrategyMultiplexer");
+            registerByClassName(context, "org.apache.sling.caconfig.resource.impl.ContextPathStrategyMultiplexer",
true);
         }
         
         context.registerInjectActivateService(new ConfigurationResourceResolvingStrategyMultiplexer());
@@ -103,7 +102,12 @@ public final class ContextPlugins {
      * @param context Sling context
      */
     private static void registerConfigurationResolver(SlingContextImpl context) {
-        context.registerInjectActivateService(new ConfigurationPersistenceStrategyMultiplexer());
+        
+        if (!registerByClassName(context, "org.apache.sling.caconfig.management.impl.ConfigurationPersistenceStrategyMultiplexerImpl"))
{
+            // fallback to impl 1.2
+            registerByClassName(context, "org.apache.sling.caconfig.management.impl.ConfigurationPersistenceStrategyMultiplexer",
true);
+        }
+
         context.registerInjectActivateService(new ConfigurationMetadataProviderMultiplexer());
         
         // only required for impl 1.2+
@@ -133,13 +137,22 @@ public final class ContextPlugins {
     }
 
     private static boolean registerByClassName(SlingContextImpl context, String className)
{
+        return registerByClassName(context, className, false);
+    }
+
+    private static boolean registerByClassName(SlingContextImpl context, String className,
boolean mandatory) {
         try {
             Class<?> clazz = Class.forName(className);
             context.registerInjectActivateService(clazz.newInstance());
             return true;
         }
         catch (ClassNotFoundException ex) {
-            return false;
+            if (mandatory) {
+                throw new RuntimeException(ex.getMessage(), ex);
+            }
+            else {
+                return false;
+            }
         }
         catch (InstantiationException ex) {
             throw new RuntimeException(ex);

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

Mime
View raw message