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 fdd4cf68abc..e8d7806dd60 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
@@ -42,6 +42,8 @@ import java.util.Collections;
import java.util.List;
import java.util.Locale;
+import org.eclipse.jetty.start.StartArgs.DownloadArg;
+
/**
* Main start class.
*
@@ -168,18 +170,11 @@ public class Main
}).start();
}
- private void download(String arg)
+ private void download(DownloadArg arg)
{
try
{
- String[] split = arg.split("|",3);
- if ((split.length != 3) || "http".equalsIgnoreCase(split[0]) || !split[1].startsWith("//"))
- {
- throw new IllegalArgumentException("Not --download=:");
- }
-
- String location = split[2];
- File file = baseHome.getBaseFile(location);
+ File file = baseHome.getBaseFile(arg.location);
StartLog.debug("Download to %s %s",file.getAbsolutePath(),(file.exists()?"[Exists!]":""));
if (file.exists())
@@ -187,9 +182,9 @@ public class Main
return;
}
- URL url = new URL(split[0].substring(11) + ":" + split[1]);
+ URL url = new URL(arg.uri);
- System.err.println("DOWNLOAD: " + url + " to " + location);
+ System.err.println("DOWNLOAD: " + url + " to " + arg.location);
FS.ensureDirectoryExists(file.getParentFile());
@@ -445,6 +440,12 @@ public class Main
usage(true);
}
+ // Various Downloads
+ for (DownloadArg url : args.getDownloads())
+ {
+ download(url);
+ }
+
// Show the version information and return
if (args.isListClasspath())
{
@@ -470,12 +471,6 @@ public class Main
System.out.println(cmd.toString());
}
- // Various Downloads
- for (String url : args.getDownloads())
- {
- download(url);
- }
-
// Enables/Disable
ModulePersistence persistence = loadModulePersistence();
if (args.isModulePersistenceChanging())
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 8179a34d28b..1020ca78d08 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
@@ -39,7 +39,76 @@ import java.util.Set;
*/
public class StartArgs
{
+ public static class DownloadArg
+ {
+ public String uri;
+ public String location;
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (this == obj)
+ {
+ return true;
+ }
+ if (obj == null)
+ {
+ return false;
+ }
+ if (getClass() != obj.getClass())
+ {
+ return false;
+ }
+ DownloadArg other = (DownloadArg)obj;
+ if (uri == null)
+ {
+ if (other.uri != null)
+ {
+ return false;
+ }
+ }
+ else if (!uri.equals(other.uri))
+ {
+ return false;
+ }
+ if (location == null)
+ {
+ if (other.location != null)
+ {
+ return false;
+ }
+ }
+ else if (!location.equals(other.location))
+ {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ final int prime = 31;
+ int result = 1;
+ result = (prime * result) + ((uri == null)?0:uri.hashCode());
+ result = (prime * result) + ((location == null)?0:location.hashCode());
+ return result;
+ }
+
+ @Override
+ public String toString()
+ {
+ StringBuilder builder = new StringBuilder();
+ builder.append("DownloadArg [uri=");
+ builder.append(uri);
+ builder.append(", location=");
+ builder.append(location);
+ builder.append("]");
+ return builder.toString();
+ }
+ }
public static final String CMD_LINE_SOURCE = "";
+
public static final String VERSION;
static
@@ -70,7 +139,7 @@ public class StartArgs
private List commandLine = new ArrayList<>();
private Set modules = new HashSet<>();
private Map> sources = new HashMap<>();
- private List downloads = new ArrayList<>();
+ private List downloads = new ArrayList<>();
private Classpath classpath;
private List xmlRefs = new ArrayList<>();
private List xmls = new ArrayList<>();
@@ -100,6 +169,31 @@ public class StartArgs
classpath = new Classpath();
}
+ private void addDownload(String uriLocation)
+ {
+ String parts[] = uriLocation.split(":",3);
+ if (parts.length != 3)
+ {
+ throw new IllegalArgumentException("Not :");
+ }
+ if (!"http".equalsIgnoreCase(parts[0]))
+ {
+ throw new IllegalArgumentException("Download only supports http protocol");
+ }
+ if (!parts[1].startsWith("//"))
+ {
+ throw new IllegalArgumentException("Download URI invalid: " + uriLocation);
+ }
+ DownloadArg arg = new DownloadArg();
+ arg.uri = String.format("%s:%s",parts[0],parts[1]);
+ arg.location = parts[2];
+
+ if (!downloads.contains(arg))
+ {
+ downloads.add(arg);
+ }
+ }
+
public void addSystemProperty(String key, String value)
{
this.systemPropertyKeys.add(key);
@@ -186,25 +280,6 @@ public class StartArgs
}
}
- public void dumpSystemProperties()
- {
- System.out.println();
- System.out.println("System Properties:");
- System.out.println("------------------");
-
- if (systemPropertyKeys.isEmpty())
- {
- System.out.println(" (no system properties specified)");
- return;
- }
-
- for (String key : systemPropertyKeys)
- {
- String value = System.getProperty(key);
- System.out.printf(" %s = %s%n",key,value);
- }
- }
-
public void dumpProperties()
{
System.out.println();
@@ -227,6 +302,25 @@ public class StartArgs
}
}
+ public void dumpSystemProperties()
+ {
+ System.out.println();
+ System.out.println("System Properties:");
+ System.out.println("------------------");
+
+ if (systemPropertyKeys.isEmpty())
+ {
+ System.out.println(" (no system properties specified)");
+ return;
+ }
+
+ for (String key : systemPropertyKeys)
+ {
+ String value = System.getProperty(key);
+ System.out.printf(" %s = %s%n",key,value);
+ }
+ }
+
private void dumpSystemProperty(String key)
{
System.out.printf(" %s=%s%n",key,System.getProperty(key));
@@ -328,16 +422,18 @@ public class StartArgs
File xmlfile = baseHome.getFile(xmlRef);
addUniqueXmlFile(xmlRef,xmlfile);
}
-
+
// Register Download operations
- for ( String download : module.getDownloads() )
+ for (String download : module.getDownloads())
{
- downloads.add(download);
+ StartLog.debug("Adding module specified download: %s",download);
+ addDownload(download);
}
-
+
// Register BootLib references
- for ( String bootlib : module.getBootLibs() )
+ for (String bootlib : module.getBootLibs())
{
+ StartLog.debug("Adding module specified bootlib: %s",bootlib);
exec = true;
jvmArgs.add(bootlib);
}
@@ -369,8 +465,9 @@ public class StartArgs
return disable;
}
- public List getDownloads()
- {
+ public List getDownloads()
+
+ {
return downloads;
}
@@ -396,7 +493,7 @@ public class StartArgs
{
cmd.addArg(x);
}
-
+
cmd.addRawArg("-Djetty.home=" + baseHome.getHome());
cmd.addRawArg("-Djetty.base=" + baseHome.getBase());
@@ -456,11 +553,6 @@ public class StartArgs
return modulePersistEnable;
}
- public boolean isModulePersistenceChanging()
- {
- return (modulePersistDisable.size() > 0) || (modulePersistEnable.size() > 0);
- }
-
public Properties getProperties()
{
return properties;
@@ -559,6 +651,11 @@ public class StartArgs
return listModules;
}
+ public boolean isModulePersistenceChanging()
+ {
+ return (modulePersistDisable.size() > 0) || (modulePersistEnable.size() > 0);
+ }
+
public boolean isRun()
{
return run;
@@ -624,7 +721,7 @@ public class StartArgs
if (arg.startsWith("--download="))
{
- downloads.add(getValue(arg));
+ addDownload(getValue(arg));
return;
}
diff --git a/jetty-start/src/test/java/org/eclipse/jetty/start/ConfigurationAssert.java b/jetty-start/src/test/java/org/eclipse/jetty/start/ConfigurationAssert.java
index 59013b6116c..e83e68f8ee7 100644
--- a/jetty-start/src/test/java/org/eclipse/jetty/start/ConfigurationAssert.java
+++ b/jetty-start/src/test/java/org/eclipse/jetty/start/ConfigurationAssert.java
@@ -31,6 +31,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
+import org.eclipse.jetty.start.StartArgs.DownloadArg;
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
import org.junit.Assert;
@@ -108,7 +109,7 @@ public class ConfigurationAssert
actualProperties.add(name + "=" + value);
}
assertContainsUnordered("Properties",expectedProperties,actualProperties);
-
+
// Validate Downloads
Set expectedDownloads = new HashSet<>();
for (String line : textFile)
@@ -119,12 +120,12 @@ public class ConfigurationAssert
}
}
Set actualDownloads = new HashSet<>();
- for (String line : args.getDownloads())
+ for (DownloadArg darg : args.getDownloads())
{
- actualDownloads.add(line);
+ actualDownloads.add(String.format("%s:%s",darg.uri,darg.location));
}
assertContainsUnordered("Downloads",expectedDownloads,actualDownloads);
-
+
// Validate Jvm Args / BootLib Entries
Set expectedJvmArgs = new HashSet<>();
for (String line : textFile)
@@ -140,9 +141,9 @@ public class ConfigurationAssert
actualJvmArgs.add(line);
}
assertContainsUnordered("JvmArgs",expectedJvmArgs,actualJvmArgs);
- if ( expectedJvmArgs.size() > 0 )
+ if (expectedJvmArgs.size() > 0)
{
- Assert.assertTrue("exec has been turned on", args.isExec());
+ Assert.assertTrue("exec has been turned on",args.isExec());
}
}