diff options
author | Jan Bartel | 2014-06-16 16:31:14 +0000 |
---|---|---|
committer | Jan Bartel | 2014-06-16 16:31:14 +0000 |
commit | 723640edbde60ad9d26c83bc6d311df0e467e5a2 (patch) | |
tree | 2565a480c440b6c921b45bb0cc46086b4b5c9dc3 /jetty-maven-plugin/src | |
parent | 4896672c94da16f39dce67b4c42dbb84ff95d10b (diff) | |
download | org.eclipse.jetty.project-723640edbde60ad9d26c83bc6d311df0e467e5a2.tar.gz org.eclipse.jetty.project-723640edbde60ad9d26c83bc6d311df0e467e5a2.tar.xz org.eclipse.jetty.project-723640edbde60ad9d26c83bc6d311df0e467e5a2.zip |
437430 jettyXml not consistent between jetty:run and jetty:run-forked
Diffstat (limited to 'jetty-maven-plugin/src')
3 files changed, 53 insertions, 30 deletions
diff --git a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/AbstractJettyMojo.java b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/AbstractJettyMojo.java index 5c98d231d6..e9e979f50a 100644 --- a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/AbstractJettyMojo.java +++ b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/AbstractJettyMojo.java @@ -27,6 +27,7 @@ import java.net.URL; import java.net.URLClassLoader; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.Enumeration; import java.util.Iterator; import java.util.List; @@ -449,7 +450,7 @@ public abstract class AbstractJettyMojo extends AbstractMojo - + /** * @throws Exception */ @@ -458,28 +459,7 @@ public abstract class AbstractJettyMojo extends AbstractMojo if (getJettyXmlFiles() == null) return; - XmlConfiguration last = null; - for ( File xmlFile : getJettyXmlFiles() ) - { - getLog().info( "Configuring Jetty from xml configuration file = " + xmlFile.getCanonicalPath() ); - XmlConfiguration xmlConfiguration = new XmlConfiguration(Resource.toURL(xmlFile)); - - //chain ids from one config file to another - if (last == null) - xmlConfiguration.getIdMap().put("Server", this.server); - else - xmlConfiguration.getIdMap().putAll(last.getIdMap()); - - //Set the system properties each time in case the config file set a new one - Enumeration<?> ensysprop = System.getProperties().propertyNames(); - while (ensysprop.hasMoreElements()) - { - String name = (String)ensysprop.nextElement(); - xmlConfiguration.getProperties().put(name,System.getProperty(name)); - } - last = xmlConfiguration; - xmlConfiguration.configure(); - } + this.server.applyXmlConfigurations(getJettyXmlFiles()); } diff --git a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyServer.java b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyServer.java index de5da154e1..3e60e1008b 100644 --- a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyServer.java +++ b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyServer.java @@ -19,6 +19,12 @@ package org.eclipse.jetty.maven.plugin; +import java.io.File; +import java.util.Collections; +import java.util.Enumeration; +import java.util.List; +import java.util.Map; + import org.eclipse.jetty.server.Handler; import org.eclipse.jetty.server.RequestLog; import org.eclipse.jetty.server.handler.ContextHandlerCollection; @@ -27,6 +33,8 @@ import org.eclipse.jetty.server.handler.HandlerCollection; import org.eclipse.jetty.server.handler.RequestLogHandler; import org.eclipse.jetty.util.resource.Resource; import org.eclipse.jetty.webapp.WebAppContext; +import org.eclipse.jetty.xml.XmlConfiguration; + /** * JettyServer @@ -109,4 +117,43 @@ public class JettyServer extends org.eclipse.jetty.server.Server } } } + + /** + * Apply xml files to server startup, passing in ourselves as the + * "Server" instance. + * + * @param files + * @throws Exception + */ + public void applyXmlConfigurations (List<File> files) + throws Exception + { + if (files == null || files.isEmpty()) + return; + + Map<String,Object> lastMap = Collections.singletonMap("Server", (Object)this); + + for ( File xmlFile : files ) + { + if (PluginLog.getLog() != null) + PluginLog.getLog().info( "Configuring Jetty from xml configuration file = " + xmlFile.getCanonicalPath() ); + + + XmlConfiguration xmlConfiguration = new XmlConfiguration(Resource.toURL(xmlFile)); + + //chain ids from one config file to another + if (lastMap != null) + xmlConfiguration.getIdMap().putAll(lastMap); + + //Set the system properties each time in case the config file set a new one + Enumeration<?> ensysprop = System.getProperties().propertyNames(); + while (ensysprop.hasMoreElements()) + { + String name = (String)ensysprop.nextElement(); + xmlConfiguration.getProperties().put(name,System.getProperty(name)); + } + xmlConfiguration.configure(); + lastMap = xmlConfiguration.getIdMap(); + } + } } diff --git a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/Starter.java b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/Starter.java index b9604709d6..d16b89d842 100644 --- a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/Starter.java +++ b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/Starter.java @@ -23,6 +23,7 @@ import java.io.FileInputStream; import java.io.InputStream; import java.net.URL; import java.util.ArrayList; +import java.util.Collections; import java.util.Enumeration; import java.util.HashSet; import java.util.Iterator; @@ -415,19 +416,14 @@ public class Starter /** + * Apply any jetty xml files given * @throws Exception */ public void applyJettyXml() throws Exception { if (jettyXmls == null) return; - - for ( File xmlFile : jettyXmls ) - { - LOG.info( "Configuring Jetty from xml configuration file = " + xmlFile.getCanonicalPath() ); - XmlConfiguration xmlConfiguration = new XmlConfiguration(Resource.toURL(xmlFile)); - xmlConfiguration.configure(this.server); - } + this.server.applyXmlConfigurations(jettyXmls); } |