Skip to content
Permalink
Browse files

Merge branch 'master' of https://github.com/update4j/update4j

  • Loading branch information...
mordechaim committed Feb 24, 2019
2 parents 49d914c + e8585e4 commit 5edc494c02b49cd025ce99cb9c6fc6df525b91d9
Showing with 18 additions and 21 deletions.
  1. +18 −21 src/main/java/org/update4j/service/DefaultLauncher.java
@@ -31,7 +31,7 @@

public static final String DOMAIN_PREFIX = "default.launcher";
public static final String MAIN_CLASS_PROPERTY_KEY = DOMAIN_PREFIX + ".main.class";
public static final String ARGUMENT_PROPERTY_KEY = DOMAIN_PREFIX + ".argument";
public static final String ARGUMENT_PROPERTY_KEY_PREFIX = DOMAIN_PREFIX + ".argument";
public static final String SYSTEM_PROPERTY_KEY_PREFIX = DOMAIN_PREFIX + ".system";

@InjectTarget(required = false)
@@ -70,28 +70,24 @@ public void run(LaunchContext context) {
if (this.args != null)
localArgs.addAll(this.args);

// use TreeMap to sort
Map<String, String> argMap = new TreeMap<>();
context.getConfiguration().getResolvedProperties().entrySet().stream().forEach(e -> {
final String pfx = ARGUMENT_PROPERTY_KEY + ".";
// starts with but not equals, to filter missing <key> part
if (e.getKey().startsWith(pfx) && !e.getKey().equals(pfx)) {
String key = e.getKey().substring(pfx.length());
argMap.put(key, e.getValue());
// use TreeMap to sort by key
Map<Integer, String> argMap = new TreeMap<>();
context.getConfiguration().getResolvedProperties().forEach((k,v) -> {
String pfx = ARGUMENT_PROPERTY_KEY_PREFIX + ".";
// starts with but not equals, to filter missing <num> part
if (k.startsWith(pfx) && !k.equals(pfx)) {
int num = Integer.parseInt(k.substring(pfx.length()));
argMap.put(num, v);
}
});
argMap.entrySet().stream().forEach(e -> {
localArgs.add(e.getValue());
});


localArgs.addAll(argMap.values());
String[] argsArray = localArgs.toArray(new String[localArgs.size()]);

context.getConfiguration().getResolvedProperties().entrySet().stream().forEach(e -> {
context.getConfiguration().getResolvedProperties().forEach((k,v) -> {
String pfx = SYSTEM_PROPERTY_KEY_PREFIX + ".";
// starts with but not equals, to filter missing <key> part
if (e.getKey().startsWith(pfx) && !e.getKey().equals(pfx)) {
String key = e.getKey().substring(pfx.length());
System.setProperty(key, e.getValue());
if (k.startsWith(pfx) && !k.equals(pfx)) {
System.setProperty(k.substring(pfx.length()), v);
}
});

@@ -145,9 +141,10 @@ private static String table() {
+ "\t\t| | |\n"
+ "\t\t| | Required. |\n"
+ "\t\t+--------------------------------+------------------------------------+\n"
+ "\t\t| default.launcher.argument.<key>| Pass values in the args list, |\n"
+ "\t\t| | ordered by the default String sort |\n"
+ "\t\t| | algorithm of <key>. |\n"
+ "\t\t| default.launcher.argument.<num>| Pass values in the args list, |\n"
+ "\t\t| | ordered by <num>. It will throw a |\n"
+ "\t\t| | NumberFormatException if <num> is |\n"
+ "\t\t| | not a valid integer. |\n"
+ "\t\t| | |\n"
+ "\t\t| | Arguments passed from the bootstrap|\n"
+ "\t\t| | are always first in the list |\n"

0 comments on commit 5edc494

Please sign in to comment.
You can’t perform that action at this time.