You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by da...@apache.org on 2019/12/16 15:17:00 UTC

[sling-whiteboard] branch master updated: Use Artifact ID in Feature and Bundle

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 087f923  Use Artifact ID in Feature and Bundle
087f923 is described below

commit 087f923f5c77e1ccedd9997226048d8c121920f2
Author: David Bosschaert <da...@gmail.com>
AuthorDate: Mon Dec 16 15:16:44 2019 +0000

    Use Artifact ID in Feature and Bundle
---
 .../src/main/java/org/osgi/feature/Bundle.java     | 20 +++++-------
 .../src/main/java/org/osgi/feature/Feature.java    | 38 ++++------------------
 .../main/java/org/osgi/feature/FeatureService.java | 14 ++++++++
 .../org/osgi/feature/impl/FeatureServiceImpl.java  |  6 ++++
 4 files changed, 35 insertions(+), 43 deletions(-)

diff --git a/osgi-featuremodel/src/main/java/org/osgi/feature/Bundle.java b/osgi-featuremodel/src/main/java/org/osgi/feature/Bundle.java
index ad3a04f..f80acee 100644
--- a/osgi-featuremodel/src/main/java/org/osgi/feature/Bundle.java
+++ b/osgi-featuremodel/src/main/java/org/osgi/feature/Bundle.java
@@ -21,11 +21,11 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.Objects;
 
-public class Bundle extends ArtifactID {
+public class Bundle extends Artifact {
     private final Map<String, Object> metadata;
 
-    private Bundle(String groupId, String artifactId, String version, Map<String,Object> metadata) {
-        super(groupId, artifactId, version, null, null);
+    private Bundle(ArtifactID id, Map<String,Object> metadata) {
+        super(id);
 
         this.metadata = Collections.unmodifiableMap(metadata);
     }
@@ -55,20 +55,16 @@ public class Bundle extends ArtifactID {
     }
 
     public static class Builder {
-        private final String groupId;
-        private final String artifactId;
-        private final String version;
+        private final ArtifactID id;
 
         private final Map<String,Object> metadata = new HashMap<>();
 
-        public Builder(ArtifactID aid) {
-            this(aid.getGroupId(), aid.getArtifactId(), aid.getVersion());
+        public Builder(ArtifactID id) {
+            this.id = id;
         }
 
         public Builder(String groupId, String artifactId, String version) {
-            this.groupId = groupId;
-            this.artifactId = artifactId;
-            this.version = version;
+            this(new ArtifactID(groupId, artifactId, version, null, null));
         }
 
         public Builder addMetadata(String key, Object value) {
@@ -82,7 +78,7 @@ public class Bundle extends ArtifactID {
         }
 
         public Bundle build() {
-            return new Bundle(groupId, artifactId, version, metadata);
+            return new Bundle(id, metadata);
         }
     }
 }
diff --git a/osgi-featuremodel/src/main/java/org/osgi/feature/Feature.java b/osgi-featuremodel/src/main/java/org/osgi/feature/Feature.java
index b6414bd..35f3086 100644
--- a/osgi-featuremodel/src/main/java/org/osgi/feature/Feature.java
+++ b/osgi-featuremodel/src/main/java/org/osgi/feature/Feature.java
@@ -25,7 +25,7 @@ import java.util.Map;
 
 // Thread Safe
 // Or do we use an interface?
-public class Feature extends ArtifactID {
+public class Feature extends Artifact {
     private final String title;
     private final String description;
     private final String vendor;
@@ -38,9 +38,9 @@ public class Feature extends ArtifactID {
     private final List<Configuration> configurations;
     private final Map<String, String> variables;
 
-    private Feature(String gid, String aid, String ver, String type, String classifier, String aTitle, String desc, String vnd, String lic, String loc,
+    private Feature(ArtifactID id, String aTitle, String desc, String vnd, String lic, String loc,
             boolean comp, boolean fin, List<Bundle> bs, List<Configuration> cs, Map<String,String> vars) {
-        super(gid, aid, ver, type, classifier);
+        super(id);
 
         title = aTitle;
         description = desc;
@@ -102,14 +102,8 @@ public class Feature extends ArtifactID {
 
     // Not Thread Safe
     public static class Builder {
-        private static final String DEFAULT_FEATURE_TYPE = "osgifeature";
+        private final ArtifactID id;
 
-        private final String groupId;
-        private final String artifactId;
-        private final String version;
-
-        private String type;
-        private String classifier;
         private String title;
         private String description;
         private String vendor;
@@ -123,25 +117,11 @@ public class Feature extends ArtifactID {
         private final Map<String,String> variables = new HashMap<>();
 
         public Builder(ArtifactID id) {
-            this(id.getGroupId(), id.getArtifactId(), id.getVersion());
-            setType(id.getType());
-            setClassifier(id.getClassifier());
+            this.id = id;
         }
 
         public Builder(String groupId, String artifactId, String version) {
-            this.groupId = groupId;
-            this.artifactId = artifactId;
-            this.version = version;
-        }
-
-        public Builder setType(String type) {
-            this.type = type;
-            return this;
-        }
-
-        public Builder setClassifier(String cls) {
-            this.classifier = cls;
-            return this;
+            this(new ArtifactID(groupId, artifactId, version, null, null));
         }
 
         public Builder setTitle(String title) {
@@ -200,11 +180,7 @@ public class Feature extends ArtifactID {
         }
 
         public Feature build() {
-            if (classifier != null && type == null) {
-                type = DEFAULT_FEATURE_TYPE;
-            }
-
-            return new Feature(groupId, artifactId, version, type, classifier, title,
+            return new Feature(id, title,
                     description, vendor, license, location, complete, isFinal,
                     bundles, configurations, variables);
         }
diff --git a/osgi-featuremodel/src/main/java/org/osgi/feature/FeatureService.java b/osgi-featuremodel/src/main/java/org/osgi/feature/FeatureService.java
index 2e6bacc..d1102cf 100644
--- a/osgi-featuremodel/src/main/java/org/osgi/feature/FeatureService.java
+++ b/osgi-featuremodel/src/main/java/org/osgi/feature/FeatureService.java
@@ -21,7 +21,21 @@ import java.io.Reader;
 import java.io.Writer;
 
 public interface FeatureService {
+    /**
+     * Read a Feature from JSON
+     * @param jsonReader A Reader to the JSON input
+     * @return The Feature represented by the JSON
+     * @throws IOException When reading fails
+     */
     Feature readFeature(Reader jsonReader) throws IOException;
 
+    /**
+     * Write a Feature Model to JSON
+     * @param feature the Feature to write.
+     * @param jsonWriter A Writer to which the Feature should be written.
+     * @throws IOException When writing fails.
+     */
     void writeFeature(Feature feature, Writer jsonWriter) throws IOException;
+
+    Feature mergeFeatures(Feature f1, Feature f2);
 }
diff --git a/osgi-featuremodel/src/main/java/org/osgi/feature/impl/FeatureServiceImpl.java b/osgi-featuremodel/src/main/java/org/osgi/feature/impl/FeatureServiceImpl.java
index 0a130e4..2e5a61f 100644
--- a/osgi-featuremodel/src/main/java/org/osgi/feature/impl/FeatureServiceImpl.java
+++ b/osgi-featuremodel/src/main/java/org/osgi/feature/impl/FeatureServiceImpl.java
@@ -101,4 +101,10 @@ public class FeatureServiceImpl implements FeatureService {
 
     }
 
+    @Override
+    public Feature mergeFeatures(Feature f1, Feature f2) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
 }