Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse McConnell2011-05-18 16:01:09 -0400
committerJesse McConnell2011-05-18 16:01:09 -0400
commita85e00f3ff200c42352c07f1f3d57420873e756b (patch)
tree7d944cc9ba18baccc63d4197b847d74d73d84688 /jetty-deploy/src/main
parentd722830f0b386d7f6af2ecc8453283cac5aa2900 (diff)
downloadorg.eclipse.jetty.project-a85e00f3ff200c42352c07f1f3d57420873e756b.tar.gz
org.eclipse.jetty.project-a85e00f3ff200c42352c07f1f3d57420873e756b.tar.xz
org.eclipse.jetty.project-a85e00f3ff200c42352c07f1f3d57420873e756b.zip
Bug 345729 remove previous solution in lew of more general approach allowing for the application of a jetty-web.xml type file to all contexts in the binding phase
git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@3208 7e9141cc-0065-0410-87d8-b60c137991c4
Diffstat (limited to 'jetty-deploy/src/main')
-rw-r--r--jetty-deploy/src/main/java/org/eclipse/jetty/deploy/bindings/GlobalJettyXmlBinding.java72
-rw-r--r--jetty-deploy/src/main/java/org/eclipse/jetty/deploy/bindings/WebappClasspathPatternBinding.java86
2 files changed, 72 insertions, 86 deletions
diff --git a/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/bindings/GlobalJettyXmlBinding.java b/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/bindings/GlobalJettyXmlBinding.java
new file mode 100644
index 0000000000..ddcd2877a6
--- /dev/null
+++ b/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/bindings/GlobalJettyXmlBinding.java
@@ -0,0 +1,72 @@
+package org.eclipse.jetty.deploy.bindings;
+
+import java.net.URL;
+
+import org.eclipse.jetty.deploy.App;
+import org.eclipse.jetty.deploy.AppLifeCycle;
+import org.eclipse.jetty.deploy.graph.Node;
+import org.eclipse.jetty.server.handler.ContextHandler;
+import org.eclipse.jetty.util.log.Log;
+import org.eclipse.jetty.util.resource.FileResource;
+import org.eclipse.jetty.util.resource.Resource;
+import org.eclipse.jetty.webapp.WebAppContext;
+import org.eclipse.jetty.xml.XmlConfiguration;
+
+public class GlobalJettyXmlBinding implements AppLifeCycle.Binding
+{
+
+ private String _jettyXml;
+
+ public String getJettyXml()
+ {
+ return _jettyXml;
+ }
+
+ public void setJettyXml(String jettyXml)
+ {
+ this._jettyXml = jettyXml;
+ }
+
+ public String[] getBindingTargets()
+ {
+ return new String[] { "deploying" };
+ }
+
+ public void processBinding(Node node, App app) throws Exception
+ {
+ ContextHandler handler = app.getContextHandler();
+ if (handler == null)
+ {
+ throw new NullPointerException("No Handler created for App: " + app);
+ }
+
+ if (handler instanceof WebAppContext)
+ {
+ WebAppContext context = (WebAppContext)handler;
+
+ if (Log.isDebugEnabled())
+ {
+ Log.debug("Binding: Configuring webapp context with global settings from: " + _jettyXml);
+ }
+
+ if ( _jettyXml == null )
+ {
+ Log.warn("Binding: global context binding is enabled but no jetty-web.xml file has been registered");
+ }
+
+ Resource globalContextSettings = new FileResource(new URL(_jettyXml));
+
+ if (globalContextSettings.exists())
+ {
+ XmlConfiguration jettyXmlConfig = new XmlConfiguration(globalContextSettings.getInputStream());
+
+ jettyXmlConfig.configure(context);
+ }
+ else
+ {
+ Log.info("Binding: Unable to locate global webapp context settings: " + _jettyXml);
+ }
+ }
+ }
+
+}
diff --git a/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/bindings/WebappClasspathPatternBinding.java b/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/bindings/WebappClasspathPatternBinding.java
deleted file mode 100644
index 7b2229d352..0000000000
--- a/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/bindings/WebappClasspathPatternBinding.java
+++ /dev/null
@@ -1,86 +0,0 @@
-package org.eclipse.jetty.deploy.bindings;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jetty.deploy.App;
-import org.eclipse.jetty.deploy.AppLifeCycle;
-import org.eclipse.jetty.deploy.graph.Node;
-import org.eclipse.jetty.server.handler.ContextHandler;
-import org.eclipse.jetty.webapp.WebAppContext;
-
-/**
- * This binding allows a user to manage a server wide policy of server
- * and system classes as they exist for the webapp context. These settings
- * can alter and override any that might have been set during context handler
- * creation.
- *
- */
-public class WebappClasspathPatternBinding implements AppLifeCycle.Binding
-{
- private List<String> _serverClasses = new ArrayList<String>();
- private List<String> _systemClasses = new ArrayList<String>();
-
- /**
- * if true, this binding will replace server and system classes instead
- * of merging with whatever is in the ContextHandler when processBinding
- * is invoked.
- */
- private boolean _override = false;
-
- public void setOverride( boolean override )
- {
- _override = override;
- }
-
- public void setServerClasses(String[] serverClasses)
- {
- for ( String entry : serverClasses )
- {
- _serverClasses.add(entry);
- }
- }
-
- public void setSystemClasses(String[] systemClasses)
- {
- for (String entry : systemClasses)
- {
- _systemClasses.add(entry);
- }
- }
-
- public String[] getBindingTargets()
- {
- return new String[] { "deploying" };
- }
-
- public void processBinding(Node node, App app) throws Exception
- {
- ContextHandler handler = app.getContextHandler();
- if (handler == null)
- {
- throw new NullPointerException("No Handler created for App: " + app);
- }
-
- if (handler instanceof WebAppContext)
- {
- WebAppContext webapp = (WebAppContext)handler;
-
- if ( !_override )
- {
- for ( String entry : webapp.getServerClasses() )
- {
- _serverClasses.add(entry);
- }
- for ( String entry : webapp.getSystemClasses() )
- {
- _systemClasses.add(entry);
- }
- }
-
- webapp.setServerClasses( _serverClasses.toArray(new String[_serverClasses.size()]) );
- webapp.setSystemClasses( _systemClasses.toArray(new String[_systemClasses.size()]) );
- }
- }
-
-}

Back to the top