sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject [sling-whiteboard] branch master updated: [Feature Model] Move constants from support module to feature module
Date Thu, 26 Apr 2018 08:51:57 GMT
This is an automated email from the ASF dual-hosted git repository.

davidb 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 9e06613  [Feature Model] Move constants from support module to feature module
9e06613 is described below

commit 9e06613a755b73acbeb6828f41d8b226c0161647
Author: David Bosschaert <david.bosschaert@gmail.com>
AuthorDate: Thu Apr 26 09:50:10 2018 +0100

    [Feature Model] Move constants from support module to feature module
    
    EXTENSION_NAME_REPOINIT and EXTENSION_NAME_CONTENT_PACKAGES were moved
    from SlingConstants in feature-support to FeatureConstants in feature.
---
 .../impl/ContentPackagesExtensionScanner.java      | 12 +++++------
 .../feature/scanner/impl/RepoInitScanner.java      |  7 ++++---
 .../sling/feature/karaf/KarafFeatureWriter.java    | 23 +++++++++++-----------
 .../feature/launcher/impl/FeatureProcessor.java    | 22 ++++++++++-----------
 .../modelconverter/impl/FeatureToProvisioning.java |  6 +++---
 .../modelconverter/impl/ProvisioningToFeature.java | 10 +++++-----
 .../sling/feature/support/SlingConstants.java      |  6 ------
 .../apache/sling/feature/FeatureConstants.java}    | 17 ++--------------
 8 files changed, 43 insertions(+), 60 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 4fc9fb6..e125ce0 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
@@ -16,17 +16,17 @@
  */
 package org.apache.sling.feature.scanner.impl;
 
-import java.io.File;
-import java.io.IOException;
-import java.util.Set;
-
 import org.apache.sling.feature.Artifact;
 import org.apache.sling.feature.Extension;
 import org.apache.sling.feature.ExtensionType;
+import org.apache.sling.feature.FeatureConstants;
 import org.apache.sling.feature.io.ArtifactManager;
 import org.apache.sling.feature.scanner.ContainerDescriptor;
 import org.apache.sling.feature.scanner.spi.ExtensionScanner;
-import org.apache.sling.feature.support.SlingConstants;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Set;
 
 public class ContentPackagesExtensionScanner implements ExtensionScanner {
 
@@ -44,7 +44,7 @@ public class ContentPackagesExtensionScanner implements ExtensionScanner
{
     public ContainerDescriptor scan(final Extension extension,
             final ArtifactManager artifactManager)
     throws IOException {
-        if (!SlingConstants.EXTENSION_NAME_CONTENT_PACKAGES.equals(extension.getName()) )
{
+        if (!FeatureConstants.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 3681ecf..e30e879 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
@@ -16,15 +16,16 @@
  */
 package org.apache.sling.feature.scanner.impl;
 
-import java.io.IOException;
-
 import org.apache.sling.feature.Extension;
 import org.apache.sling.feature.ExtensionType;
+import org.apache.sling.feature.FeatureConstants;
 import org.apache.sling.feature.io.ArtifactManager;
 import org.apache.sling.feature.scanner.ContainerDescriptor;
 import org.apache.sling.feature.scanner.spi.ExtensionScanner;
 import org.apache.sling.feature.support.SlingConstants;
 
+import java.io.IOException;
+
 public class RepoInitScanner implements ExtensionScanner {
 
     @Override
@@ -41,7 +42,7 @@ public class RepoInitScanner implements ExtensionScanner {
     public ContainerDescriptor scan(final Extension extension,
             final ArtifactManager artifactManager)
     throws IOException {
-        if (!SlingConstants.EXTENSION_NAME_REPOINIT.equals(extension.getName()) ) {
+        if (!FeatureConstants.EXTENSION_NAME_REPOINIT.equals(extension.getName()) ) {
             return null;
         }
         if ( extension.getType() != ExtensionType.TEXT ) {
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 990fc0c..dc00bc1 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
@@ -16,6 +16,17 @@
  */
 package org.apache.sling.feature.karaf;
 
+import org.apache.sling.feature.Artifact;
+import org.apache.sling.feature.ArtifactId;
+import org.apache.sling.feature.Configuration;
+import org.apache.sling.feature.Configurations;
+import org.apache.sling.feature.Extension;
+import org.apache.sling.feature.Feature;
+import org.apache.sling.feature.FeatureConstants;
+import org.apache.sling.feature.io.ArtifactHandler;
+import org.apache.sling.feature.io.ArtifactManager;
+import org.apache.sling.feature.support.SlingConstants;
+
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
@@ -31,16 +42,6 @@ import java.util.Map;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipOutputStream;
 
-import org.apache.sling.feature.Artifact;
-import org.apache.sling.feature.ArtifactId;
-import org.apache.sling.feature.Configuration;
-import org.apache.sling.feature.Configurations;
-import org.apache.sling.feature.Extension;
-import org.apache.sling.feature.Feature;
-import org.apache.sling.feature.io.ArtifactHandler;
-import org.apache.sling.feature.io.ArtifactManager;
-import org.apache.sling.feature.support.SlingConstants;
-
 
 /**
  * This writer writes out a Karaf feature XML.
@@ -53,7 +54,7 @@ public class KarafFeatureWriter {
             final ArtifactManager artifactManager)
     throws IOException {
         // check for repoinit extension
-        final Extension repoinitExt = feature.getExtensions().getByName(SlingConstants.EXTENSION_NAME_REPOINIT);
+        final Extension repoinitExt = feature.getExtensions().getByName(FeatureConstants.EXTENSION_NAME_REPOINIT);
         File configurationBundleFile = null;
         Artifact configuratorBundle = null;
         try {
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 149fa96..557ec90 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
@@ -16,19 +16,12 @@
  */
 package org.apache.sling.feature.launcher.impl;
 
-import java.io.File;
-import java.io.FileReader;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-
 import org.apache.sling.feature.Application;
 import org.apache.sling.feature.Artifact;
 import org.apache.sling.feature.Configuration;
 import org.apache.sling.feature.Extension;
 import org.apache.sling.feature.ExtensionType;
+import org.apache.sling.feature.FeatureConstants;
 import org.apache.sling.feature.io.ArtifactHandler;
 import org.apache.sling.feature.io.ArtifactManager;
 import org.apache.sling.feature.io.json.ApplicationJSONReader;
@@ -37,7 +30,14 @@ import org.apache.sling.feature.launcher.impl.LauncherConfig.StartupMode;
 import org.apache.sling.feature.resolver.ApplicationResolverAssembler;
 import org.apache.sling.feature.resolver.FeatureResolver;
 import org.apache.sling.feature.resolver.FrameworkResolver;
-import org.apache.sling.feature.support.SlingConstants;
+
+import java.io.File;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
 
 public class FeatureProcessor {
 
@@ -114,9 +114,9 @@ public class FeatureProcessor {
                     config.getInstallation().addInstallableArtifact(handler.getFile());
                 }
             } else {
-                if ( ext.getName().equals(SlingConstants.EXTENSION_NAME_REPOINIT) ) {
+                if ( ext.getName().equals(FeatureConstants.EXTENSION_NAME_REPOINIT) ) {
                     if ( ext.getType() != ExtensionType.TEXT ) {
-                        throw new Exception(SlingConstants.EXTENSION_NAME_REPOINIT + " extension
must be of type text and not json");
+                        throw new Exception(FeatureConstants.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 995d47f..95f1055 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
@@ -23,6 +23,7 @@ import org.apache.sling.feature.Configurations;
 import org.apache.sling.feature.Extension;
 import org.apache.sling.feature.ExtensionType;
 import org.apache.sling.feature.Extensions;
+import org.apache.sling.feature.FeatureConstants;
 import org.apache.sling.feature.KeyValueMap;
 import org.apache.sling.feature.io.ArtifactManager;
 import org.apache.sling.feature.io.IOUtils;
@@ -30,7 +31,6 @@ import org.apache.sling.feature.io.json.ApplicationJSONReader;
 import org.apache.sling.feature.io.json.FeatureJSONReader.SubstituteVariables;
 import org.apache.sling.feature.resolver.ApplicationResolverAssembler;
 import org.apache.sling.feature.resolver.FeatureResolver;
-import org.apache.sling.feature.support.SlingConstants;
 import org.apache.sling.provisioning.model.Artifact;
 import org.apache.sling.provisioning.model.Configuration;
 import org.apache.sling.provisioning.model.Feature;
@@ -206,7 +206,7 @@ public class FeatureToProvisioning {
 
         // extensions: content packages and repoinit
         for(final Extension ext : extensions) {
-            if ( SlingConstants.EXTENSION_NAME_CONTENT_PACKAGES.equals(ext.getName()) ) {
+            if ( FeatureConstants.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();
@@ -221,7 +221,7 @@ public class FeatureToProvisioning {
                     f.getOrCreateRunMode(runmodes).getOrCreateArtifactGroup(20).add(newCP);
                 }
 
-            } else if ( SlingConstants.EXTENSION_NAME_REPOINIT.equals(ext.getName()) ) {
+            } else if ( FeatureConstants.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 f1e86d0..0cd2311 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
@@ -23,6 +23,7 @@ import org.apache.sling.feature.Configurations;
 import org.apache.sling.feature.Extension;
 import org.apache.sling.feature.ExtensionType;
 import org.apache.sling.feature.Extensions;
+import org.apache.sling.feature.FeatureConstants;
 import org.apache.sling.feature.KeyValueMap;
 import org.apache.sling.feature.io.ArtifactHandler;
 import org.apache.sling.feature.io.ArtifactManager;
@@ -30,7 +31,6 @@ import org.apache.sling.feature.io.ArtifactManagerConfig;
 import org.apache.sling.feature.io.IOUtils;
 import org.apache.sling.feature.io.json.ApplicationJSONWriter;
 import org.apache.sling.feature.io.json.FeatureJSONWriter;
-import org.apache.sling.feature.support.SlingConstants;
 import org.apache.sling.provisioning.model.Artifact;
 import org.apache.sling.provisioning.model.ArtifactGroup;
 import org.apache.sling.provisioning.model.Configuration;
@@ -335,7 +335,7 @@ public class ProvisioningToFeature {
             variables.put(FeatureToProvisioning.PROVISIONING_MODEL_NAME_VARIABLE, feature.getName());
         }
 
-        Extension cpExtension = extensions.getByName(SlingConstants.EXTENSION_NAME_CONTENT_PACKAGES);
+        Extension cpExtension = extensions.getByName(FeatureConstants.EXTENSION_NAME_CONTENT_PACKAGES);
         for(final RunMode runMode : feature.getRunModes() ) {
             for(final ArtifactGroup group : runMode.getArtifactGroups()) {
                 for(final Artifact artifact : group) {
@@ -348,7 +348,7 @@ public class ProvisioningToFeature {
 
                     if ( newArtifact.getId().getType().equals("zip") ) {
                         if ( cpExtension == null ) {
-                            cpExtension = new Extension(ExtensionType.ARTIFACTS, SlingConstants.EXTENSION_NAME_CONTENT_PACKAGES,
true);
+                            cpExtension = new Extension(ExtensionType.ARTIFACTS, FeatureConstants.EXTENSION_NAME_CONTENT_PACKAGES,
true);
                             extensions.add(cpExtension);
                         }
                         cpExtension.getArtifacts().add(newArtifact);
@@ -411,7 +411,7 @@ public class ProvisioningToFeature {
                 }
             }
         }
-        Extension repoExtension = extensions.getByName(SlingConstants.EXTENSION_NAME_REPOINIT);
+        Extension repoExtension = extensions.getByName(FeatureConstants.EXTENSION_NAME_REPOINIT);
         for(final Section sect : feature.getAdditionalSections("repoinit")) {
             String text = sect.getContents();
             if ( repoExtension == null ) {
@@ -419,7 +419,7 @@ public class ProvisioningToFeature {
 //                extensions.add(repoExtension);
 //                repoExtension.setJSON(text);
 
-                repoExtension = new Extension(ExtensionType.JSON, SlingConstants.EXTENSION_NAME_REPOINIT,
true);
+                repoExtension = new Extension(ExtensionType.JSON, FeatureConstants.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/SlingConstants.java
b/featuremodel/feature-support/src/main/java/org/apache/sling/feature/support/SlingConstants.java
index 1c72aad..7c05f96 100644
--- 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
@@ -23,12 +23,6 @@ import java.util.Collections;
 
 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)))\"";
 
diff --git a/featuremodel/feature-support/src/main/java/org/apache/sling/feature/support/SlingConstants.java
b/featuremodel/feature/src/main/java/org/apache/sling/feature/FeatureConstants.java
similarity index 62%
copy from featuremodel/feature-support/src/main/java/org/apache/sling/feature/support/SlingConstants.java
copy to featuremodel/feature/src/main/java/org/apache/sling/feature/FeatureConstants.java
index 1c72aad..1cbfdf5 100644
--- a/featuremodel/feature-support/src/main/java/org/apache/sling/feature/support/SlingConstants.java
+++ b/featuremodel/feature/src/main/java/org/apache/sling/feature/FeatureConstants.java
@@ -14,25 +14,12 @@
  * License for the specific language governing permissions and limitations under
  * the License.
  */
-package org.apache.sling.feature.support;
-
-import org.apache.felix.utils.resource.RequirementImpl;
-import org.osgi.resource.Requirement;
-
-import java.util.Collections;
-
-public abstract class SlingConstants {
+package org.apache.sling.feature;
 
+public class FeatureConstants {
     /** 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 RequirementImpl(null, "osgi.implementation",
-            Collections.singletonMap("filter", "(&(osgi.implementation=org.apache.sling.jcr.repoinit)(version>=1.0)(!(version>=2.0)))"),
-                    null);
 }

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

Mime
View raw message