Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Bartel2015-11-01 20:35:02 -0500
committerJan Bartel2015-11-01 20:35:02 -0500
commita022c77dabd4165fc5797aaf76b2c3755d363950 (patch)
tree98108537beeca8681717081cf4181c82f0143528
parent303f98e38cf1520674333c5a06f0b7e1e7ca98ef (diff)
downloadorg.eclipse.jetty.project-a022c77dabd4165fc5797aaf76b2c3755d363950.tar.gz
org.eclipse.jetty.project-a022c77dabd4165fc5797aaf76b2c3755d363950.tar.xz
org.eclipse.jetty.project-a022c77dabd4165fc5797aaf76b2c3755d363950.zip
481203 Add ability to set configurations to apply to WebAppContext for jetty-maven-plugin
-rw-r--r--jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/AbstractJettyMojo.java3
-rw-r--r--jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunForkedMojo.java2
-rw-r--r--jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyWebAppContext.java65
-rw-r--r--jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/ServerSupport.java8
-rw-r--r--jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/Starter.java5
5 files changed, 55 insertions, 28 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 402ad48243..caa79c57a9 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
@@ -443,6 +443,9 @@ public abstract class AbstractJettyMojo extends AbstractMojo
//set up a RequestLog if one is provided and the handle structure
ServerSupport.configureHandlers(server, this.requestLog);
+
+ //Set up list of default Configurations to apply to a webapp
+ ServerSupport.configureDefaultConfigurationClasses(server);
configureWebApplication();
ServerSupport.addWebApplication(server, webApp);
diff --git a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunForkedMojo.java b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunForkedMojo.java
index d4ac65e2ac..22cf2f21dc 100644
--- a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunForkedMojo.java
+++ b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunForkedMojo.java
@@ -244,6 +244,8 @@ public class JettyRunForkedMojo extends JettyRunMojo
//ensure handler structure enabled
ServerSupport.configureHandlers(server, null);
+
+ ServerSupport.configureDefaultConfigurationClasses(server);
//ensure config of the webapp based on settings in plugin
configureWebApplication();
diff --git a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyWebAppContext.java b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyWebAppContext.java
index 8f1f343584..0a2dd8cc3b 100644
--- a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyWebAppContext.java
+++ b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyWebAppContext.java
@@ -72,23 +72,25 @@ public class JettyWebAppContext extends WebAppContext
private static final String DEFAULT_CONTAINER_INCLUDE_JAR_PATTERN = ".*/javax.servlet-[^/]*\\.jar$|.*/servlet-api-[^/]*\\.jar$|.*javax.servlet.jsp.jstl-[^/]*\\.jar|.*taglibs-standard-impl-.*\\.jar";
private static final String WEB_INF_CLASSES_PREFIX = "/WEB-INF/classes";
private static final String WEB_INF_LIB_PREFIX = "/WEB-INF/lib";
+
+
+ public static final String[] DEFAULT_CONFIGURATION_CLASSES = {
+ "org.eclipse.jetty.maven.plugin.MavenWebInfConfiguration",
+ "org.eclipse.jetty.webapp.WebXmlConfiguration",
+ "org.eclipse.jetty.webapp.MetaInfConfiguration",
+ "org.eclipse.jetty.webapp.FragmentConfiguration",
+ "org.eclipse.jetty.plus.webapp.EnvConfiguration",
+ "org.eclipse.jetty.plus.webapp.PlusConfiguration",
+ "org.eclipse.jetty.annotations.AnnotationConfiguration",
+ "org.eclipse.jetty.webapp.JettyWebXmlConfiguration"
+ };
- private final Configuration[] _defaultConfigurations = {
- new MavenWebInfConfiguration(),
- new WebXmlConfiguration(),
- new MetaInfConfiguration(),
- new FragmentConfiguration(),
- new EnvConfiguration(),
- new PlusConfiguration(),
- new AnnotationConfiguration(),
- new JettyWebXmlConfiguration()
- };
- private final Configuration[] _quickStartConfigurations = {
- new MavenQuickStartConfiguration(),
- new EnvConfiguration(),
- new PlusConfiguration(),
- new JettyWebXmlConfiguration()
+ private final String[] QUICKSTART_CONFIGURATION_CLASSES = {
+ "org.eclipse.jetty.maven.plugin.MavenQuickStartConfiguration",
+ "org.eclipse.jetty.plus.webapp.EnvConfiguration",
+ "org.eclipse.jetty.plus.webapp.PlusConfiguration",
+ "org.eclipse.jetty.webapp.JettyWebXmlConfiguration"
};
private File _classes = null;
@@ -100,6 +102,7 @@ public class JettyWebAppContext extends WebAppContext
private String _jettyEnvXml;
private List<Overlay> _overlays;
private Resource _quickStartWebXml;
+
@@ -338,25 +341,17 @@ public class JettyWebAppContext extends WebAppContext
{
//choose if this will be a quickstart or normal start
if (!isGenerateQuickStart() && getQuickStartWebDescriptor() != null)
- setConfigurations(_quickStartConfigurations);
- else
{
- setConfigurations(_defaultConfigurations);
+ setConfigurationClasses(QUICKSTART_CONFIGURATION_CLASSES);
+ }
+ else
+ {
if (isGenerateQuickStart())
{
_preconfigProcessor = new PreconfigureDescriptorProcessor();
getMetaData().addDescriptorProcessor(_preconfigProcessor);
}
}
-
- //inject configurations with config from maven plugin
- for (Configuration c:getConfigurations())
- {
- if (c instanceof EnvConfiguration && getJettyEnvXml() != null)
- ((EnvConfiguration)c).setJettyEnvXml(Resource.toURL(new File(getJettyEnvXml())));
- else if (c instanceof MavenQuickStartConfiguration && getQuickStartWebDescriptor() != null)
- ((MavenQuickStartConfiguration)c).setQuickStartWebXml(getQuickStartWebDescriptor());
- }
//Set up the pattern that tells us where the jars are that need scanning
@@ -404,6 +399,22 @@ public class JettyWebAppContext extends WebAppContext
}
+ @Override
+ protected void loadConfigurations() throws Exception
+ {
+ super.loadConfigurations();
+
+ //inject configurations with config from maven plugin
+ for (Configuration c:getConfigurations())
+ {
+ if (c instanceof EnvConfiguration && getJettyEnvXml() != null)
+ ((EnvConfiguration)c).setJettyEnvXml(Resource.toURL(new File(getJettyEnvXml())));
+ else if (c instanceof MavenQuickStartConfiguration && getQuickStartWebDescriptor() != null)
+ ((MavenQuickStartConfiguration)c).setQuickStartWebXml(getQuickStartWebDescriptor());
+ }
+ }
+
+
/* ------------------------------------------------------------ */
public void doStop () throws Exception
{
diff --git a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/ServerSupport.java b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/ServerSupport.java
index babfe6830a..407a17f2a9 100644
--- a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/ServerSupport.java
+++ b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/ServerSupport.java
@@ -35,6 +35,7 @@ import org.eclipse.jetty.server.handler.DefaultHandler;
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.Configuration;
import org.eclipse.jetty.webapp.WebAppContext;
import org.eclipse.jetty.xml.XmlConfiguration;
@@ -46,6 +47,13 @@ import org.eclipse.jetty.xml.XmlConfiguration;
*/
public class ServerSupport
{
+
+ public static void configureDefaultConfigurationClasses (Server server)
+ {
+ server.setAttribute(Configuration.ATTR, JettyWebAppContext.DEFAULT_CONFIGURATION_CLASSES);
+ }
+
+
/**
* Set up the handler structure to receive a webapp.
* Also put in a DefaultHandler so we get a nice page
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 0f9e361cbd..a5b94536ad 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
@@ -125,7 +125,10 @@ public class Starter
//check if contexts already configured, create if not
ServerSupport.configureHandlers(server, null);
-
+
+ //Set up list of default Configurations to apply to a webapp
+ ServerSupport.configureDefaultConfigurationClasses(server);
+
webApp = new JettyWebAppContext();
//configure webapp from properties file describing unassembled webapp

Back to the top