diff --git a/jetty-cdi/pom.xml b/jetty-cdi/pom.xml index 5440c4d7e4f..5f5073cdec1 100644 --- a/jetty-cdi/pom.xml +++ b/jetty-cdi/pom.xml @@ -35,5 +35,10 @@ + + org.eclipse.jetty + jetty-deploy + ${project.version} + diff --git a/jetty-cdi/src/main/config/etc/jetty-cdi.xml b/jetty-cdi/src/main/config/etc/jetty-cdi.xml new file mode 100644 index 00000000000..d364f4c45a6 --- /dev/null +++ b/jetty-cdi/src/main/config/etc/jetty-cdi.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + diff --git a/jetty-cdi/src/main/config/modules/cdi.mod b/jetty-cdi/src/main/config/modules/cdi.mod index e352a7113e4..b66263eb43e 100644 --- a/jetty-cdi/src/main/config/modules/cdi.mod +++ b/jetty-cdi/src/main/config/modules/cdi.mod @@ -3,6 +3,7 @@ # [depend] +deploy annotations # JSP (and EL) are requirements for CDI and Weld jsp @@ -15,6 +16,9 @@ http://central.maven.org/maven2/org/jboss/weld/servlet/weld-servlet/2.2.5.Final/ lib/weld/weld-servlet-2.2.5.Final.jar lib/jetty-cdi-${jetty.version}.jar +[xml] +etc/jetty-cdi.xml + [license] Weld is an open source project hosted on Github and released under the Apache 2.0 license. http://weld.cdi-spec.org/ diff --git a/jetty-cdi/src/main/java/org/eclipse/jetty/cdi/WeldDeploymentBinding.java b/jetty-cdi/src/main/java/org/eclipse/jetty/cdi/WeldDeploymentBinding.java new file mode 100644 index 00000000000..887be29e3ef --- /dev/null +++ b/jetty-cdi/src/main/java/org/eclipse/jetty/cdi/WeldDeploymentBinding.java @@ -0,0 +1,66 @@ +// +// ======================================================================== +// Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd. +// ------------------------------------------------------------------------ +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the Eclipse Public License v1.0 +// and Apache License v2.0 which accompanies this distribution. +// +// The Eclipse Public License is available at +// http://www.eclipse.org/legal/epl-v10.html +// +// The Apache License v2.0 is available at +// http://www.opensource.org/licenses/apache2.0.php +// +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== +// + +package org.eclipse.jetty.cdi; + +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; + +/** + * Perform some basic weld configuration of WebAppContext + */ +public class WeldDeploymentBinding implements AppLifeCycle.Binding +{ + 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; + + webapp.setInitParameter("org.jboss.weld.environment.container.class", + "org.jboss.weld.environment.jetty.JettyContainer"); + + // webapp cannot change / replace weld classes + webapp.addSystemClass("org.jboss.weld."); + webapp.addSystemClass("org.jboss.classfilewriter."); + webapp.addSystemClass("org.jboss.logging."); + webapp.addSystemClass("com.google.common."); + + // don't hide weld classes from webapps (allow webapp to use ones from system classloader) + webapp.addServerClass("-org.jboss.weld."); + webapp.addServerClass("-org.jboss.classfilewriter."); + webapp.addServerClass("-org.jboss.logging."); + webapp.addServerClass("-com.google.common."); + } + } +} diff --git a/pom.xml b/pom.xml index b86dabff430..6d5e1c40159 100644 --- a/pom.xml +++ b/pom.xml @@ -443,6 +443,7 @@ jetty-annotations jetty-jndi jetty-jaas + jetty-cdi jetty-spring jetty-client jetty-proxy diff --git a/tests/test-cdi/cdi-webapp-it/pom.xml b/tests/test-cdi/cdi-webapp-it/pom.xml index 513ae874b82..ac3baf20365 100644 --- a/tests/test-cdi/cdi-webapp-it/pom.xml +++ b/tests/test-cdi/cdi-webapp-it/pom.xml @@ -146,7 +146,7 @@ -