Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Wilkins2014-05-13 10:04:10 +0000
committerGreg Wilkins2014-05-13 10:31:06 +0000
commit51324a27861b96cb9efae379d5d05d39e64c0b4c (patch)
treed9512acc55041aeb756a268052442b38dff49337 /jetty-start
parentfb2010177c55c6c144e1e52dd9aa1321b534e089 (diff)
downloadorg.eclipse.jetty.project-51324a27861b96cb9efae379d5d05d39e64c0b4c.tar.gz
org.eclipse.jetty.project-51324a27861b96cb9efae379d5d05d39e64c0b4c.tar.xz
org.eclipse.jetty.project-51324a27861b96cb9efae379d5d05d39e64c0b4c.zip
434505 Allow property files on start.jar command line
Signed-off-by: Tom Zeller<tzeller@dragonacea.biz> (cherry picked from commit d621df3c3482cccb1153a85936a8d80eedc0a032) Conflicts: jetty-start/src/main/java/org/eclipse/jetty/start/FS.java jetty-start/src/main/java/org/eclipse/jetty/start/StartArgs.java
Diffstat (limited to 'jetty-start')
-rw-r--r--jetty-start/src/main/java/org/eclipse/jetty/start/FS.java12
-rw-r--r--jetty-start/src/main/java/org/eclipse/jetty/start/Main.java3
-rw-r--r--jetty-start/src/main/java/org/eclipse/jetty/start/StartArgs.java49
3 files changed, 63 insertions, 1 deletions
diff --git a/jetty-start/src/main/java/org/eclipse/jetty/start/FS.java b/jetty-start/src/main/java/org/eclipse/jetty/start/FS.java
index 9b55b45c0a..69a7344baf 100644
--- a/jetty-start/src/main/java/org/eclipse/jetty/start/FS.java
+++ b/jetty-start/src/main/java/org/eclipse/jetty/start/FS.java
@@ -120,7 +120,17 @@ public class FS
{
return filename.toLowerCase(Locale.ENGLISH).endsWith(".xml");
}
-
+
+ public static String toRelativePath(File baseDir, File path)
+ {
+ return baseDir.toURI().relativize(path.toURI()).toASCIIString();
+ }
+
+ public static boolean isPropertyFile(String filename)
+ {
+ return filename.toLowerCase(Locale.ENGLISH).endsWith(".properties");
+ }
+
public static String separators(String path)
{
StringBuilder ret = new StringBuilder();
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 236deba1a0..682c908271 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
@@ -593,6 +593,9 @@ public class Main
// ------------------------------------------------------------
// 6) Resolve Extra XMLs
args.resolveExtraXmls(baseHome);
+
+ // 9) Resolve Property Files
+ args.resolvePropertyFiles(baseHome);
return args;
}
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 0ca8c09ef7..47a24cb837 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
@@ -88,6 +88,12 @@ public class StartArgs
/** List of all xml references found directly on command line or start.ini */
private List<String> xmlRefs = new ArrayList<>();
+ /** List of all property references found directly on command line or start.ini */
+ private List<String> propertyFileRefs = new ArrayList<>();
+
+ /** List of all property files */
+ private List<Path> propertyFiles = new ArrayList<>();
+
private Props properties = new Props();
private Set<String> systemPropertyKeys = new HashSet<>();
private List<String> rawLibs = new ArrayList<>();
@@ -149,6 +155,19 @@ public class StartArgs
xmls.add(xmlfile);
}
}
+
+ private void addUniquePropertyFile(String propertyFileRef, Path propertyFile) throws IOException
+ {
+ if (!FS.canReadFile(propertyFile))
+ {
+ throw new IOException("Cannot read file: " + propertyFileRef);
+ }
+ propertyFile = FS.toRealPath(propertyFile);
+ if (!propertyFiles.contains(propertyFile))
+ {
+ propertyFiles.add(propertyFile);
+ }
+ }
public void dumpActiveXmls(BaseHome baseHome)
{
@@ -506,6 +525,11 @@ public class StartArgs
{
cmd.addRawArg(xml.toAbsolutePath().toString());
}
+
+ for (Path propertyFile : propertyFiles)
+ {
+ cmd.addRawArg(propertyFile.toAbsolutePath().toString());
+ }
return cmd;
}
@@ -844,6 +868,16 @@ public class StartArgs
}
return;
}
+
+ if (FS.isPropertyFile(arg))
+ {
+ // only add non-duplicates
+ if (!propertyFileRefs.contains(arg))
+ {
+ propertyFileRefs.add(arg);
+ }
+ return;
+ }
// Anything else is unrecognized
throw new UsageException(ERR_BAD_ARG,"Unrecognized argument: \"%s\" in %s",arg,source);
@@ -863,6 +897,21 @@ public class StartArgs
addUniqueXmlFile(xmlRef,xmlfile);
}
}
+
+ public void resolvePropertyFiles(BaseHome baseHome) throws IOException
+ {
+ // Find and Expand property files
+ for (String propertyFileRef : propertyFileRefs)
+ {
+ // Straight Reference
+ Path propertyFile = baseHome.getPath(propertyFileRef);
+ if (!FS.exists(propertyFile))
+ {
+ propertyFile = baseHome.getPath("etc/" + propertyFileRef);
+ }
+ addUniquePropertyFile(propertyFileRef,propertyFile);
+ }
+ }
public void setAllModules(Modules allModules)
{

Back to the top