Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoakim Erdfelt2014-06-04 22:48:58 +0000
committerJoakim Erdfelt2014-06-04 22:48:58 +0000
commit5f8ed9519bffb3a4a9a4552c2ed1a511dcd83619 (patch)
tree56565ea562617daaabcc916766ecca19e78391c2 /jetty-start
parent7ee2f4e367607a542a87c31c57fb0a680ba15619 (diff)
downloadorg.eclipse.jetty.project-5f8ed9519bffb3a4a9a4552c2ed1a511dcd83619.tar.gz
org.eclipse.jetty.project-5f8ed9519bffb3a4a9a4552c2ed1a511dcd83619.tar.xz
org.eclipse.jetty.project-5f8ed9519bffb3a4a9a4552c2ed1a511dcd83619.zip
Restore Origin/Source information of raw arguments from ConfigSource(s)
+ Change will remember where each raw argument from a DirConfigSource comes from (previously only remembered the origin of properties)
Diffstat (limited to 'jetty-start')
-rw-r--r--jetty-start/src/main/java/org/eclipse/jetty/start/Main.java1
-rw-r--r--jetty-start/src/main/java/org/eclipse/jetty/start/Props.java12
-rw-r--r--jetty-start/src/main/java/org/eclipse/jetty/start/RawArgs.java97
-rw-r--r--jetty-start/src/main/java/org/eclipse/jetty/start/StartArgs.java4
-rw-r--r--jetty-start/src/main/java/org/eclipse/jetty/start/StartLog.java6
-rw-r--r--jetty-start/src/main/java/org/eclipse/jetty/start/config/CommandLineConfigSource.java12
-rw-r--r--jetty-start/src/main/java/org/eclipse/jetty/start/config/ConfigSource.java5
-rw-r--r--jetty-start/src/main/java/org/eclipse/jetty/start/config/ConfigSources.java5
-rw-r--r--jetty-start/src/main/java/org/eclipse/jetty/start/config/DirConfigSource.java11
9 files changed, 126 insertions, 27 deletions
diff --git a/jetty-start/src/main/java/org/eclipse/jetty/start/Main.java b/jetty-start/src/main/java/org/eclipse/jetty/start/Main.java
index f1482a529d..8859cff7d2 100644
--- a/jetty-start/src/main/java/org/eclipse/jetty/start/Main.java
+++ b/jetty-start/src/main/java/org/eclipse/jetty/start/Main.java
@@ -475,6 +475,7 @@ public class Main
// Also list other places this module is enabled
for (String source : module.getSources())
{
+ StartLog.debug("also enabled in: %s",source);
if (!short_start_ini.equals(source))
{
StartLog.info("%-15s enabled in %s",name,baseHome.toShortForm(source));
diff --git a/jetty-start/src/main/java/org/eclipse/jetty/start/Props.java b/jetty-start/src/main/java/org/eclipse/jetty/start/Props.java
index f760f6e8e2..20a7434b84 100644
--- a/jetty-start/src/main/java/org/eclipse/jetty/start/Props.java
+++ b/jetty-start/src/main/java/org/eclipse/jetty/start/Props.java
@@ -114,7 +114,7 @@ public final class Props implements Iterable<Prop>
* @param arg the argument to parse for a potential property
* @param source the source for this argument (to track origin of property from)
*/
- public void addPossibleProperty(String arg, String source)
+ public boolean addPossibleProperty(String arg, String source)
{
// Start property (syntax similar to System property)
if (arg.startsWith("-D"))
@@ -125,15 +125,14 @@ public final class Props implements Iterable<Prop>
case 2:
setSystemProperty(assign[0],assign[1]);
setProperty(assign[0],assign[1],source);
- break;
+ return true;
case 1:
setSystemProperty(assign[0],"");
setProperty(assign[0],"",source);
- break;
+ return true;
default:
- break;
+ return false;
}
- return;
}
// Is this a raw property declaration?
@@ -144,10 +143,11 @@ public final class Props implements Iterable<Prop>
String value = arg.substring(idx + 1);
setProperty(key,value,source);
- return;
+ return true;
}
// All other strings are ignored
+ return false;
}
public String cleanReference(String property)
diff --git a/jetty-start/src/main/java/org/eclipse/jetty/start/RawArgs.java b/jetty-start/src/main/java/org/eclipse/jetty/start/RawArgs.java
new file mode 100644
index 0000000000..6464a35d17
--- /dev/null
+++ b/jetty-start/src/main/java/org/eclipse/jetty/start/RawArgs.java
@@ -0,0 +1,97 @@
+//
+// ========================================================================
+// Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Eclipse Public License v1.0
+// and Apache License v2.0 which accompanies this distribution.
+//
+// The Eclipse Public License is available at
+// http://www.eclipse.org/legal/epl-v10.html
+//
+// The Apache License v2.0 is available at
+// http://www.opensource.org/licenses/apache2.0.php
+//
+// You may elect to redistribute this code under either of these licenses.
+// ========================================================================
+//
+
+package org.eclipse.jetty.start;
+
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.jetty.start.RawArgs.Entry;
+
+public class RawArgs implements Iterable<Entry>
+{
+ public class Entry
+ {
+ private String line;
+ private String origin;
+
+ private Entry(String line, String origin)
+ {
+ this.line = line;
+ this.origin = origin;
+ }
+
+ public String getLine()
+ {
+ return line;
+ }
+
+ public String getOrigin()
+ {
+ return origin;
+ }
+
+ public boolean startsWith(String val)
+ {
+ return line.startsWith(val);
+ }
+ }
+
+ /**
+ * All of the args, in argument order
+ */
+ private List<Entry> args = new ArrayList<>();
+
+ public void addAll(List<String> lines, Path sourceFile)
+ {
+ String source = sourceFile.toAbsolutePath().toString();
+ for (String line : lines)
+ {
+ addArg(line,source);
+ }
+ }
+
+ public void addArg(final String rawline, final String source)
+ {
+ if (rawline == null)
+ {
+ return;
+ }
+
+ String line = rawline.trim();
+ if (line.length() == 0)
+ {
+ return;
+ }
+
+ args.add(new Entry(line,source));
+ }
+
+ @Override
+ public Iterator<Entry> iterator()
+ {
+ return args.iterator();
+ }
+
+ public int size()
+ {
+ return args.size();
+ }
+}
diff --git a/jetty-start/src/main/java/org/eclipse/jetty/start/StartArgs.java b/jetty-start/src/main/java/org/eclipse/jetty/start/StartArgs.java
index d1e6623ad0..43df38122a 100644
--- a/jetty-start/src/main/java/org/eclipse/jetty/start/StartArgs.java
+++ b/jetty-start/src/main/java/org/eclipse/jetty/start/StartArgs.java
@@ -639,9 +639,9 @@ public class StartArgs
while (iter.hasPrevious())
{
ConfigSource source = iter.previous();
- for (String arg : source.getArgs())
+ for (RawArgs.Entry arg : source.getArgs())
{
- parse(arg,source.getId());
+ parse(arg.getLine(),arg.getOrigin());
}
}
}
diff --git a/jetty-start/src/main/java/org/eclipse/jetty/start/StartLog.java b/jetty-start/src/main/java/org/eclipse/jetty/start/StartLog.java
index 963433c65e..75f8280d63 100644
--- a/jetty-start/src/main/java/org/eclipse/jetty/start/StartLog.java
+++ b/jetty-start/src/main/java/org/eclipse/jetty/start/StartLog.java
@@ -96,9 +96,9 @@ public class StartLog
String logFileName = cmdLineSource.getProperty("start-log-file");
- for (String arg : cmdLineSource.getArgs())
+ for (RawArgs.Entry arg : cmdLineSource.getArgs())
{
- if ("--debug".equals(arg))
+ if ("--debug".equals(arg.getLine()))
{
debug = true;
continue;
@@ -106,7 +106,7 @@ public class StartLog
if (arg.startsWith("--start-log-file"))
{
- logFileName = Props.getValue(arg);
+ logFileName = Props.getValue(arg.getLine());
continue;
}
}
diff --git a/jetty-start/src/main/java/org/eclipse/jetty/start/config/CommandLineConfigSource.java b/jetty-start/src/main/java/org/eclipse/jetty/start/config/CommandLineConfigSource.java
index 61f9f643f1..934158f1ac 100644
--- a/jetty-start/src/main/java/org/eclipse/jetty/start/config/CommandLineConfigSource.java
+++ b/jetty-start/src/main/java/org/eclipse/jetty/start/config/CommandLineConfigSource.java
@@ -23,8 +23,6 @@ import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.file.Path;
-import java.util.Arrays;
-import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -32,6 +30,7 @@ import org.eclipse.jetty.start.BaseHome;
import org.eclipse.jetty.start.FS;
import org.eclipse.jetty.start.Props;
import org.eclipse.jetty.start.Props.Prop;
+import org.eclipse.jetty.start.RawArgs;
import org.eclipse.jetty.start.UsageException;
/**
@@ -42,17 +41,18 @@ public class CommandLineConfigSource implements ConfigSource
public static final String ORIGIN_INTERNAL_FALLBACK = "<internal-fallback>";
public static final String ORIGIN_CMD_LINE = "<command-line>";
- private final List<String> args;
+ private final RawArgs args;
private final Props props;
private final Path homePath;
private final Path basePath;
public CommandLineConfigSource(String rawargs[])
{
- this.args = Arrays.asList(rawargs);
+ this.args = new RawArgs();
this.props = new Props();
- for (String arg : args)
+ for (String arg : rawargs)
{
+ this.args.addArg(arg,ORIGIN_CMD_LINE);
this.props.addPossibleProperty(arg,ORIGIN_CMD_LINE);
}
@@ -179,7 +179,7 @@ public class CommandLineConfigSource implements ConfigSource
}
@Override
- public List<String> getArgs()
+ public RawArgs getArgs()
{
return args;
}
diff --git a/jetty-start/src/main/java/org/eclipse/jetty/start/config/ConfigSource.java b/jetty-start/src/main/java/org/eclipse/jetty/start/config/ConfigSource.java
index 47abc1745d..ba81a2a6c9 100644
--- a/jetty-start/src/main/java/org/eclipse/jetty/start/config/ConfigSource.java
+++ b/jetty-start/src/main/java/org/eclipse/jetty/start/config/ConfigSource.java
@@ -18,9 +18,8 @@
package org.eclipse.jetty.start.config;
-import java.util.List;
-
import org.eclipse.jetty.start.Props;
+import org.eclipse.jetty.start.RawArgs;
/**
* A Configuration Source
@@ -57,7 +56,7 @@ public interface ConfigSource
*
* @return the list of Arguments for this ConfigSource
*/
- public List<String> getArgs();
+ public RawArgs getArgs();
/**
* The properties for this ConfigSource
diff --git a/jetty-start/src/main/java/org/eclipse/jetty/start/config/ConfigSources.java b/jetty-start/src/main/java/org/eclipse/jetty/start/config/ConfigSources.java
index 4eb3713ccc..7bd3780357 100644
--- a/jetty-start/src/main/java/org/eclipse/jetty/start/config/ConfigSources.java
+++ b/jetty-start/src/main/java/org/eclipse/jetty/start/config/ConfigSources.java
@@ -31,6 +31,7 @@ import java.util.concurrent.atomic.AtomicInteger;
import org.eclipse.jetty.start.FS;
import org.eclipse.jetty.start.Props;
+import org.eclipse.jetty.start.RawArgs;
import org.eclipse.jetty.start.Props.Prop;
import org.eclipse.jetty.start.UsageException;
@@ -67,11 +68,11 @@ public class ConfigSources implements Iterable<ConfigSource>
updateProps();
// look for --include-jetty-dir entries
- for (String arg : source.getArgs())
+ for (RawArgs.Entry arg : source.getArgs())
{
if (arg.startsWith("--include-jetty-dir"))
{
- String ref = getValue(arg);
+ String ref = getValue(arg.getLine());
String dirName = props.expand(ref);
Path dir = FS.toPath(dirName);
DirConfigSource dirsource = new DirConfigSource(ref,dir,sourceWeight.incrementAndGet(),true);
diff --git a/jetty-start/src/main/java/org/eclipse/jetty/start/config/DirConfigSource.java b/jetty-start/src/main/java/org/eclipse/jetty/start/config/DirConfigSource.java
index 9befbe8d98..589905c9ef 100644
--- a/jetty-start/src/main/java/org/eclipse/jetty/start/config/DirConfigSource.java
+++ b/jetty-start/src/main/java/org/eclipse/jetty/start/config/DirConfigSource.java
@@ -33,6 +33,7 @@ import org.eclipse.jetty.start.FS;
import org.eclipse.jetty.start.NaturalSort;
import org.eclipse.jetty.start.PathMatchers;
import org.eclipse.jetty.start.Props;
+import org.eclipse.jetty.start.RawArgs;
import org.eclipse.jetty.start.UsageException;
import org.eclipse.jetty.start.Props.Prop;
import org.eclipse.jetty.start.StartIni;
@@ -71,7 +72,7 @@ public class DirConfigSource implements ConfigSource
private final String id;
private final Path dir;
private final int weight;
- private final List<String> args;
+ private final RawArgs args;
private final Props props;
/**
@@ -95,7 +96,7 @@ public class DirConfigSource implements ConfigSource
this.weight = weight;
this.props = new Props();
- this.args = new ArrayList<>();
+ this.args = new RawArgs();
if (canHaveArgs)
{
@@ -103,7 +104,7 @@ public class DirConfigSource implements ConfigSource
if (FS.canReadFile(iniFile))
{
StartIni ini = new StartIni(iniFile);
- args.addAll(ini.getLines());
+ args.addAll(ini.getLines(),iniFile);
parseAllArgs(ini.getLines(),iniFile.toString());
}
@@ -138,7 +139,7 @@ public class DirConfigSource implements ConfigSource
{
StartLog.debug("Reading %s/start.d/%s - %s",id,diniFile.getFileName(),diniFile);
StartIni ini = new StartIni(diniFile);
- args.addAll(ini.getLines());
+ args.addAll(ini.getLines(),diniFile);
parseAllArgs(ini.getLines(),diniFile.toString());
}
}
@@ -194,7 +195,7 @@ public class DirConfigSource implements ConfigSource
}
@Override
- public List<String> getArgs()
+ public RawArgs getArgs()
{
return args;
}

Back to the top