diff --git a/jetty-distribution/src/main/resources/start.d/README.TXT b/jetty-distribution/src/main/resources/start.d/README.TXT new file mode 100644 index 00000000000..28e2492913e --- /dev/null +++ b/jetty-distribution/src/main/resources/start.d/README.TXT @@ -0,0 +1,26 @@ + +This start.d directory contains modular ini files that are appended to the effective command line +used to start jetty by the command: + + java -jar start.jar + + +The modules are executed in alphabetic order and the 'NNN-' prefixes are a convention to make that ordering +explicit regardless of module name. + +All modules ending with '.ini' will be executed and it is a convention that disabled modules are renamed to +end with '.ini.disabled'. The start.jar mechanism can be used to enable/disable modules with commands like: + + java -jar start.jar --enable=ssl --enable=spdy + +Note that the numeric prefix can be skipped in such commands. + + +The ini modules have a simple dependency mechanism so a module can declare if it depends on or conflicts with +other modules. For example the spdy module includes the entries: + + EXCLUDE=https + DEPEND=npn,ssl + +This says that spdy cannot be used with the https module (both use the same port and spdy provides https) and +that the npn and ssl modules must also be enabled. diff --git a/jetty-distribution/src/main/resources/webapps.demo/README.TXT b/jetty-distribution/src/main/resources/webapps.demo/README.TXT index ec2bea255cb..d6fb93b8996 100644 --- a/jetty-distribution/src/main/resources/webapps.demo/README.TXT +++ b/jetty-distribution/src/main/resources/webapps.demo/README.TXT @@ -3,5 +3,10 @@ This directory is scanned by the demo WebAppDeployer provider created in the etc/jetty-demo.xml file and enabled by the start.d/900-demo.ini file. -For normal deployment, use the webapps directory. +To disable the demo, either remove the start.d/900-demo.ini or issue the following command: + + java -jar start.jar --disable=demo + + +For normal webapp deployment, use the webapps directory. diff --git a/jetty-distribution/src/main/resources/webapps/README.TXT b/jetty-distribution/src/main/resources/webapps/README.TXT index dc2b38915e3..170137a0ec4 100644 --- a/jetty-distribution/src/main/resources/webapps/README.TXT +++ b/jetty-distribution/src/main/resources/webapps/README.TXT @@ -23,3 +23,11 @@ only the XML is deployed (which may use the war in its configuration). This directory is scanned for additions, removals and updates for hot deployment. +To configure the deployment mechanism, edit the files: + start.d/500-deploy.ini + etc/jetty-deploy.ini + +To disable the auto deploy mechanism use the command: + + java -jar start.jar --disable=deploy + diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpOutput.java b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpOutput.java index 4d87aa01b8c..2c7254ce1a9 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpOutput.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpOutput.java @@ -57,6 +57,7 @@ public class HttpOutput extends ServletOutputStream implements Runnable private long _written; private ByteBuffer _aggregate; private int _bufferSize; + private int _commitSize; private WriteListener _writeListener; private volatile Throwable _onError; @@ -79,6 +80,7 @@ write completed - - - ASYNC READY->owp { _channel = channel; _bufferSize = _channel.getHttpConfiguration().getOutputBufferSize(); + _commitSize=_bufferSize/4; } public boolean isWritten() @@ -231,7 +233,7 @@ write completed - - - ASYNC READY->owp // Should we aggregate? int capacity = getBufferSize(); - if (!complete && len<=capacity/4) + if (!complete && len<=_commitSize) { if (_aggregate == null) _aggregate = _channel.getByteBufferPool().acquire(capacity, false); @@ -271,7 +273,7 @@ write completed - - - ASYNC READY->owp // Should we aggregate? int capacity = getBufferSize(); - if (!complete && len<=capacity/4) + if (!complete && len<=_commitSize) { if (_aggregate == null) _aggregate = _channel.getByteBufferPool().acquire(capacity, false); @@ -294,7 +296,7 @@ write completed - - - ASYNC READY->owp _channel.write(_aggregate, complete && len==0); // should we fill aggregate again from the buffer? - if (len>0 && !complete && len<=_aggregate.capacity()/4) + if (len>0 && !complete && len<=_commitSize) { BufferUtil.append(_aggregate, b, off, len); return; @@ -596,7 +598,8 @@ write completed - - - ASYNC READY->owp public void setBufferSize(int size) { - this._bufferSize = size; + _bufferSize = size; + _commitSize = size; } public void resetBuffer() @@ -704,12 +707,10 @@ write completed - - - ASYNC READY->owp return false; } - // TODO write comments - if (!_complete && _len0 && !_flushed) { _flushed=true; diff --git a/jetty-start/src/main/java/org/eclipse/jetty/start/Config.java b/jetty-start/src/main/java/org/eclipse/jetty/start/Config.java index e7ecc9497a0..1af85edaa97 100644 --- a/jetty-start/src/main/java/org/eclipse/jetty/start/Config.java +++ b/jetty-start/src/main/java/org/eclipse/jetty/start/Config.java @@ -162,7 +162,7 @@ public class Config { ver = "Unknown"; } - _version = ver; + __version = ver; } /** @@ -170,8 +170,10 @@ public class Config */ private final Comparator keySorter = new NaturalSort.Strings(); - private static final String _version; + private static final String __version; private static boolean DEBUG = false; + private static Config __instance; + private final HomeBase _homebase; private final Map _properties = new HashMap(); private final Map _classpaths = new HashMap(); @@ -199,6 +201,7 @@ public class Config public Config() { + __instance=this; _homebase = new HomeBase(); setProperty("jetty.home",_homebase.getHome()); setProperty("jetty.base",_homebase.getBase()); @@ -408,7 +411,8 @@ public class Config _properties.clear(); } - public Properties getProperties() + /* This method is static so it can be accessed by XmlConfiguration */ + public static Properties getProperties() { Properties properties = new Properties(); // Add System Properties First @@ -418,8 +422,8 @@ public class Config properties.put(name, System.getProperty(name)); } // Add Config Properties Next (overwriting any System Properties that exist) - for (String key : _properties.keySet()) { - properties.put(key,_properties.get(key)); + for (String key : __instance._properties.keySet()) { + properties.put(key,__instance._properties.get(key)); } return properties; } @@ -427,7 +431,7 @@ public class Config public String getProperty(String name) { if ("version".equalsIgnoreCase(name)) { - return _version; + return __version; } // Search Config Properties First if (_properties.containsKey(name)) { diff --git a/jetty-start/src/main/java/org/eclipse/jetty/start/HomeBase.java b/jetty-start/src/main/java/org/eclipse/jetty/start/HomeBase.java index b225f2832b4..383a42a54cc 100644 --- a/jetty-start/src/main/java/org/eclipse/jetty/start/HomeBase.java +++ b/jetty-start/src/main/java/org/eclipse/jetty/start/HomeBase.java @@ -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() 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 beefe4ae4c5..afc6231739c 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 @@ -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; @@ -130,7 +133,7 @@ public class Main implements IncludeListener } if (!ini) { - arguments.add("--ini=start.ini"); + arguments.add(0,"--ini=start.ini"); } // The XML Configuration Files to initialize with @@ -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; + } + } + } } } diff --git a/jetty-start/src/test/java/org/eclipse/jetty/start/MainTest.java b/jetty-start/src/test/java/org/eclipse/jetty/start/MainTest.java index 6d643258d34..c7a277e1912 100644 --- a/jetty-start/src/test/java/org/eclipse/jetty/start/MainTest.java +++ b/jetty-start/src/test/java/org/eclipse/jetty/start/MainTest.java @@ -108,7 +108,7 @@ public class MainTest assertThat("CommandLineBuilder shouldn't be null",cmd,notNullValue()); List 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"));