diff --git a/jetty-distribution/src/main/resources/start.ini b/jetty-distribution/src/main/resources/start.ini index 4d01c119001..94f1ac626a5 100644 --- a/jetty-distribution/src/main/resources/start.ini +++ b/jetty-distribution/src/main/resources/start.ini @@ -12,12 +12,11 @@ # Each line in this file is prepended to the command line # as arguments, which may be either: # + A property like: name=value -# + A file of properties like: /etc/myjetty.properties -# + A classpath option like: OPTION=jmx +# + A module to enable like: --module=jmx # + An XML configuration file like: etc/jetty-feature.xml # + A start.jar option like: --dry-run # -# If --exec or --exec-print are used, then this file may also +# If --exec or --dry-run are used, then this file may also # contain lines with: # + A JVM option like: -Xmx2000m # + A System Property like: -Dcom.sun.management.jmxremote @@ -27,14 +26,11 @@ # NOTE: The lines in this file may be uncommented to activate # features. Alternately, the lines may be copied to a ini file # in the start.d directory to enabled configuration without -# editing this file. See start.d/900-demo.ini for an example. +# editing this file. See start.d/demo.ini for an example. # -# Future releases will switch start.d style configuration for -# all features. #=========================================================== - #=========================================================== # Configure JVM arguments. # If JVM args are include in an ini file then --exec is needed @@ -59,7 +55,6 @@ # -XX:+DisableExplicitGC # -Dorg.apache.jasper.compiler.disablejsr199=true - #=========================================================== # Default Server Options # Use the core server jars with websocket on the classpath @@ -79,22 +74,15 @@ jetty.dump.stop=false # To enable remote JMX access uncomment jmxremote and # enable --exec #----------------------------------------------------------- ---module=jmx # jetty.jmxrmihost=localhost # jetty.jmxrmiport=1099 # -Dcom.sun.management.jmxremote -#=========================================================== -# Java Server Pages -#----------------------------------------------------------- ---module=jsp - #=========================================================== # Request logger # Will add a handler to log all HTTP requests to a standard # request log format file. #----------------------------------------------------------- -# --module=requestlog # requestlog.retain=90 # requestlog.append=true # requestlog.extended=true @@ -105,7 +93,6 @@ jetty.dump.stop=false # The following configuration will redirect stderr and stdout # to file which is rolled over daily. #----------------------------------------------------------- -# --module=logging # jetty.log.retain=90 #=========================================================== @@ -113,17 +100,14 @@ jetty.dump.stop=false # The default user and group is 'jetty' and if you are # starting as root you must change the run privledged to true #----------------------------------------------------------- -# --module=setuid # jetty.startServerAsPrivileged=false # jetty.username=jetty # jetty.groupname=jetty # jetty.umask=002 - #=========================================================== # HTTP Connector #----------------------------------------------------------- ---module=http jetty.port=8080 http.timeout=30000 @@ -143,72 +127,22 @@ http.timeout=30000 #=========================================================== # HTTPS Connector -# Must be used with jetty-ssl.xml #----------------------------------------------------------- ---module=https # jetty.https.port=8443 - -#=========================================================== -# NPN Next Protocol Negotiation -# -# The SPDY and HTTP/2.0 connectors require NPN. The jar for -# NPN cannot be downloaded from eclipse. So the --download -# option is used to install the NPN jar if it does not already -# exist -# -#----------------------------------------------------------- -# --exec -# --download=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 -# -Xbootclasspath/p:lib/npn/npn-boot-1.1.5.v20130313.jar - - #=========================================================== # SPDY Connector -# Requires SSL Context and NPN from above #----------------------------------------------------------- -# --module=spdy # jetty.spdy.port=8443 - -#=========================================================== -# Webapplication Deployer -#----------------------------------------------------------- ---module=deploy - # =========================================================== -# Enable JAAS +# JAAS # ----------------------------------------------------------- -# --module=jaas # jaas.login.conf=etc/login.conf -# =========================================================== -# Enable JNDI -# ----------------------------------------------------------- -# --module=jndi - -# =========================================================== -# Enable additional webapp environment configurators -# ----------------------------------------------------------- -# --module=plus - -# =========================================================== -# Enable servlet 3.1 annotations -# ----------------------------------------------------------- -# --module=annotations - -#=========================================================== -# Other server features -#----------------------------------------------------------- -# --module=debug -# --module=ipaccess -# --module=stats - - #=========================================================== # Low resource managment #----------------------------------------------------------- -# --module=lowresources # lowresources.period=1050 # lowresources.lowResourcesIdleTimeout=200 # lowresources.monitorThreads=true @@ -216,5 +150,3 @@ http.timeout=30000 # lowresources.maxMemory=0 # lowresources.maxLowResourcesTime=5000 ---module=webapp - diff --git a/jetty-start/src/main/java/org/eclipse/jetty/start/ModulePersistence.java b/jetty-start/src/main/java/org/eclipse/jetty/start/ModulePersistence.java index cee63494024..0fe072051ce 100644 --- a/jetty-start/src/main/java/org/eclipse/jetty/start/ModulePersistence.java +++ b/jetty-start/src/main/java/org/eclipse/jetty/start/ModulePersistence.java @@ -39,7 +39,13 @@ public class ModulePersistence extends TextFile public boolean disableModule(StartArgs args, String moduleName) throws IOException { + // capture of what modules were disabled by this action List modulesThatWereDisabled = new ArrayList<>(); + // capture of what modules were automatically enabled by this action + // this list can occur if you attempt to disable a leaf node, the parent nodes + // of that leaf would then become enabled + List modulesThatWereEnabled = new ArrayList<>(); + // set of child modules that should be disabled by this action Set resolvedModulesToDisable = args.getAllModules().resolveChildModulesOf(moduleName); // Show user what could be disabled @@ -61,6 +67,28 @@ public class ModulePersistence extends TextFile } // Do the disabling + + // Step 1: set parent modules to enabled. + // This is to handle the case where the leaf is disabled, you still + // want the branch itself to be active upto the step before that leaf + Modules modules = args.getAllModules(); + Module leaf = modules.get(moduleName); + // no children, this is a leaf + if (leaf.getChildEdges().size() <= 0) + { + // mark all parents as enabled + List sources = new ArrayList<>(); + sources.add(""); + for (Module parent : leaf.getParentEdges()) + { + parent.setEnabled(true); + parent.addSources(sources); + addUniqueLine(parent.getName()); + modulesThatWereEnabled.add(parent.getName()); + } + } + + // Step 2: mark the leaf nodes disabled ListIterator iter = super.listIterator(); while (iter.hasNext()) { @@ -85,9 +113,14 @@ public class ModulePersistence extends TextFile } return true; } + else if (modulesThatWereEnabled.size() > 0) + { + System.out.printf("Module %s was has been effectively disabled.%n",moduleName); + return true; + } else { - System.out.printf("Module %s not found, nothing actually disabled.%n",moduleName); + System.out.printf("Module %s not found, no changes made to module persistence.%n",moduleName); return false; } } @@ -137,7 +170,7 @@ public class ModulePersistence extends TextFile File file = getFile(); File parent = file.getParentFile(); FS.ensureDirectoryExists(parent); - + try (FileWriter writer = new FileWriter(file,false)) { for (String line : getLines()) diff --git a/jetty-start/src/main/java/org/eclipse/jetty/start/Modules.java b/jetty-start/src/main/java/org/eclipse/jetty/start/Modules.java index 90313e77f93..7f0ae9c5d36 100644 --- a/jetty-start/src/main/java/org/eclipse/jetty/start/Modules.java +++ b/jetty-start/src/main/java/org/eclipse/jetty/start/Modules.java @@ -228,11 +228,11 @@ public class Modules implements Iterable err.append("The following "); if (enabled.size() > 1) { - err.append(enabled.size()).append(" modules"); + err.append(enabled.size()).append("modules"); } else { - err.append(" module"); + err.append("module"); } err.append(", defined outside of the module persistence mechanism, "); if (enabled.size() > 1) diff --git a/jetty-start/src/test/java/org/eclipse/jetty/start/ModulePersistenceTest.java b/jetty-start/src/test/java/org/eclipse/jetty/start/ModulePersistenceTest.java index 3b0d28041e5..1d32f93df19 100644 --- a/jetty-start/src/test/java/org/eclipse/jetty/start/ModulePersistenceTest.java +++ b/jetty-start/src/test/java/org/eclipse/jetty/start/ModulePersistenceTest.java @@ -99,7 +99,7 @@ public class ModulePersistenceTest // Load persistence file again persistence = new ModulePersistence(mfile); - Assert.assertThat("persistence.enabled",persistence.getEnabled(),containsInAnyOrder("websocket")); + Assert.assertThat("persistence.enabled",persistence.getEnabled(),containsInAnyOrder("server","websocket")); } @Test diff --git a/jetty-start/src/test/resources/usecases/home/modules/demo.mod b/jetty-start/src/test/resources/usecases/home/modules/demo.mod index 1ee750bfa6d..af06453d839 100644 --- a/jetty-start/src/test/resources/usecases/home/modules/demo.mod +++ b/jetty-start/src/test/resources/usecases/home/modules/demo.mod @@ -8,6 +8,7 @@ DEPEND=rewrite DEPEND=client DEPEND=annotations DEPEND=websocket +DEPEND=webapp LIB=demo/lib/*.jar diff --git a/tests/test-webapps/test-jetty-webapp/src/main/config/modules/demo.mod b/tests/test-webapps/test-jetty-webapp/src/main/config/modules/demo.mod index 1ee750bfa6d..77dfd0be12f 100644 --- a/tests/test-webapps/test-jetty-webapp/src/main/config/modules/demo.mod +++ b/tests/test-webapps/test-jetty-webapp/src/main/config/modules/demo.mod @@ -8,6 +8,7 @@ DEPEND=rewrite DEPEND=client DEPEND=annotations DEPEND=websocket +DEPEND=deploy LIB=demo/lib/*.jar