Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse McConnell2011-05-13 16:22:12 -0400
committerJesse McConnell2011-05-13 16:22:12 -0400
commit5f01e2428b929e840fabe6c9383661f419492fff (patch)
tree29eb80f48d9205d3e3a947a868adce79534ae481 /jetty-deploy/src/main
parentdbcdcc6ce676b3e7b1e9b0b3a3150fbc1401100a (diff)
downloadorg.eclipse.jetty.project-5f01e2428b929e840fabe6c9383661f419492fff.tar.gz
org.eclipse.jetty.project-5f01e2428b929e840fabe6c9383661f419492fff.tar.xz
org.eclipse.jetty.project-5f01e2428b929e840fabe6c9383661f419492fff.zip
Bug 345729 add binding that can allow for global management of server and system classes for webapp contexts, added 2 gettings on webappcontext for getting default server and system class settings.
git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@3143 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/WebappClasspathPatternBinding.java86
1 files changed, 86 insertions, 0 deletions
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
new file mode 100644
index 0000000000..7b2229d352
--- /dev/null
+++ b/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/bindings/WebappClasspathPatternBinding.java
@@ -0,0 +1,86 @@
+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