From 02dbb862056b956e390b02a047574fff07ba7c79 Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Sun, 20 Jan 2013 19:44:55 +0000 Subject: [PATCH] WW-3916 adds usage of the latest Jetty plugin git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/trunk@1435931 13f79535-47bb-0310-9956-ffa450edef68 --- apps/mailreader/pom.xml | 28 +++++++++++++- .../src/main/resources/log4j.properties | 36 ++++++++++++++++++ .../src/main/webapp/WEB-INF/database.xml | 16 +++----- apps/rest-showcase/pom.xml | 4 +- apps/showcase/pom.xml | 4 +- .../resources/archetype-resources/pom.xml | 34 +++++++++++++---- .../src/main/resources/log4j.properties | 29 ++++++++++++++ .../resources/archetype-resources/pom.xml | 33 ++++++++++++---- .../src/main/resources/log4j.properties | 29 ++++++++++++++ .../resources/archetype-resources/pom.xml | 38 ++++++++++++++----- .../struts2/dispatcher/DispatcherTest.java | 7 +--- .../xwork2/config/ConfigurationManager.java | 21 ++++++---- 12 files changed, 227 insertions(+), 52 deletions(-) create mode 100644 apps/mailreader/src/main/resources/log4j.properties create mode 100644 archetypes/struts2-archetype-blank/src/main/resources/archetype-resources/src/main/resources/log4j.properties create mode 100644 archetypes/struts2-archetype-convention/src/main/resources/archetype-resources/src/main/resources/log4j.properties diff --git a/apps/mailreader/pom.xml b/apps/mailreader/pom.xml index 888875dc9..04a0ff2e9 100644 --- a/apps/mailreader/pom.xml +++ b/apps/mailreader/pom.xml @@ -68,11 +68,35 @@ org.mortbay.jetty - maven-jetty-plugin - 6.0.1 + jetty-maven-plugin + 8.1.7.v20120910 + CTRL+C + 8999 + + + log4j.configuration + file:${basedir}/src/main/resources/log4j.properties + + + slf4j + false + + 10 + ${basedir}/src/main/webapp/ + + /struts2-mailreader + ${basedir}/src/main/webapp/WEB-INF/web.xml + + + + log4j + log4j + 1.2.16 + + diff --git a/apps/mailreader/src/main/resources/log4j.properties b/apps/mailreader/src/main/resources/log4j.properties new file mode 100644 index 000000000..7a86f1ef9 --- /dev/null +++ b/apps/mailreader/src/main/resources/log4j.properties @@ -0,0 +1,36 @@ +# +# Log4J Settings for log4j 1.2.x (via jakarta-commons-logging) +# +# The five logging levels used by Log are (in order): +# +# 1. DEBUG (the least serious) +# 2. INFO +# 3. WARN +# 4. ERROR +# 5. FATAL (the most serious) + + +# Set root logger level to WARN and append to stdout +log4j.rootLogger=DEBUG, stdout +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.Target=System.out +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout + +# Pattern to output the caller's file name and line number. +log4j.appender.stdout.layout.ConversionPattern=%d %5p (%c:%L) - %m%n + +# Print only messages of level ERROR or above in the package noModule. +log4j.logger.noModule=FATAL + +# OpenSymphony Stuff +log4j.logger.freemarker=INFO +log4j.logger.com.opensymphony=INFO +log4j.logger.com.opensymphony.xwork2.ognl=ERROR +log4j.logger.org.apache.struts2=WARN +log4j.logger.org.apache.struts2.components=WARN +log4j.logger.org.apache.struts2.dispatcher=WARN +log4j.logger.org.apache.struts2.convention=INFO + +# Spring Stuff +log4j.logger.org.springframework=WARN + diff --git a/apps/mailreader/src/main/webapp/WEB-INF/database.xml b/apps/mailreader/src/main/webapp/WEB-INF/database.xml index 0bc833dce..e54d9c56a 100644 --- a/apps/mailreader/src/main/webapp/WEB-INF/database.xml +++ b/apps/mailreader/src/main/webapp/WEB-INF/database.xml @@ -1,13 +1,9 @@ - - - - - - + + + + + + - \ No newline at end of file diff --git a/apps/rest-showcase/pom.xml b/apps/rest-showcase/pom.xml index 116d3cb3f..66576d5e9 100644 --- a/apps/rest-showcase/pom.xml +++ b/apps/rest-showcase/pom.xml @@ -101,8 +101,10 @@ org.mortbay.jetty jetty-maven-plugin - 8.0.0.M2 + 8.1.7.v20120910 + CTRL+C + 8999 log4j.configuration diff --git a/apps/showcase/pom.xml b/apps/showcase/pom.xml index 230e8fc34..6c50e10e7 100644 --- a/apps/showcase/pom.xml +++ b/apps/showcase/pom.xml @@ -204,8 +204,10 @@ org.mortbay.jetty jetty-maven-plugin - 8.0.0.M2 + 8.1.7.v20120910 + CTRL+C + 8999 log4j.configuration diff --git a/archetypes/struts2-archetype-blank/src/main/resources/archetype-resources/pom.xml b/archetypes/struts2-archetype-blank/src/main/resources/archetype-resources/pom.xml index 4d0b5b139..6087324f5 100644 --- a/archetypes/struts2-archetype-blank/src/main/resources/archetype-resources/pom.xml +++ b/archetypes/struts2-archetype-blank/src/main/resources/archetype-resources/pom.xml @@ -66,17 +66,35 @@ org.mortbay.jetty - maven-jetty-plugin - 6.1.21 + jetty-maven-plugin + 8.1.7.v20120910 + CTRL+C + 8999 + + + log4j.configuration + file:${basedir}/src/main/resources/log4j.properties + + + slf4j + false + + 10 - - src/main/webapp/WEB-INF - src/main/webapp/WEB-INF/web.xml - src/main/resources/struts.xml - src/main/resources/example.xml - + ${basedir}/src/main/webapp/ + + /struts2-blank + ${basedir}/src/main/webapp/WEB-INF/web.xml + + + + log4j + log4j + 1.2.16 + + diff --git a/archetypes/struts2-archetype-blank/src/main/resources/archetype-resources/src/main/resources/log4j.properties b/archetypes/struts2-archetype-blank/src/main/resources/archetype-resources/src/main/resources/log4j.properties new file mode 100644 index 000000000..a29a304b3 --- /dev/null +++ b/archetypes/struts2-archetype-blank/src/main/resources/archetype-resources/src/main/resources/log4j.properties @@ -0,0 +1,29 @@ +# +# Log4J Settings for log4j 1.2.x (via jakarta-commons-logging) +# +# The five logging levels used by Log are (in order): +# +# 1. DEBUG (the least serious) +# 2. INFO +# 3. WARN +# 4. ERROR +# 5. FATAL (the most serious) + + +# Set root logger level to WARN and append to stdout +log4j.rootLogger=WARN, stdout + +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout + +# Pattern to output the caller's file name and line number. +log4j.appender.stdout.layout.ConversionPattern=%d %5p (%c:%L) - %m%n + +# Print only messages of level ERROR or above in the package noModule. +log4j.logger.noModule=ERROR + +# OpenSymphony Stuff +log4j.logger.com.opensymphony=INFO + +# Struts2 Stuff +log4j.logger.org.apache.struts2=INFO diff --git a/archetypes/struts2-archetype-convention/src/main/resources/archetype-resources/pom.xml b/archetypes/struts2-archetype-convention/src/main/resources/archetype-resources/pom.xml index 51067e927..1e640aa41 100644 --- a/archetypes/struts2-archetype-convention/src/main/resources/archetype-resources/pom.xml +++ b/archetypes/struts2-archetype-convention/src/main/resources/archetype-resources/pom.xml @@ -80,16 +80,35 @@ org.mortbay.jetty - maven-jetty-plugin - 6.1.21 + jetty-maven-plugin + 8.1.7.v20120910 + CTRL+C + 8999 + + + log4j.configuration + file:${basedir}/src/main/resources/log4j.properties + + + slf4j + false + + 10 - - src/main/webapp/WEB-INF - src/main/webapp/WEB-INF/web.xml - src/main/resources/struts.xml - + ${basedir}/src/main/webapp/ + + /struts2-showcase + ${basedir}/src/main/webapp/WEB-INF/web.xml + + + + log4j + log4j + 1.2.16 + + diff --git a/archetypes/struts2-archetype-convention/src/main/resources/archetype-resources/src/main/resources/log4j.properties b/archetypes/struts2-archetype-convention/src/main/resources/archetype-resources/src/main/resources/log4j.properties new file mode 100644 index 000000000..a29a304b3 --- /dev/null +++ b/archetypes/struts2-archetype-convention/src/main/resources/archetype-resources/src/main/resources/log4j.properties @@ -0,0 +1,29 @@ +# +# Log4J Settings for log4j 1.2.x (via jakarta-commons-logging) +# +# The five logging levels used by Log are (in order): +# +# 1. DEBUG (the least serious) +# 2. INFO +# 3. WARN +# 4. ERROR +# 5. FATAL (the most serious) + + +# Set root logger level to WARN and append to stdout +log4j.rootLogger=WARN, stdout + +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout + +# Pattern to output the caller's file name and line number. +log4j.appender.stdout.layout.ConversionPattern=%d %5p (%c:%L) - %m%n + +# Print only messages of level ERROR or above in the package noModule. +log4j.logger.noModule=ERROR + +# OpenSymphony Stuff +log4j.logger.com.opensymphony=INFO + +# Struts2 Stuff +log4j.logger.org.apache.struts2=INFO diff --git a/archetypes/struts2-archetype-starter/src/main/resources/archetype-resources/pom.xml b/archetypes/struts2-archetype-starter/src/main/resources/archetype-resources/pom.xml index 8cf3756ae..89470df5e 100644 --- a/archetypes/struts2-archetype-starter/src/main/resources/archetype-resources/pom.xml +++ b/archetypes/struts2-archetype-starter/src/main/resources/archetype-resources/pom.xml @@ -88,19 +88,37 @@ - org.mortbay.jetty - maven-jetty-plugin - 6.1.21 + org.mortbay.jetty + jetty-maven-plugin + 8.1.7.v20120910 + CTRL+C + 8999 + + + log4j.configuration + file:${basedir}/src/main/resources/log4j.properties + + + slf4j + false + + 10 - - src/main/webapp/WEB-INF - src/main/webapp/WEB-INF/web.xml - src/main/resources/struts.xml - src/main/resources/applicationContext.xml - + ${basedir}/src/main/webapp/ + + /struts2-showcase + ${basedir}/src/main/webapp/WEB-INF/web.xml + - + + + log4j + log4j + 1.2.16 + + + diff --git a/core/src/test/java/org/apache/struts2/dispatcher/DispatcherTest.java b/core/src/test/java/org/apache/struts2/dispatcher/DispatcherTest.java index b1b132033..59be11cf2 100644 --- a/core/src/test/java/org/apache/struts2/dispatcher/DispatcherTest.java +++ b/core/src/test/java/org/apache/struts2/dispatcher/DispatcherTest.java @@ -197,10 +197,7 @@ public class DispatcherTest extends StrutsTestCase { mockContainer.expectAndReturn("getInstance", C.args(C.eq(String.class), C.eq(XWorkConstants.RELOAD_XML_CONFIGURATION)), reloadConfigs); mockContainer.expectAndReturn("getInstance", C.args(C.eq(ObjectFactory.class)), destroyedObjectFactory); - mockContainer.expectAndReturn("getInstance", C.args(C.eq(String.class), C.eq(XWorkConstants.RELOAD_XML_CONFIGURATION)), - reloadConfigs); - mockConfiguration.expectAndReturn("getContainer", mockContainer.proxy()); mockConfiguration.expectAndReturn("getContainer", mockContainer.proxy()); mockConfiguration.expectAndReturn("getContainer", mockContainer.proxy()); mockConfiguration.expect("destroy"); @@ -227,14 +224,12 @@ public class DispatcherTest extends StrutsTestCase { Map packageConfigs = new HashMap(); packageConfigs.put("test", packageConfig); - + Mock mockContainer = new Mock(Container.class); mockContainer.matchAndReturn("getInstance", C.args(C.eq(ObjectFactory.class)), new ObjectFactory()); String reloadConfigs = container.getInstance(String.class, XWorkConstants.RELOAD_XML_CONFIGURATION); mockContainer.expectAndReturn("getInstance", C.args(C.eq(String.class), C.eq(XWorkConstants.RELOAD_XML_CONFIGURATION)), reloadConfigs); - mockContainer.expectAndReturn("getInstance", C.args(C.eq(String.class), C.eq(XWorkConstants.RELOAD_XML_CONFIGURATION)), - reloadConfigs); Mock mockConfiguration = new Mock(Configuration.class); mockConfiguration.matchAndReturn("getPackageConfigs", packageConfigs); diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/config/ConfigurationManager.java b/xwork-core/src/main/java/com/opensymphony/xwork2/config/ConfigurationManager.java index 9a1b82628..042fda4b6 100644 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/config/ConfigurationManager.java +++ b/xwork-core/src/main/java/com/opensymphony/xwork2/config/ConfigurationManager.java @@ -19,7 +19,6 @@ import com.opensymphony.xwork2.XWorkConstants; import com.opensymphony.xwork2.config.impl.DefaultConfiguration; import com.opensymphony.xwork2.config.providers.XWorkConfigurationProvider; import com.opensymphony.xwork2.config.providers.XmlConfigurationProvider; -import com.opensymphony.xwork2.inject.Container; import com.opensymphony.xwork2.util.logging.Logger; import com.opensymphony.xwork2.util.logging.LoggerFactory; @@ -46,6 +45,7 @@ public class ConfigurationManager { private List packageProviders = new CopyOnWriteArrayList(); protected String defaultFrameworkBeanName; private boolean providersChanged = false; + private boolean reloadConfigs = true; // for the first time public ConfigurationManager() { this("xwork"); @@ -70,7 +70,7 @@ public class ConfigurationManager { throw new ConfigurationException("Unable to load configuration.", e); } } else { - conditionalReload(configuration.getContainer()); + conditionalReload(); } return configuration; @@ -169,10 +169,8 @@ public class ConfigurationManager { /** * Reloads the Configuration files if the configuration files indicate that they need to be reloaded. - * @param container current container used to obtain instance of {@link com.opensymphony.xwork2.util.fs.DefaultFileManager} */ - public synchronized void conditionalReload(Container container) { - boolean reloadConfigs = Boolean.parseBoolean(container.getInstance(String.class, XWorkConstants.RELOAD_XML_CONFIGURATION)); + public synchronized void conditionalReload() { if (reloadConfigs || providersChanged) { if (LOG.isDebugEnabled()) { LOG.debug("Checking ConfigurationProviders for reload."); @@ -185,16 +183,25 @@ public class ConfigurationManager { if (reload) { reloadProviders(providers); } + updateReloadConfigsFlag(); providersChanged = false; } } + private void updateReloadConfigsFlag() { + reloadConfigs = Boolean.parseBoolean(configuration.getContainer().getInstance(String.class, XWorkConstants.RELOAD_XML_CONFIGURATION)); + if (LOG.isDebugEnabled()) { + LOG.debug("Updating [#0], current value is [#1], new value [#2]", + XWorkConstants.RELOAD_XML_CONFIGURATION, String.valueOf(reloadConfigs), String.valueOf(reloadConfigs)); + } + } + private boolean needReloadPackageProviders() { if (packageProviders != null) { for (PackageProvider provider : packageProviders) { if (provider.needsReload()) { if (LOG.isInfoEnabled()) { - LOG.info("Detected package provider " + provider + " needs to be reloaded. Reloading all providers."); + LOG.info("Detected package provider [#0] needs to be reloaded. Reloading all providers.", provider.toString()); } return true; } @@ -207,7 +214,7 @@ public class ConfigurationManager { for (ContainerProvider provider : providers) { if (provider.needsReload()) { if (LOG.isInfoEnabled()) { - LOG.info("Detected container provider " + provider + " needs to be reloaded. Reloading all providers."); + LOG.info("Detected container provider [#0] needs to be reloaded. Reloading all providers.", provider.toString()); } return true; }