423739 Start checks module files.

At runtime, required modules files are checked.  Either a warning is generated
or they are downloaded/create if --download or --create is specified.
This commit is contained in:
Greg Wilkins 2013-12-12 16:59:58 +11:00
parent 0ac021b6fd
commit a12ad15a2c
5 changed files with 100 additions and 5 deletions

View File

@ -3,13 +3,35 @@
#
[files]
http://repo1.maven.org/maven2/org/mortbay/jetty/npn/npn-boot/1.1.6.v20130911/npn-boot-1.1.6.v20130911.jar:lib/npn/npn-boot-1.1.6.v20130911.jar
${switch java.version
1.7.0_9: http://repo1.maven.org/maven2/org/mortbay/jetty/npn/npn-boot/1.1.3.v20130313/npn-boot-1.1.3.v20130313.jar:lib/npn/npn-boot-1.1.3.v20130313.jar
1.7.0_10: http://repo1.maven.org/maven2/org/mortbay/jetty/npn/npn-boot/1.1.3.v20130313/npn-boot-1.1.3.v20130313.jar:lib/npn/npn-boot-1.1.3.v20130313.jar
1.7.0_11: http://repo1.maven.org/maven2/org/mortbay/jetty/npn/npn-boot/1.1.3.v20130313/npn-boot-1.1.3.v20130313.jar:lib/npn/npn-boot-1.1.3.v20130313.jar
1.7.0_13: http://repo1.maven.org/maven2/org/mortbay/jetty/npn/npn-boot/1.1.4.v20130313/npn-boot-1.1.4.v20130313.jar:lib/npn/npn-boot-1.1.4.v20130313.jar
1.7.0_15: http://repo1.maven.org/maven2/org/mortbay/jetty/npn/npn-boot/1.1.5.v20130313/npn-boot-1.1.5.v20130313.jar:lib/npn/npn-boot-1.1.5.v20130313.jar
1.7.0_17: http://repo1.maven.org/maven2/org/mortbay/jetty/npn/npn-boot/1.1.5.v20130313/npn-boot-1.1.5.v20130313.jar:lib/npn/npn-boot-1.1.5.v20130313.jar
1.7.0_21: http://repo1.maven.org/maven2/org/mortbay/jetty/npn/npn-boot/1.1.5.v20130313/npn-boot-1.1.5.v20130313.jar:lib/npn/npn-boot-1.1.5.v20130313.jar
1.7.0_25: http://repo1.maven.org/maven2/org/mortbay/jetty/npn/npn-boot/1.1.5.v20130313/npn-boot-1.1.5.v20130313.jar:lib/npn/npn-boot-1.1.5.v20130313.jar
1.7.0_40: http://repo1.maven.org/maven2/org/mortbay/jetty/npn/npn-boot/1.1.6.v20130911/npn-boot-1.1.6.v20130911.jar:lib/npn/npn-boot-1.1.6.v20130911.jar
1.7.0_45: http://repo1.maven.org/maven2/org/mortbay/jetty/npn/npn-boot/1.1.6.v20130911/npn-boot-1.1.6.v20130911.jar:lib/npn/npn-boot-1.1.6.v20130911.jar
*: http://repo1.maven.org/maven2/org/mortbay/jetty/npn/npn-boot/1.1.6.v20130911/npn-boot-1.1.6.v20130911.jar:lib/npn/npn-boot-1.1.6.v20130911.jar
}
[ini-template]
# NPN Configuration
# NPN boot jar for JRE 1.7.0_45
--exec
-Xbootclasspath/p:lib/npn/npn-boot-1.1.6.v20130911.jar
${switch java.version
1.7.0_9: -Xbootclasspath/p:lib/npn/npn-boot-1.1.3.v20130313.jar
1.7.0_10: -Xbootclasspath/p:lib/npn/npn-boot-1.1.3.v20130313.jar
1.7.0_11: -Xbootclasspath/p:lib/npn/npn-boot-1.1.3.v20130313.jar
1.7.0_13: -Xbootclasspath/p:lib/npn/npn-boot-1.1.4.v20130313.jar
1.7.0_15: -Xbootclasspath/p:lib/npn/npn-boot-1.1.5.v20130313.jar
1.7.0_17: -Xbootclasspath/p:lib/npn/npn-boot-1.1.5.v20130313.jar
1.7.0_21: -Xbootclasspath/p:lib/npn/npn-boot-1.1.5.v20130313.jar
1.7.0_25: -Xbootclasspath/p:lib/npn/npn-boot-1.1.5.v20130313.jar
1.7.0_40: -Xbootclasspath/p:lib/npn/npn-boot-1.1.6.v20130911.jar
1.7.0_45: -Xbootclasspath/p:lib/npn/npn-boot-1.1.6.v20130911.jar
*: -Xbootclasspath/p:lib/npn/npn-boot-1.1.6.v20130911.jar
}
# For other versions of JRE, an appropriate npn-boot jar must be downloaded
#

View File

@ -661,6 +661,24 @@ public class Main
moduleIni(args,module,true,false);
}
// Check files
for (FileArg arg : args.getFiles())
{
File file = baseHome.getBaseFile(arg.location);
if (!file.exists() && args.isDownload())
initFile(arg);
if (!file.exists())
{
args.setRun(false);
String type=arg.location.endsWith("/")?"directory":"file";
if (arg.uri==null)
StartLog.warn("Required %s '%s' does not exist. Run with --create",type,baseHome.toShortForm(file));
else
StartLog.warn("Required %s '%s' not downloaded from %s. Run with --download",type,baseHome.toShortForm(file),arg.uri);
}
}
// Informational command line, don't run jetty
if (!args.isRun())
{

View File

@ -260,9 +260,37 @@ public class Module
{
String line;
String sectionType = "";
String caseTag = null;
boolean switched = false;
while ((line = buf.readLine()) != null)
{
line = line.trim();
if (caseTag!=null)
{
if ("}".equals(line))
{
caseTag=null;
continue;
}
if (switched)
continue;
if (!line.startsWith(caseTag) && !line.startsWith("*:"))
continue;
switched=true;
line=line.substring(line.indexOf(':')+1).trim();
}
else if (line.startsWith("${switch "))
{
switched=false;
caseTag=line.substring(9).trim();
caseTag=System.getProperty(caseTag)+":";
continue;
}
Matcher sectionMatcher = section.matcher(line);
if (sectionMatcher.matches())

View File

@ -85,6 +85,7 @@ public class StartArgs
private Modules allModules;
// Should the server be run?
private boolean run = true;
private boolean download = false;
private boolean help = false;
private boolean stopCommand = false;
private boolean listModules = false;
@ -534,6 +535,11 @@ public class StartArgs
return false;
}
public boolean isDownload()
{
return download;
}
public boolean isDryRun()
{
return dryRun;
@ -564,6 +570,11 @@ public class StartArgs
return listModules;
}
public void setRun(boolean run)
{
this.run = run;
}
public boolean isRun()
{
return run;
@ -647,6 +658,15 @@ public class StartArgs
if (arg.startsWith("--download="))
{
addFile(getValue(arg));
run=false;
download=true;
return;
}
if (arg.equals("--download") || arg.equals("--create"))
{
run=false;
download=true;
return;
}
@ -864,4 +884,5 @@ public class StartArgs
builder.append("]");
return builder.toString();
}
}

View File

@ -94,6 +94,12 @@ Module Management:
See http://graphviz.org/ for details on how to post-process
this file into the output best suited for your needs.
--download Download or create any missing files/directories that are
required by initialised modules.
--create Download or create any missing files/directories that are
required by initialised modules.
Startup / Shutdown Command Line:
--------------------------------