[jira] [Commented] (SLING-7970) Add Feature Model introspection service
[ https://issues.apache.org/jira/browse/SLING-7970?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16683840#comment-16683840 ] David Bosschaert commented on SLING-7970: - A mechanism to look up the effective feature model is provided via theĀ {{sling.feature}} OSGi framework property which can be looked up and returns the URL of a resource that provides the effective feature. > Add Feature Model introspection service > --- > > Key: SLING-7970 > URL: https://issues.apache.org/jira/browse/SLING-7970 > Project: Sling > Issue Type: New Feature > Components: Feature Model >Reporter: David Bosschaert >Assignee: David Bosschaert >Priority: Major > > We need a service that can report on the feature model that is launched by > the launcher, for introspection purposes. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (SLING-7970) Add Feature Model introspection service
[ https://issues.apache.org/jira/browse/SLING-7970?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16651591#comment-16651591 ] ASF GitHub Bot commented on SLING-7970: --- bosschaert commented on issue #4: SLING-7970 Add Feature Model introspection Service API URL: https://github.com/apache/sling-org-apache-sling-feature-launcher/pull/4#issuecomment-430215509 Closing pull request, trying an alternative approach that would not require an API. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Add Feature Model introspection service > --- > > Key: SLING-7970 > URL: https://issues.apache.org/jira/browse/SLING-7970 > Project: Sling > Issue Type: New Feature > Components: Feature Model >Reporter: David Bosschaert >Assignee: David Bosschaert >Priority: Major > > We need a service that can report on the feature model that is launched by > the launcher, for introspection purposes. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (SLING-7970) Add Feature Model introspection service
[ https://issues.apache.org/jira/browse/SLING-7970?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16651592#comment-16651592 ] ASF GitHub Bot commented on SLING-7970: --- bosschaert closed pull request #4: SLING-7970 Add Feature Model introspection Service API URL: https://github.com/apache/sling-org-apache-sling-feature-launcher/pull/4 This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/pom.xml b/pom.xml index 9debaf3..67dfb97 100644 --- a/pom.xml +++ b/pom.xml @@ -93,6 +93,11 @@ 2.6 provided + +org.osgi +org.osgi.annotation.versioning +provided + org.osgi osgi.core diff --git a/src/main/java/org/apache/sling/feature/launcher/impl/FeatureProcessor.java b/src/main/java/org/apache/sling/feature/launcher/impl/FeatureProcessor.java index dd5c2bb..018f1ea 100644 --- a/src/main/java/org/apache/sling/feature/launcher/impl/FeatureProcessor.java +++ b/src/main/java/org/apache/sling/feature/launcher/impl/FeatureProcessor.java @@ -19,6 +19,7 @@ import java.io.File; import java.io.FileReader; import java.io.IOException; +import java.io.StringWriter; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; @@ -42,6 +43,7 @@ import org.apache.sling.feature.io.file.ArtifactHandler; import org.apache.sling.feature.io.file.ArtifactManager; import org.apache.sling.feature.io.json.FeatureJSONReader; +import org.apache.sling.feature.io.json.FeatureJSONWriter; import org.apache.sling.feature.launcher.spi.LauncherPrepareContext; import org.apache.sling.feature.launcher.spi.extensions.ExtensionHandler; @@ -120,7 +122,7 @@ public static void prepareLauncher(final LauncherPrepareContext ctx, final Launc for(final Artifact a : entry.getValue()) { final File artifactFile = ctx.getArtifactFile(a.getId()); -config.getInstallation().addBundle(entry.getKey(), artifactFile); +config.getInstallation().addBundle(entry.getKey(), a.getId().toMvnId(), artifactFile); } } @@ -138,6 +140,10 @@ public static void prepareLauncher(final LauncherPrepareContext ctx, final Launc } } +StringWriter featureStringWriter = new StringWriter(); +FeatureJSONWriter.write(featureStringWriter, app); + config.getInstallation().setEffectiveFeature(featureStringWriter.toString()); + extensions: for(final Extension ext : app.getExtensions()) { for (ExtensionHandler handler : ServiceLoader.load(ExtensionHandler.class, FeatureProcessor.class.getClassLoader())) { diff --git a/src/main/java/org/apache/sling/feature/launcher/impl/Installation.java b/src/main/java/org/apache/sling/feature/launcher/impl/Installation.java index 3f08856..3fa11d3 100644 --- a/src/main/java/org/apache/sling/feature/launcher/impl/Installation.java +++ b/src/main/java/org/apache/sling/feature/launcher/impl/Installation.java @@ -23,6 +23,7 @@ import java.util.ArrayList; import java.util.Dictionary; import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -35,7 +36,7 @@ private final Map fwkProperties = new HashMap<>(); /** Bundle map */ -private final Map> bundleMap = new HashMap<>(); +private final Map> bundleMap = new HashMap<>(); /** Artifacts to be installed */ private final List installables = new ArrayList<>(); @@ -46,6 +47,9 @@ /** The list of app jars. */ private final List appJars = new ArrayList<>(); +/** The effective, merged feature used to launch. */ +private String effectiveFeature; + /** * Add an application jar. * @param jar The application jar @@ -65,15 +69,17 @@ public void addAppJar(final File jar) { /** * Add a bundle with the given start level * @param startLevel The start level + * @param id The artifact ID for the bundle * @param file The bundle file */ -public void addBundle(final Integer startLevel, final File file) { -List files = bundleMap.get(startLevel); +@Override +public void addBundle(final Integer startLevel, final String id, final File file) { +Map files = bundleMap.get(startLevel); if ( files == null ) { -files = new ArrayList<>(); +files = new LinkedHashMap<>(); bundleMap.put(startLevel, files); } -files.add(file); +files.put(id, file); } /** @@ -112,7 +118,7 @@ public void addFrameworkProperty(String key, String value) * @see
[jira] [Commented] (SLING-7970) Add Feature Model introspection service
[ https://issues.apache.org/jira/browse/SLING-7970?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16644941#comment-16644941 ] ASF GitHub Bot commented on SLING-7970: --- bosschaert opened a new pull request #4: SLING-7970 Add Feature Model introspection Service API URL: https://github.com/apache/sling-org-apache-sling-feature-launcher/pull/4 The API has two services: 1. A Features service that provides the effective feature run as JSON 2. A Bundles service that allows the lookup of a Bundle artifact ID as represented in the feature model from a BSN and Version. Right now the Service API is embedded in the launcher. We could potentially isolate it in a separate module in the future. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Add Feature Model introspection service > --- > > Key: SLING-7970 > URL: https://issues.apache.org/jira/browse/SLING-7970 > Project: Sling > Issue Type: New Feature > Components: Feature Model >Reporter: David Bosschaert >Assignee: David Bosschaert >Priority: Major > > We need a service that can report on the feature model that is launched by > the launcher, for introspection purposes. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (SLING-7970) Add Feature Model introspection service
[ https://issues.apache.org/jira/browse/SLING-7970?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16644695#comment-16644695 ] ASF GitHub Bot commented on SLING-7970: --- bosschaert commented on issue #3: SLING-7970 Add Feature Model introspection service URL: https://github.com/apache/sling-org-apache-sling-feature-launcher/pull/3#issuecomment-428498492 Closing this pull request as I'm going to take a look at a different approach. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Add Feature Model introspection service > --- > > Key: SLING-7970 > URL: https://issues.apache.org/jira/browse/SLING-7970 > Project: Sling > Issue Type: New Feature > Components: Feature Model >Reporter: David Bosschaert >Assignee: David Bosschaert >Priority: Major > > We need a service that can report on the feature model that is launched by > the launcher, for introspection purposes. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (SLING-7970) Add Feature Model introspection service
[ https://issues.apache.org/jira/browse/SLING-7970?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16644696#comment-16644696 ] ASF GitHub Bot commented on SLING-7970: --- bosschaert closed pull request #3: SLING-7970 Add Feature Model introspection service URL: https://github.com/apache/sling-org-apache-sling-feature-launcher/pull/3 This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/pom.xml b/pom.xml index 9debaf3..08bea14 100644 --- a/pom.xml +++ b/pom.xml @@ -99,6 +99,12 @@ 7.0.0 provided + +org.apache.felix +org.apache.felix.inventory +1.0.6 +provided + org.slf4j slf4j-api diff --git a/src/main/java/org/apache/sling/feature/launcher/impl/FeatureProcessor.java b/src/main/java/org/apache/sling/feature/launcher/impl/FeatureProcessor.java index dd5c2bb..018f1ea 100644 --- a/src/main/java/org/apache/sling/feature/launcher/impl/FeatureProcessor.java +++ b/src/main/java/org/apache/sling/feature/launcher/impl/FeatureProcessor.java @@ -19,6 +19,7 @@ import java.io.File; import java.io.FileReader; import java.io.IOException; +import java.io.StringWriter; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; @@ -42,6 +43,7 @@ import org.apache.sling.feature.io.file.ArtifactHandler; import org.apache.sling.feature.io.file.ArtifactManager; import org.apache.sling.feature.io.json.FeatureJSONReader; +import org.apache.sling.feature.io.json.FeatureJSONWriter; import org.apache.sling.feature.launcher.spi.LauncherPrepareContext; import org.apache.sling.feature.launcher.spi.extensions.ExtensionHandler; @@ -120,7 +122,7 @@ public static void prepareLauncher(final LauncherPrepareContext ctx, final Launc for(final Artifact a : entry.getValue()) { final File artifactFile = ctx.getArtifactFile(a.getId()); -config.getInstallation().addBundle(entry.getKey(), artifactFile); +config.getInstallation().addBundle(entry.getKey(), a.getId().toMvnId(), artifactFile); } } @@ -138,6 +140,10 @@ public static void prepareLauncher(final LauncherPrepareContext ctx, final Launc } } +StringWriter featureStringWriter = new StringWriter(); +FeatureJSONWriter.write(featureStringWriter, app); + config.getInstallation().setEffectiveFeature(featureStringWriter.toString()); + extensions: for(final Extension ext : app.getExtensions()) { for (ExtensionHandler handler : ServiceLoader.load(ExtensionHandler.class, FeatureProcessor.class.getClassLoader())) { diff --git a/src/main/java/org/apache/sling/feature/launcher/impl/Installation.java b/src/main/java/org/apache/sling/feature/launcher/impl/Installation.java index 3f08856..4b190ff 100644 --- a/src/main/java/org/apache/sling/feature/launcher/impl/Installation.java +++ b/src/main/java/org/apache/sling/feature/launcher/impl/Installation.java @@ -35,7 +35,7 @@ private final Map fwkProperties = new HashMap<>(); /** Bundle map */ -private final Map> bundleMap = new HashMap<>(); +private final Map> bundleMap = new HashMap<>(); /** Artifacts to be installed */ private final List installables = new ArrayList<>(); @@ -46,6 +46,9 @@ /** The list of app jars. */ private final List appJars = new ArrayList<>(); +/** The effective, merged feature used to launch. */ +private String effectiveFeature; + /** * Add an application jar. * @param jar The application jar @@ -67,13 +70,13 @@ public void addAppJar(final File jar) { * @param startLevel The start level * @param file The bundle file */ -public void addBundle(final Integer startLevel, final File file) { -List files = bundleMap.get(startLevel); +public void addBundle(final Integer startLevel, final String id, final File file) { +Map files = bundleMap.get(startLevel); if ( files == null ) { -files = new ArrayList<>(); +files = new HashMap<>(); bundleMap.put(startLevel, files); } -files.add(file); +files.put(id, file); } /** @@ -112,7 +115,7 @@ public void addFrameworkProperty(String key, String value) * @see org.apache.sling.feature.launcher.spi.LauncherRunContext#getBundleMap() */ @Override -public Map> getBundleMap() { +public Map> getBundleMap() { return this.bundleMap; } @@ -132,6 +135,22 @@ public void addFrameworkProperty(String key, String value) return
[jira] [Commented] (SLING-7970) Add Feature Model introspection service
[ https://issues.apache.org/jira/browse/SLING-7970?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16639820#comment-16639820 ] ASF GitHub Bot commented on SLING-7970: --- bosschaert commented on issue #3: SLING-7970 Add Feature Model introspection service URL: https://github.com/apache/sling-org-apache-sling-feature-launcher/pull/3#issuecomment-427362517 Hi @cziegeler and @karlpauls would you have time to take a quick look at these changes? I'll work on unit tests in the mean time... This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Add Feature Model introspection service > --- > > Key: SLING-7970 > URL: https://issues.apache.org/jira/browse/SLING-7970 > Project: Sling > Issue Type: New Feature > Components: Feature Model >Reporter: David Bosschaert >Assignee: David Bosschaert >Priority: Major > > We need a service that can report on the feature model that is launched by > the launcher, for introspection purposes. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (SLING-7970) Add Feature Model introspection service
[ https://issues.apache.org/jira/browse/SLING-7970?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16639818#comment-16639818 ] ASF GitHub Bot commented on SLING-7970: --- bosschaert opened a new pull request #3: SLING-7970 Add Feature Model introspection service URL: https://github.com/apache/sling-org-apache-sling-feature-launcher/pull/3 Get the launcher to install a Felix Inventory Printer service that prints the effective feature. This can be used to report on the selected feature. Additionally register a service that can find the Bundle Artifact ID from a given Bundle Symbolic Name and Version. This can be used to find a bundle in a feature description. The interface for this service can be found here https://github.com/apache/sling-whiteboard/blob/master/featuremodel/feature-service/src/main/java/org/apache/sling/feature/service/Bundles.java This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Add Feature Model introspection service > --- > > Key: SLING-7970 > URL: https://issues.apache.org/jira/browse/SLING-7970 > Project: Sling > Issue Type: New Feature > Components: Feature Model >Reporter: David Bosschaert >Assignee: David Bosschaert >Priority: Major > > We need a service that can report on the feature model that is launched by > the launcher, for introspection purposes. -- This message was sent by Atlassian JIRA (v7.6.3#76005)