414635 Modular start.d and jetty.base property

Merged branch jetty-9.1-altstart with cherry picks of
ecf30e4
72f8143
998f95b
46a9495
fe4b922
3443593
2b40990
07636db
4e1a62b
aed6811
578613e
b1b394b
This commit is contained in:
Greg Wilkins 2013-08-19 16:29:01 +10:00
parent b1b394b4bf
commit c0402dec4a
3 changed files with 45 additions and 4 deletions

View File

@ -51,7 +51,7 @@ public class HomeBase
public HomeBase(File homeDir, File baseDir)
{
this.homeDir = homeDir;
this.baseDir = baseDir;
this.baseDir = baseDir==null?homeDir:baseDir;
}
public boolean isBaseDifferent()

View File

@ -47,6 +47,8 @@ import java.util.List;
import java.util.Locale;
import java.util.Properties;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.eclipse.jetty.start.StartIni.IncludeListener;
@ -65,6 +67,7 @@ public class Main implements IncludeListener
{
private static final String START_LOG_FILENAME = "start.log";
private static final SimpleDateFormat START_LOG_ROLLOVER_DATEFORMAT = new SimpleDateFormat("yyyy_MM_dd-HHmmSSSSS.'" + START_LOG_FILENAME + "'");
private static final Pattern NNN_MODULE_INI = Pattern.compile("^(\\d\\d\\d-)(.*?\\.ini)(\\.disabled)?$");
private static final int EXIT_USAGE = 1;
private static final int ERR_LOGGING = -1;
@ -1183,7 +1186,7 @@ public class Main implements IncludeListener
final String mini = module + ".ini";
final String disable = module + ".ini.disabled";
FileFilter disabledModuleFilter = new FS.FileNamesFilter(mini, disable);
FileFilter disabledModuleFilter = new FS.FilenameRegexFilter("(\\d\\d\\d-)?"+Pattern.quote(module)+"\\.ini(\\.disabled)?");
HomeBase hb = _config.getHomeBase();
@ -1206,6 +1209,25 @@ public class Main implements IncludeListener
file.renameTo(new File(file.getParentFile(),mini));
found = true;
}
else
{
Matcher matcher = NNN_MODULE_INI.matcher(n);
if (matcher.matches())
{
if (matcher.group(3)==null)
{
System.err.printf("Module %s already enabled in %s as %s%n",module,hb.toShortForm(file.getParent()),n);
found = true;
}
else
{
String enabled=matcher.group(1)+mini;
System.err.printf("Enabling Module %s in %s as %s%n",module,hb.toShortForm(file.getParent()),enabled);
file.renameTo(new File(file.getParentFile(),enabled));
found = true;
}
}
}
}
}
@ -1223,7 +1245,7 @@ public class Main implements IncludeListener
final String mini = module + ".ini";
final String disable = module + ".ini.disabled";
FileFilter disabledModuleFilter = new FS.FileNamesFilter(mini, disable);
FileFilter disabledModuleFilter = new FS.FilenameRegexFilter("(\\d\\d\\d-)?"+Pattern.quote(module)+"\\.ini(\\.disabled)?");
HomeBase hb = _config.getHomeBase();
@ -1246,6 +1268,25 @@ public class Main implements IncludeListener
file.renameTo(new File(file.getParentFile(),disable));
found = true;
}
else
{
Matcher matcher = NNN_MODULE_INI.matcher(n);
if (matcher.matches())
{
if (matcher.group(3)!=null)
{
System.err.printf("Module %s already disabled in %s as %s%n",module,hb.toShortForm(file.getParent()),n);
found = true;
}
else
{
String disabled=matcher.group(1)+disable;
System.err.printf("Disabling Module %s in %s as %s%n",module,hb.toShortForm(file.getParent()),disabled);
file.renameTo(new File(file.getParentFile(),disabled));
found = true;
}
}
}
}
}

View File

@ -108,7 +108,7 @@ public class MainTest
assertThat("CommandLineBuilder shouldn't be null",cmd,notNullValue());
List<String> commandArgs = cmd.getArgs();
assertThat("commandArgs should contain 11 elements",commandArgs.size(),equalTo(11));
assertThat("commandArgs elements",commandArgs.size(),equalTo(12));
assertThat("args does not contain -cp",commandArgs,hasItems("-cp"));
assertThat("Classpath should be correctly quoted and match expected value",commandArgs,
hasItems("/jetty/home with spaces/somejar.jar:/jetty/home with spaces/someotherjar.jar"));