sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject [sling-whiteboard] branch master updated: Move Sling specific constants into support module
Date Tue, 17 Apr 2018 08:31:12 GMT
This is an automated email from the ASF dual-hosted git repository.

cziegeler pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-whiteboard.git


The following commit(s) were added to refs/heads/master by this push:
     new bb5f6cf  Move Sling specific constants into support module
bb5f6cf is described below

commit bb5f6cf159ed7f98b40940846657c0a2de40567b
Author: Carsten Ziegeler <cziegeler@apache.org>
AuthorDate: Tue Apr 17 10:31:04 2018 +0200

    Move Sling specific constants into support module
---
 .../impl/ContentPackagesExtensionScanner.java      |  3 +-
 .../feature/scanner/impl/RepoInitScanner.java      | 10 ++----
 .../sling/feature/karaf/KarafFeatureWriter.java    |  5 +--
 .../feature/launcher/impl/FeatureProcessor.java    |  5 +--
 .../modelconverter/impl/FeatureToProvisioning.java | 37 ++++++++++----------
 .../modelconverter/impl/ProvisioningToFeature.java | 39 +++++++++++-----------
 .../sling/feature/support/ConfigurationUtil.java   | 11 +++---
 .../apache/sling/feature/support/FeatureUtil.java  |  2 +-
 .../sling/feature/support/SlingConstants.java      | 37 ++++++++++++++++++++
 .../java/org/apache/sling/feature/Extension.java   |  6 ----
 10 files changed, 92 insertions(+), 63 deletions(-)

diff --git a/featuremodel/feature-analyser/src/main/java/org/apache/sling/feature/scanner/impl/ContentPackagesExtensionScanner.java
b/featuremodel/feature-analyser/src/main/java/org/apache/sling/feature/scanner/impl/ContentPackagesExtensionScanner.java
index ec799be..70b81b2 100644
--- a/featuremodel/feature-analyser/src/main/java/org/apache/sling/feature/scanner/impl/ContentPackagesExtensionScanner.java
+++ b/featuremodel/feature-analyser/src/main/java/org/apache/sling/feature/scanner/impl/ContentPackagesExtensionScanner.java
@@ -25,6 +25,7 @@ import org.apache.sling.feature.Extension;
 import org.apache.sling.feature.ExtensionType;
 import org.apache.sling.feature.analyser.ContainerDescriptor;
 import org.apache.sling.feature.scanner.ExtensionScanner;
+import org.apache.sling.feature.support.SlingConstants;
 import org.apache.sling.feature.support.artifact.ArtifactManager;
 
 public class ContentPackagesExtensionScanner implements ExtensionScanner {
@@ -43,7 +44,7 @@ public class ContentPackagesExtensionScanner implements ExtensionScanner
{
     public ContainerDescriptor scan(final Extension extension,
             final ArtifactManager artifactManager)
     throws IOException {
-        if (!Extension.NAME_CONTENT_PACKAGES.equals(extension.getName()) ) {
+        if (!SlingConstants.EXTENSION_NAME_CONTENT_PACKAGES.equals(extension.getName()) )
{
             return null;
         }
         if ( extension.getType() != ExtensionType.ARTIFACTS ) {
diff --git a/featuremodel/feature-analyser/src/main/java/org/apache/sling/feature/scanner/impl/RepoInitScanner.java
b/featuremodel/feature-analyser/src/main/java/org/apache/sling/feature/scanner/impl/RepoInitScanner.java
index cd9c58a..41dafd7 100644
--- a/featuremodel/feature-analyser/src/main/java/org/apache/sling/feature/scanner/impl/RepoInitScanner.java
+++ b/featuremodel/feature-analyser/src/main/java/org/apache/sling/feature/scanner/impl/RepoInitScanner.java
@@ -17,15 +17,13 @@
 package org.apache.sling.feature.scanner.impl;
 
 import java.io.IOException;
-import java.util.Collections;
 
 import org.apache.sling.feature.Extension;
 import org.apache.sling.feature.ExtensionType;
-import org.apache.sling.feature.OSGiRequirement;
 import org.apache.sling.feature.analyser.ContainerDescriptor;
 import org.apache.sling.feature.scanner.ExtensionScanner;
+import org.apache.sling.feature.support.SlingConstants;
 import org.apache.sling.feature.support.artifact.ArtifactManager;
-import org.osgi.resource.Requirement;
 
 public class RepoInitScanner implements ExtensionScanner {
 
@@ -43,7 +41,7 @@ public class RepoInitScanner implements ExtensionScanner {
     public ContainerDescriptor scan(final Extension extension,
             final ArtifactManager artifactManager)
     throws IOException {
-        if (!Extension.NAME_REPOINIT.equals(extension.getName()) ) {
+        if (!SlingConstants.EXTENSION_NAME_REPOINIT.equals(extension.getName()) ) {
             return null;
         }
         if ( extension.getType() != ExtensionType.TEXT ) {
@@ -52,9 +50,7 @@ public class RepoInitScanner implements ExtensionScanner {
 
         final ContainerDescriptor cd = new ContainerDescriptor() {};
 
-        final Requirement req = new OSGiRequirement("osgi.implementation", Collections.emptyMap(),
-            Collections.singletonMap("filter", "(&(osgi.implementation=org.apache.sling.jcr.repoinit)(version>=1.0)(!(version>=2.0)))"));
-        cd.getRequirements().add(req);
+        cd.getRequirements().add(SlingConstants.REQUIREMENT_REPOINIT);
 
         cd.lock();
 
diff --git a/featuremodel/feature-karaf/src/main/java/org/apache/sling/feature/karaf/KarafFeatureWriter.java
b/featuremodel/feature-karaf/src/main/java/org/apache/sling/feature/karaf/KarafFeatureWriter.java
index 38e0f74..14f8000 100644
--- a/featuremodel/feature-karaf/src/main/java/org/apache/sling/feature/karaf/KarafFeatureWriter.java
+++ b/featuremodel/feature-karaf/src/main/java/org/apache/sling/feature/karaf/KarafFeatureWriter.java
@@ -38,6 +38,7 @@ import org.apache.sling.feature.Configurations;
 import org.apache.sling.feature.Extension;
 import org.apache.sling.feature.Feature;
 import org.apache.sling.feature.support.ConfigurationUtil;
+import org.apache.sling.feature.support.SlingConstants;
 import org.apache.sling.feature.support.artifact.ArtifactHandler;
 import org.apache.sling.feature.support.artifact.ArtifactManager;
 
@@ -53,7 +54,7 @@ public class KarafFeatureWriter {
             final ArtifactManager artifactManager)
     throws IOException {
         // check for repoinit extension
-        final Extension repoinitExt = feature.getExtensions().getByName(Extension.NAME_REPOINIT);
+        final Extension repoinitExt = feature.getExtensions().getByName(SlingConstants.EXTENSION_NAME_REPOINIT);
         File configurationBundleFile = null;
         Artifact configuratorBundle = null;
         try {
@@ -74,7 +75,7 @@ public class KarafFeatureWriter {
                         map = null;
                     } else {
                         map = Collections.singletonMap("Require-Capability",
-                                ConfigurationUtil.REQUIRE_REPOINIT_CAPABILITY);
+                                SlingConstants.REQUIRE_REPOINIT_CAPABILITY);
                     }
                     ConfigurationUtil.createConfiguratorBundle(os,
                             configs,
diff --git a/featuremodel/feature-launcher/src/main/java/org/apache/sling/feature/launcher/impl/FeatureProcessor.java
b/featuremodel/feature-launcher/src/main/java/org/apache/sling/feature/launcher/impl/FeatureProcessor.java
index af52852..12c0dbe 100644
--- a/featuremodel/feature-launcher/src/main/java/org/apache/sling/feature/launcher/impl/FeatureProcessor.java
+++ b/featuremodel/feature-launcher/src/main/java/org/apache/sling/feature/launcher/impl/FeatureProcessor.java
@@ -32,6 +32,7 @@ import org.apache.sling.feature.ExtensionType;
 import org.apache.sling.feature.launcher.impl.LauncherConfig.StartupMode;
 import org.apache.sling.feature.resolver.FrameworkResolver;
 import org.apache.sling.feature.support.FeatureUtil;
+import org.apache.sling.feature.support.SlingConstants;
 import org.apache.sling.feature.support.artifact.ArtifactHandler;
 import org.apache.sling.feature.support.artifact.ArtifactManager;
 import org.apache.sling.feature.support.json.ApplicationJSONReader;
@@ -113,9 +114,9 @@ public class FeatureProcessor {
                     config.getInstallation().addInstallableArtifact(handler.getFile());
                 }
             } else {
-                if ( ext.getName().equals(Extension.NAME_REPOINIT) ) {
+                if ( ext.getName().equals(SlingConstants.EXTENSION_NAME_REPOINIT) ) {
                     if ( ext.getType() != ExtensionType.TEXT ) {
-                        throw new Exception(Extension.NAME_REPOINIT + " extension must be
of type text and not json");
+                        throw new Exception(SlingConstants.EXTENSION_NAME_REPOINIT + " extension
must be of type text and not json");
                     }
                     final Configuration cfg = new Configuration("org.apache.sling.jcr.repoinit.RepositoryInitializer",
"repoinit" + String.valueOf(index));
                     index++;
diff --git a/featuremodel/feature-modelconverter/src/main/java/org/apache/sling/feature/modelconverter/impl/FeatureToProvisioning.java
b/featuremodel/feature-modelconverter/src/main/java/org/apache/sling/feature/modelconverter/impl/FeatureToProvisioning.java
index 018f99c..fd1d268 100644
--- a/featuremodel/feature-modelconverter/src/main/java/org/apache/sling/feature/modelconverter/impl/FeatureToProvisioning.java
+++ b/featuremodel/feature-modelconverter/src/main/java/org/apache/sling/feature/modelconverter/impl/FeatureToProvisioning.java
@@ -16,6 +16,22 @@
  */
 package org.apache.sling.feature.modelconverter.impl;
 
+import java.io.File;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.StringReader;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.json.Json;
+import javax.json.JsonArray;
+import javax.json.JsonReader;
+import javax.json.JsonString;
+import javax.json.JsonValue;
+
 import org.apache.sling.feature.Application;
 import org.apache.sling.feature.ArtifactId;
 import org.apache.sling.feature.Bundles;
@@ -25,6 +41,7 @@ import org.apache.sling.feature.ExtensionType;
 import org.apache.sling.feature.Extensions;
 import org.apache.sling.feature.KeyValueMap;
 import org.apache.sling.feature.support.FeatureUtil;
+import org.apache.sling.feature.support.SlingConstants;
 import org.apache.sling.feature.support.artifact.ArtifactManager;
 import org.apache.sling.feature.support.json.ApplicationJSONReader;
 import org.apache.sling.feature.support.json.FeatureJSONReader.SubstituteVariables;
@@ -38,22 +55,6 @@ import org.apache.sling.provisioning.model.io.ModelWriter;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.io.File;
-import java.io.FileReader;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.StringReader;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.json.Json;
-import javax.json.JsonArray;
-import javax.json.JsonReader;
-import javax.json.JsonString;
-import javax.json.JsonValue;
-
 /** Converter that converts the feature model to the provisioning model.
  */
 public class FeatureToProvisioning {
@@ -205,7 +206,7 @@ public class FeatureToProvisioning {
 
         // extensions: content packages and repoinit
         for(final Extension ext : extensions) {
-            if ( Extension.NAME_CONTENT_PACKAGES.equals(ext.getName()) ) {
+            if ( SlingConstants.EXTENSION_NAME_CONTENT_PACKAGES.equals(ext.getName()) ) {
                 for(final org.apache.sling.feature.Artifact cp : ext.getArtifacts() ) {
                     String[] runmodes = null;
                     final ArtifactId id = cp.getId();
@@ -220,7 +221,7 @@ public class FeatureToProvisioning {
                     f.getOrCreateRunMode(runmodes).getOrCreateArtifactGroup(20).add(newCP);
                 }
 
-            } else if ( Extension.NAME_REPOINIT.equals(ext.getName()) ) {
+            } else if ( SlingConstants.EXTENSION_NAME_REPOINIT.equals(ext.getName()) ) {
                 final Section section = new Section("repoinit");
                 if (ext.getType() == ExtensionType.TEXT) {
                     section.setContents(ext.getText());
diff --git a/featuremodel/feature-modelconverter/src/main/java/org/apache/sling/feature/modelconverter/impl/ProvisioningToFeature.java
b/featuremodel/feature-modelconverter/src/main/java/org/apache/sling/feature/modelconverter/impl/ProvisioningToFeature.java
index 1f8ce87..1be7c02 100644
--- a/featuremodel/feature-modelconverter/src/main/java/org/apache/sling/feature/modelconverter/impl/ProvisioningToFeature.java
+++ b/featuremodel/feature-modelconverter/src/main/java/org/apache/sling/feature/modelconverter/impl/ProvisioningToFeature.java
@@ -16,6 +16,21 @@
  */
 package org.apache.sling.feature.modelconverter.impl;
 
+import java.io.File;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+
 import org.apache.sling.feature.Application;
 import org.apache.sling.feature.ArtifactId;
 import org.apache.sling.feature.Bundles;
@@ -25,6 +40,7 @@ import org.apache.sling.feature.ExtensionType;
 import org.apache.sling.feature.Extensions;
 import org.apache.sling.feature.KeyValueMap;
 import org.apache.sling.feature.support.FeatureUtil;
+import org.apache.sling.feature.support.SlingConstants;
 import org.apache.sling.feature.support.artifact.ArtifactHandler;
 import org.apache.sling.feature.support.artifact.ArtifactManager;
 import org.apache.sling.feature.support.artifact.ArtifactManagerConfig;
@@ -48,21 +64,6 @@ import org.apache.sling.provisioning.model.io.ModelReader;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.io.File;
-import java.io.FileReader;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-
 /** Converter that converts the provisioning model to the feature model.
  */
 public class ProvisioningToFeature {
@@ -335,7 +336,7 @@ public class ProvisioningToFeature {
             variables.put(FeatureToProvisioning.PROVISIONING_MODEL_NAME_VARIABLE, feature.getName());
         }
 
-        Extension cpExtension = extensions.getByName(Extension.NAME_CONTENT_PACKAGES);
+        Extension cpExtension = extensions.getByName(SlingConstants.EXTENSION_NAME_CONTENT_PACKAGES);
         for(final RunMode runMode : feature.getRunModes() ) {
             for(final ArtifactGroup group : runMode.getArtifactGroups()) {
                 for(final Artifact artifact : group) {
@@ -348,7 +349,7 @@ public class ProvisioningToFeature {
 
                     if ( newArtifact.getId().getType().equals("zip") ) {
                         if ( cpExtension == null ) {
-                            cpExtension = new Extension(ExtensionType.ARTIFACTS, Extension.NAME_CONTENT_PACKAGES,
true);
+                            cpExtension = new Extension(ExtensionType.ARTIFACTS, SlingConstants.EXTENSION_NAME_CONTENT_PACKAGES,
true);
                             extensions.add(cpExtension);
                         }
                         cpExtension.getArtifacts().add(newArtifact);
@@ -411,7 +412,7 @@ public class ProvisioningToFeature {
                 }
             }
         }
-        Extension repoExtension = extensions.getByName(Extension.NAME_REPOINIT);
+        Extension repoExtension = extensions.getByName(SlingConstants.EXTENSION_NAME_REPOINIT);
         for(final Section sect : feature.getAdditionalSections("repoinit")) {
             String text = sect.getContents();
             if ( repoExtension == null ) {
@@ -419,7 +420,7 @@ public class ProvisioningToFeature {
 //                extensions.add(repoExtension);
 //                repoExtension.setJSON(text);
 
-                repoExtension = new Extension(ExtensionType.JSON, Extension.NAME_REPOINIT,
true);
+                repoExtension = new Extension(ExtensionType.JSON, SlingConstants.EXTENSION_NAME_REPOINIT,
true);
                 extensions.add(repoExtension);
                 text = text.replace('\t', ' ');
                 String[] lines = text.split("[\n]");
diff --git a/featuremodel/feature-support/src/main/java/org/apache/sling/feature/support/ConfigurationUtil.java
b/featuremodel/feature-support/src/main/java/org/apache/sling/feature/support/ConfigurationUtil.java
index 7ba8554..a8d941b 100644
--- a/featuremodel/feature-support/src/main/java/org/apache/sling/feature/support/ConfigurationUtil.java
+++ b/featuremodel/feature-support/src/main/java/org/apache/sling/feature/support/ConfigurationUtil.java
@@ -16,10 +16,6 @@
  */
 package org.apache.sling.feature.support;
 
-import org.apache.sling.feature.Configurations;
-import org.apache.sling.feature.support.json.ConfigurationJSONWriter;
-import org.osgi.framework.Constants;
-
 import java.io.IOException;
 import java.io.OutputStream;
 import java.io.OutputStreamWriter;
@@ -29,15 +25,16 @@ import java.util.jar.JarOutputStream;
 import java.util.jar.Manifest;
 import java.util.zip.ZipEntry;
 
+import org.apache.sling.feature.Configurations;
+import org.apache.sling.feature.support.json.ConfigurationJSONWriter;
+import org.osgi.framework.Constants;
+
 
 public class ConfigurationUtil {
 
     public static final String REQUIRE_CONFIGURATOR_CAPABILITY =
             "osgi.extender;filter:=\"(&(osgi.extender=osgi.configurator)(version>=1.0)(!(version>=2.0)))\"";
 
-    public static final String REQUIRE_REPOINIT_CAPABILITY =
-            "osgi.implementation;filter:=\"(&(osgi.implementation=org.apache.sling.jcr.repoinit)(version>=1.0)(!(version>=2.0)))\"";
-
     /**
      * Create a bundle containing the configurations to be processed the
      * OSGi configurator
diff --git a/featuremodel/feature-support/src/main/java/org/apache/sling/feature/support/FeatureUtil.java
b/featuremodel/feature-support/src/main/java/org/apache/sling/feature/support/FeatureUtil.java
index fb90397..d5358fa 100644
--- a/featuremodel/feature-support/src/main/java/org/apache/sling/feature/support/FeatureUtil.java
+++ b/featuremodel/feature-support/src/main/java/org/apache/sling/feature/support/FeatureUtil.java
@@ -48,7 +48,7 @@ public class FeatureUtil {
     public static ArtifactId getFelixFrameworkId(final String version) {
         return new ArtifactId("org.apache.felix",
                 "org.apache.felix.framework",
-                version != null ? version : "5.6.8", null, null);
+                version != null ? version : "5.6.10", null, null);
     }
 
     static final Comparator<String> FEATURE_PATH_COMP = new Comparator<String>()
{
diff --git a/featuremodel/feature-support/src/main/java/org/apache/sling/feature/support/SlingConstants.java
b/featuremodel/feature-support/src/main/java/org/apache/sling/feature/support/SlingConstants.java
new file mode 100644
index 0000000..895b1cd
--- /dev/null
+++ b/featuremodel/feature-support/src/main/java/org/apache/sling/feature/support/SlingConstants.java
@@ -0,0 +1,37 @@
+/*
+ * 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.feature.support;
+
+import java.util.Collections;
+
+import org.apache.sling.feature.OSGiRequirement;
+import org.osgi.resource.Requirement;
+
+public abstract class SlingConstants {
+
+    /** Common extension name to specify the repoinit part for Apache Sling. */
+    public static final String EXTENSION_NAME_REPOINIT = "repoinit";
+
+    /** Common extension name to specify the content packages for Apache Sling. */
+    public static final String EXTENSION_NAME_CONTENT_PACKAGES = "content-packages";
+
+    public static final String REQUIRE_REPOINIT_CAPABILITY =
+            "osgi.implementation;filter:=\"(&(osgi.implementation=org.apache.sling.jcr.repoinit)(version>=1.0)(!(version>=2.0)))\"";
+
+    public static final Requirement REQUIREMENT_REPOINIT = new OSGiRequirement("osgi.implementation",
null,
+            Collections.singletonMap("filter", "(&(osgi.implementation=org.apache.sling.jcr.repoinit)(version>=1.0)(!(version>=2.0)))"));
+}
diff --git a/featuremodel/feature/src/main/java/org/apache/sling/feature/Extension.java b/featuremodel/feature/src/main/java/org/apache/sling/feature/Extension.java
index a3e8082..df10287 100644
--- a/featuremodel/feature/src/main/java/org/apache/sling/feature/Extension.java
+++ b/featuremodel/feature/src/main/java/org/apache/sling/feature/Extension.java
@@ -31,12 +31,6 @@ import java.util.List;
  */
 public class Extension {
 
-    /** Common extension name to specify the repoinit part for Apache Sling. */
-    public static final String NAME_REPOINIT = "repoinit";
-
-    /** Common extension name to specify the content packages for Apache Sling. */
-    public static final String NAME_CONTENT_PACKAGES = "content-packages";
-
     /** The extension type */
     private final ExtensionType type;
 

-- 
To stop receiving notification emails like this one, please contact
cziegeler@apache.org.

Mime
View raw message