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 2018/07/09 13:52:33 UTC

[sling-whiteboard] branch master updated: Initial Features Service implementation

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 2f12c17  Initial Features Service implementation
2f12c17 is described below

commit 2f12c171e56a7b22838d5592989fd474a104fb11
Author: David Bosschaert <da...@gmail.com>
AuthorDate: Mon Jul 9 14:52:08 2018 +0100

    Initial Features Service implementation
---
 featuremodel/feature-service/pom.xml                  |  2 +-
 .../service/{FeatureService.java => Features.java}    |  8 +++-----
 .../feature/service/impl/FeatureServiceImpl.java      | 19 +++++++++----------
 .../feature/service/impl/FeatureServiceImplTest.java  | 14 +++++---------
 4 files changed, 18 insertions(+), 25 deletions(-)

diff --git a/featuremodel/feature-service/pom.xml b/featuremodel/feature-service/pom.xml
index 3c93d25..d18eeee 100644
--- a/featuremodel/feature-service/pom.xml
+++ b/featuremodel/feature-service/pom.xml
@@ -60,7 +60,7 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.feature</artifactId>
-            <version>0.1.2</version>
+            <version>0.1.3-SNAPSHOT</version>
             <scope>provided</scope>
         </dependency>
         <dependency>
diff --git a/featuremodel/feature-service/src/main/java/org/apache/sling/feature/service/FeatureService.java b/featuremodel/feature-service/src/main/java/org/apache/sling/feature/service/Features.java
similarity index 84%
rename from featuremodel/feature-service/src/main/java/org/apache/sling/feature/service/FeatureService.java
rename to featuremodel/feature-service/src/main/java/org/apache/sling/feature/service/Features.java
index 97cdf4c..d1e91a6 100644
--- a/featuremodel/feature-service/src/main/java/org/apache/sling/feature/service/FeatureService.java
+++ b/featuremodel/feature-service/src/main/java/org/apache/sling/feature/service/Features.java
@@ -18,11 +18,9 @@
  */
 package org.apache.sling.feature.service;
 
-import org.apache.sling.feature.Feature;
-
 import java.util.Collection;
 
-public interface FeatureService {
-    Collection<Feature> listFeatures();
-    Feature getFeatureForBundle(long bundleId);
+public interface Features {
+    Collection<String> listFeatures();
+    String getFeatureForBundle(long bundleId);
 }
diff --git a/featuremodel/feature-service/src/main/java/org/apache/sling/feature/service/impl/FeatureServiceImpl.java b/featuremodel/feature-service/src/main/java/org/apache/sling/feature/service/impl/FeatureServiceImpl.java
index 3af0068..eca88d5 100644
--- a/featuremodel/feature-service/src/main/java/org/apache/sling/feature/service/impl/FeatureServiceImpl.java
+++ b/featuremodel/feature-service/src/main/java/org/apache/sling/feature/service/impl/FeatureServiceImpl.java
@@ -18,8 +18,7 @@
  */
 package org.apache.sling.feature.service.impl;
 
-import org.apache.sling.feature.Feature;
-import org.apache.sling.feature.service.FeatureService;
+import org.apache.sling.feature.service.Features;
 
 import java.util.Collection;
 import java.util.Collections;
@@ -28,25 +27,25 @@ import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
 
-class FeatureServiceImpl implements FeatureService {
-    private final Set<Feature> features;
-    private final Map<Long, Feature> bundleFeatureMap;
+class FeatureServiceImpl implements Features {
+    private final Set<String> features;
+    private final Map<Long, String> bundleFeatureMap;
 
-    FeatureServiceImpl(Map<Long, Feature> bundleIDFeatures) {
-        Map<Long, Feature> bfm = new HashMap<>(bundleIDFeatures);
+    FeatureServiceImpl(Map<Long, String> bundleIDFeatures) {
+        Map<Long, String> bfm = new HashMap<>(bundleIDFeatures);
         bundleFeatureMap = Collections.unmodifiableMap(bfm);
 
-        Set<Feature> fs = new HashSet<>(bundleIDFeatures.values());
+        Set<String> fs = new HashSet<>(bundleIDFeatures.values());
         features = Collections.unmodifiableSet(fs);
     }
 
     @Override
-    public Collection<Feature> listFeatures() {
+    public Collection<String> listFeatures() {
         return features;
     }
 
     @Override
-    public Feature getFeatureForBundle(long bundleId) {
+    public String getFeatureForBundle(long bundleId) {
         return bundleFeatureMap.get(bundleId);
     }
 }
diff --git a/featuremodel/feature-service/src/test/java/org/apache/sling/feature/service/impl/FeatureServiceImplTest.java b/featuremodel/feature-service/src/test/java/org/apache/sling/feature/service/impl/FeatureServiceImplTest.java
index 7e15e07..0a3ef0c 100644
--- a/featuremodel/feature-service/src/test/java/org/apache/sling/feature/service/impl/FeatureServiceImplTest.java
+++ b/featuremodel/feature-service/src/test/java/org/apache/sling/feature/service/impl/FeatureServiceImplTest.java
@@ -18,9 +18,7 @@
  */
 package org.apache.sling.feature.service.impl;
 
-import org.apache.sling.feature.ArtifactId;
-import org.apache.sling.feature.Feature;
-import org.apache.sling.feature.service.FeatureService;
+import org.apache.sling.feature.service.Features;
 import org.junit.Test;
 
 import java.util.HashMap;
@@ -32,18 +30,16 @@ import static org.junit.Assert.assertNull;
 public class FeatureServiceImplTest {
     @Test
     public void testFeatureService() {
-        Map<Long, Feature> bif = new HashMap<>();
+        Map<Long, String> bif = new HashMap<>();
 
-        ArtifactId aid1 = new ArtifactId("gid", "aid", "1.0.0", "myfeature", "slingfeature");
-        Feature f1 = new Feature(aid1);
+        String f1 = "gid:aid:1.0.0:myfeature:slingfeature";
         bif.put(123L, f1);
         bif.put(456L, f1);
 
-        ArtifactId aid2 = new ArtifactId("gid", "aid", "1.0.0", "myotherfeature", "slingfeature");
-        Feature f2 = new Feature(aid2);
+        String f2 = "gid:aid2:1.0.0";
         bif.put(789L, f2);
 
-        FeatureService fs = new FeatureServiceImpl(bif);
+        Features fs = new FeatureServiceImpl(bif);
         assertEquals(2, fs.listFeatures().size());
 
         assertEquals(f1, fs.getFeatureForBundle(123));