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/11/14 15:33:57 UTC
[sling-org-apache-sling-feature-launcher] branch master updated:
SLING-8109 Replace KeyValueMap with Map
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-org-apache-sling-feature-launcher.git
The following commit(s) were added to refs/heads/master by this push:
new f0564d7 SLING-8109 Replace KeyValueMap with Map<String,String>
f0564d7 is described below
commit f0564d7e8c42c545c9646da5b5eb36cf0b67fd7b
Author: David Bosschaert <bo...@adobe.com>
AuthorDate: Wed Nov 14 15:33:42 2018 +0000
SLING-8109 Replace KeyValueMap with Map<String,String>
---
pom.xml | 4 +-
.../feature/launcher/impl/FeatureProcessor.java | 59 ++++++++++------------
.../feature/launcher/impl/LauncherConfig.java | 7 +--
3 files changed, 34 insertions(+), 36 deletions(-)
diff --git a/pom.xml b/pom.xml
index 914b2af..6486631 100644
--- a/pom.xml
+++ b/pom.xml
@@ -113,13 +113,13 @@
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.feature</artifactId>
- <version>0.2.0</version>
+ <version>0.2.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.feature.io</artifactId>
- <version>0.2.0</version>
+ <version>0.2.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
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 632516d..2e6b13d 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
@@ -59,38 +59,35 @@ public class FeatureProcessor {
public static Feature createApplication(final LauncherConfig config,
final ArtifactManager artifactManager) throws IOException
{
-
- final BuilderContext builderContext = new BuilderContext(
- id -> {
- try {
- final ArtifactHandler handler = artifactManager.getArtifactHandler(id.toMvnUrl());
- try (final FileReader r = new FileReader(handler.getFile())) {
- final Feature f = FeatureJSONReader.read(r, handler.getUrl());
- return f;
- }
-
- } catch (final IOException e) {
- // ignore
+ final BuilderContext builderContext = new BuilderContext(id -> {
+ try {
+ final ArtifactHandler handler = artifactManager.getArtifactHandler(id.toMvnUrl());
+ try (final FileReader r = new FileReader(handler.getFile())) {
+ final Feature f = FeatureJSONReader.read(r, handler.getUrl());
+ return f;
}
+ } catch (IOException e) {
+ // ignore
return null;
- },
- id -> {
- try {
- final ArtifactHandler handler = artifactManager.getArtifactHandler(id.toMvnUrl());
- return handler.getFile();
- } catch (final IOException e) {
- // ignore
- return null;
- }
- },
- config.getVariables(), config.getInstallation().getFrameworkProperties())
- .addMergeExtensions(StreamSupport.stream(Spliterators.spliteratorUnknownSize(
- ServiceLoader.load(MergeHandler.class).iterator(), Spliterator.ORDERED), false)
- .toArray(MergeHandler[]::new))
- .addPostProcessExtensions(StreamSupport.stream(Spliterators.spliteratorUnknownSize(
- ServiceLoader.load(PostProcessHandler.class).iterator(), Spliterator.ORDERED), false)
- .toArray(PostProcessHandler[]::new));
-
+ }
+ });
+ builderContext.setArtifactProvider(id -> {
+ try {
+ final ArtifactHandler handler = artifactManager.getArtifactHandler(id.toMvnUrl());
+ return handler.getFile();
+ } catch (final IOException e) {
+ // ignore
+ return null;
+ }
+ });
+ builderContext.addVariablesOverwrites(config.getVariables());
+ builderContext.addFrameworkPropertiesOverwrites(config.getInstallation().getFrameworkProperties());
+ builderContext.addMergeExtensions(StreamSupport.stream(Spliterators.spliteratorUnknownSize(
+ ServiceLoader.load(MergeHandler.class).iterator(), Spliterator.ORDERED), false)
+ .toArray(MergeHandler[]::new));
+ builderContext.addPostProcessExtensions(StreamSupport.stream(Spliterators.spliteratorUnknownSize(
+ ServiceLoader.load(PostProcessHandler.class).iterator(), Spliterator.ORDERED), false)
+ .toArray(PostProcessHandler[]::new));
List<Feature> features = new ArrayList<>();
@@ -155,7 +152,7 @@ public class FeatureProcessor {
}
}
- for (final Map.Entry<String, String> prop : app.getFrameworkProperties()) {
+ for (final Map.Entry<String, String> prop : app.getFrameworkProperties().entrySet()) {
if ( !config.getInstallation().getFrameworkProperties().containsKey(prop.getKey()) ) {
config.getInstallation().getFrameworkProperties().put(prop.getKey(), prop.getValue());
}
diff --git a/src/main/java/org/apache/sling/feature/launcher/impl/LauncherConfig.java b/src/main/java/org/apache/sling/feature/launcher/impl/LauncherConfig.java
index efeb224..0f6298c 100644
--- a/src/main/java/org/apache/sling/feature/launcher/impl/LauncherConfig.java
+++ b/src/main/java/org/apache/sling/feature/launcher/impl/LauncherConfig.java
@@ -16,13 +16,14 @@
*/
package org.apache.sling.feature.launcher.impl;
-import org.apache.sling.feature.KeyValueMap;
import org.apache.sling.feature.io.file.ArtifactManagerConfig;
import org.apache.sling.feature.io.file.spi.ArtifactProviderContext;
import java.io.File;
import java.util.Arrays;
+import java.util.HashMap;
import java.util.LinkedHashSet;
+import java.util.Map;
/**
* This class holds the configuration of the launcher.
@@ -42,7 +43,7 @@ public class LauncherConfig
private volatile File home = new File(HOME);
- private final KeyValueMap variables = new KeyValueMap();
+ private final Map<String,String> variables = new HashMap<>();
/**
* Create a new configuration object.
@@ -92,7 +93,7 @@ public class LauncherConfig
this.installation.clear();
}
- public KeyValueMap getVariables() {
+ public Map<String,String> getVariables() {
return this.variables;
}
}