deltaspike-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From johndam...@apache.org
Subject [2/2] git commit: DELTASPIKE-653 Added servlet support and tests in two embedded containers.
Date Wed, 06 Aug 2014 02:17:35 GMT
DELTASPIKE-653 Added servlet support and tests in two embedded containers.


Project: http://git-wip-us.apache.org/repos/asf/deltaspike/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltaspike/commit/d76094f6
Tree: http://git-wip-us.apache.org/repos/asf/deltaspike/tree/d76094f6
Diff: http://git-wip-us.apache.org/repos/asf/deltaspike/diff/d76094f6

Branch: refs/heads/master
Commit: d76094f6c668cbdc2d487eab4c99df269c27fb1b
Parents: ae22919
Author: John D. Ament <johndament@apache.org>
Authored: Tue Aug 5 22:17:22 2014 -0400
Committer: John D. Ament <johndament@apache.org>
Committed: Tue Aug 5 22:17:22 2014 -0400

----------------------------------------------------------------------
 deltaspike/cdictrl/pom.xml                      |   3 +
 deltaspike/cdictrl/servlet-test-jetty/pom.xml   | 143 +++++++++++++++++
 .../cdise/servlet/test/jetty/JettyTest.java     |  42 +++++
 .../src/test/resources/META-INF/beans.xml       |   8 +
 .../cdictrl/servlet-test-undertow/pom.xml       | 143 +++++++++++++++++
 .../cdise/servlet/test/ut/UndertowTest.java     |  49 ++++++
 .../src/test/resources/META-INF/beans.xml       |   8 +
 deltaspike/cdictrl/servlet/pom.xml              | 157 +++++++++++++++++++
 .../servlet/CdiServletContextListener.java      |  40 +++++
 .../servlet/CdiServletRequestListener.java      |  62 ++++++++
 .../servlet/test/EmbeddedServletContainer.java  |  75 +++++++++
 .../servlet/test/content/RequestScopedBean.java |  19 +++
 .../servlet/test/content/RequestServlet.java    |  55 +++++++
 .../src/test/resources/META-INF/beans.xml       |  23 +++
 14 files changed, 827 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltaspike/blob/d76094f6/deltaspike/cdictrl/pom.xml
----------------------------------------------------------------------
diff --git a/deltaspike/cdictrl/pom.xml b/deltaspike/cdictrl/pom.xml
index 67e29d4..a4f6376 100644
--- a/deltaspike/cdictrl/pom.xml
+++ b/deltaspike/cdictrl/pom.xml
@@ -39,5 +39,8 @@
         <module>impl-owb</module>
         <module>impl-weld</module>
         <module>impl-openejb</module>
+        <module>servlet</module>
+        <module>servlet-test-undertow</module>
+        <module>servlet-test-jetty</module>
     </modules>
 </project>

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/d76094f6/deltaspike/cdictrl/servlet-test-jetty/pom.xml
----------------------------------------------------------------------
diff --git a/deltaspike/cdictrl/servlet-test-jetty/pom.xml b/deltaspike/cdictrl/servlet-test-jetty/pom.xml
new file mode 100644
index 0000000..01301f3
--- /dev/null
+++ b/deltaspike/cdictrl/servlet-test-jetty/pom.xml
@@ -0,0 +1,143 @@
+<?xml version="1.0" encoding="UTF-8"?>
+    <!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+  ~ Copyright (c) 2013 - 2014 Sparta Systems, Inc.
+  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.deltaspike.cdictrl</groupId>
+        <artifactId>cdictrl-project</artifactId>
+        <version>1.0.2-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+
+    <artifactId>deltaspike-cdictrl-servlet-test-jetty</artifactId>
+    <packaging>jar</packaging>
+
+    <name>Apache DeltaSpike CDI Servlet-ContainerControl-Jetty-Tests</name>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.httpcomponents</groupId>
+            <artifactId>httpclient</artifactId>
+            <version>4.2.5</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.deltaspike.cdictrl</groupId>
+            <artifactId>deltaspike-cdictrl-api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>javax.el</groupId>
+            <artifactId>el-api</artifactId>
+            <version>2.2</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-jta_1.1_spec</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.deltaspike.test</groupId>
+            <artifactId>test-utils</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.eclipse.jetty</groupId>
+            <artifactId>jetty-server</artifactId>
+            <version>9.2.2.v20140723</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.eclipse.jetty</groupId>
+            <artifactId>jetty-servlet</artifactId>
+            <version>9.2.2.v20140723</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-servlet_3.0_spec</artifactId>
+            <version>1.0</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-jcdi_1.0_spec</artifactId>
+            <optional>true</optional>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-atinject_1.0_spec</artifactId>
+            <optional>true</optional>
+        </dependency>
+        <dependency>
+            <groupId>org.hamcrest</groupId>
+            <artifactId>hamcrest-library</artifactId>
+            <version>1.3</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.deltaspike.cdictrl</groupId>
+            <artifactId>deltaspike-cdictrl-servlet</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.deltaspike.cdictrl</groupId>
+            <artifactId>deltaspike-cdictrl-servlet</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+            <type>test-jar</type>
+        </dependency>
+    </dependencies>
+    <profiles>
+        <profile>
+            <id>Weld</id>
+            <dependencies>
+                <dependency>
+                    <groupId>org.apache.deltaspike.cdictrl</groupId>
+                    <artifactId>deltaspike-cdictrl-weld</artifactId>
+                    <scope>test</scope>
+                </dependency>
+                <dependency>
+                    <groupId>org.jboss.weld.se</groupId>
+                    <artifactId>weld-se</artifactId>
+                    <version>${weld.version}</version>
+                    <scope>test</scope>
+                </dependency>
+            </dependencies>
+        </profile>
+        <profile>
+            <id>OWB</id>
+            <activation>
+                <activeByDefault>true</activeByDefault>
+            </activation>
+            <dependencies>
+                <dependency>
+                    <groupId>org.apache.geronimo.specs</groupId>
+                    <artifactId>geronimo-interceptor_1.1_spec</artifactId>
+                    <scope>test</scope>
+                </dependency>
+                <dependency>
+                    <groupId>org.apache.openwebbeans</groupId>
+                    <artifactId>openwebbeans-impl</artifactId>
+                    <scope>provided</scope>
+                </dependency>
+                <dependency>
+                    <groupId>org.apache.openwebbeans</groupId>
+                    <artifactId>openwebbeans-spi</artifactId>
+                    <scope>provided</scope>
+                </dependency>
+                <dependency>
+                    <groupId>org.apache.deltaspike.cdictrl</groupId>
+                    <artifactId>deltaspike-cdictrl-owb</artifactId>
+                    <scope>test</scope>
+                </dependency>
+            </dependencies>
+        </profile>
+    </profiles>
+</project>

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/d76094f6/deltaspike/cdictrl/servlet-test-jetty/src/test/java/org/apache/deltaspike/cdise/servlet/test/jetty/JettyTest.java
----------------------------------------------------------------------
diff --git a/deltaspike/cdictrl/servlet-test-jetty/src/test/java/org/apache/deltaspike/cdise/servlet/test/jetty/JettyTest.java
b/deltaspike/cdictrl/servlet-test-jetty/src/test/java/org/apache/deltaspike/cdise/servlet/test/jetty/JettyTest.java
new file mode 100644
index 0000000..a6947e4
--- /dev/null
+++ b/deltaspike/cdictrl/servlet-test-jetty/src/test/java/org/apache/deltaspike/cdise/servlet/test/jetty/JettyTest.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2013 - 2014 Sparta Systems, Inc.
+ ******************************************************************************/
+
+package org.apache.deltaspike.cdise.servlet.test.jetty;
+
+import org.apache.deltaspike.cdise.servlet.CdiServletRequestListener;
+import org.apache.deltaspike.cdise.servlet.test.EmbeddedServletContainer;
+import org.apache.deltaspike.cdise.servlet.test.content.RequestServlet;
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.servlet.ServletContextHandler;
+import org.eclipse.jetty.servlet.ServletHolder;
+
+/**
+ * Jetty based tests.
+ */
+public class JettyTest extends EmbeddedServletContainer
+{
+    private Server server;
+    @Override
+    protected int createServer() throws Exception
+    {
+        int port = super.getPort();
+        server = new Server(port);
+
+        ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
+        context.setContextPath("/");
+        server.setHandler(context);
+
+        context.addEventListener(new CdiServletRequestListener());
+        context.addServlet(new ServletHolder(new RequestServlet()),"/*");
+
+        server.start();
+        return port;
+    }
+
+    @Override
+    protected void shutdown() throws Exception
+    {
+        server.stop();
+    }
+}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/d76094f6/deltaspike/cdictrl/servlet-test-jetty/src/test/resources/META-INF/beans.xml
----------------------------------------------------------------------
diff --git a/deltaspike/cdictrl/servlet-test-jetty/src/test/resources/META-INF/beans.xml b/deltaspike/cdictrl/servlet-test-jetty/src/test/resources/META-INF/beans.xml
new file mode 100644
index 0000000..3ac4b3b
--- /dev/null
+++ b/deltaspike/cdictrl/servlet-test-jetty/src/test/resources/META-INF/beans.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+  ~ Copyright (c) 2013 - 2014 Sparta Systems, Inc.
+  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+<beans xmlns="http://java.sun.com/xml/ns/javaee"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
+</beans>

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/d76094f6/deltaspike/cdictrl/servlet-test-undertow/pom.xml
----------------------------------------------------------------------
diff --git a/deltaspike/cdictrl/servlet-test-undertow/pom.xml b/deltaspike/cdictrl/servlet-test-undertow/pom.xml
new file mode 100644
index 0000000..8a96584
--- /dev/null
+++ b/deltaspike/cdictrl/servlet-test-undertow/pom.xml
@@ -0,0 +1,143 @@
+<?xml version="1.0" encoding="UTF-8"?>
+    <!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+  ~ Copyright (c) 2013 - 2014 Sparta Systems, Inc.
+  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.deltaspike.cdictrl</groupId>
+        <artifactId>cdictrl-project</artifactId>
+        <version>1.0.2-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+
+    <artifactId>deltaspike-cdictrl-servlet-test-ut</artifactId>
+    <packaging>jar</packaging>
+
+    <name>Apache DeltaSpike CDI Servlet-ContainerControl-Undertow-Tests</name>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.httpcomponents</groupId>
+            <artifactId>httpclient</artifactId>
+            <version>4.2.5</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.deltaspike.cdictrl</groupId>
+            <artifactId>deltaspike-cdictrl-api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>javax.el</groupId>
+            <artifactId>el-api</artifactId>
+            <version>2.2</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-jta_1.1_spec</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.deltaspike.test</groupId>
+            <artifactId>test-utils</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>io.undertow</groupId>
+            <artifactId>undertow-servlet</artifactId>
+            <version>1.1.0.Beta6</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>io.undertow</groupId>
+            <artifactId>undertow-core</artifactId>
+            <version>1.1.0.Beta6</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-servlet_3.0_spec</artifactId>
+            <version>1.0</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-jcdi_1.0_spec</artifactId>
+            <optional>true</optional>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-atinject_1.0_spec</artifactId>
+            <optional>true</optional>
+        </dependency>
+        <dependency>
+            <groupId>org.hamcrest</groupId>
+            <artifactId>hamcrest-library</artifactId>
+            <version>1.3</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.deltaspike.cdictrl</groupId>
+            <artifactId>deltaspike-cdictrl-servlet</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.deltaspike.cdictrl</groupId>
+            <artifactId>deltaspike-cdictrl-servlet</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+            <type>test-jar</type>
+        </dependency>
+    </dependencies>
+    <profiles>
+        <profile>
+            <id>Weld</id>
+            <dependencies>
+                <dependency>
+                    <groupId>org.apache.deltaspike.cdictrl</groupId>
+                    <artifactId>deltaspike-cdictrl-weld</artifactId>
+                    <scope>test</scope>
+                </dependency>
+                <dependency>
+                    <groupId>org.jboss.weld.se</groupId>
+                    <artifactId>weld-se</artifactId>
+                    <version>${weld.version}</version>
+                    <scope>test</scope>
+                </dependency>
+            </dependencies>
+        </profile>
+        <profile>
+            <id>OWB</id>
+            <activation>
+                <activeByDefault>true</activeByDefault>
+            </activation>
+            <dependencies>
+                <dependency>
+                    <groupId>org.apache.geronimo.specs</groupId>
+                    <artifactId>geronimo-interceptor_1.1_spec</artifactId>
+                    <scope>test</scope>
+                </dependency>
+                <dependency>
+                    <groupId>org.apache.openwebbeans</groupId>
+                    <artifactId>openwebbeans-impl</artifactId>
+                    <scope>provided</scope>
+                </dependency>
+                <dependency>
+                    <groupId>org.apache.openwebbeans</groupId>
+                    <artifactId>openwebbeans-spi</artifactId>
+                    <scope>provided</scope>
+                </dependency>
+                <dependency>
+                    <groupId>org.apache.deltaspike.cdictrl</groupId>
+                    <artifactId>deltaspike-cdictrl-owb</artifactId>
+                    <scope>test</scope>
+                </dependency>
+            </dependencies>
+        </profile>
+    </profiles>
+</project>

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/d76094f6/deltaspike/cdictrl/servlet-test-undertow/src/test/java/org/apache/deltaspike/cdise/servlet/test/ut/UndertowTest.java
----------------------------------------------------------------------
diff --git a/deltaspike/cdictrl/servlet-test-undertow/src/test/java/org/apache/deltaspike/cdise/servlet/test/ut/UndertowTest.java
b/deltaspike/cdictrl/servlet-test-undertow/src/test/java/org/apache/deltaspike/cdise/servlet/test/ut/UndertowTest.java
new file mode 100644
index 0000000..5e1fd15
--- /dev/null
+++ b/deltaspike/cdictrl/servlet-test-undertow/src/test/java/org/apache/deltaspike/cdise/servlet/test/ut/UndertowTest.java
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2013 - 2014 Sparta Systems, Inc.
+ ******************************************************************************/
+
+package org.apache.deltaspike.cdise.servlet.test.ut;
+
+import io.undertow.Undertow;
+import io.undertow.servlet.Servlets;
+import io.undertow.servlet.api.DeploymentInfo;
+import io.undertow.servlet.api.DeploymentManager;
+import io.undertow.servlet.api.ListenerInfo;
+import io.undertow.servlet.api.ServletInfo;
+import org.apache.deltaspike.cdise.servlet.CdiServletRequestListener;
+import org.apache.deltaspike.cdise.servlet.test.EmbeddedServletContainer;
+import org.apache.deltaspike.cdise.servlet.test.content.RequestServlet;
+
+/**
+ * Test execution for undertow embedded container.
+ */
+public class UndertowTest extends EmbeddedServletContainer
+{
+    private Undertow server;
+
+    protected int createServer() throws Exception
+    {
+        int port = getPort();
+        ServletInfo servletInfo = Servlets.servlet("RequestServlet", RequestServlet.class).setAsyncSupported(true)
+                .setLoadOnStartup(1).addMapping("/*");
+        ListenerInfo listenerInfo = Servlets.listener(CdiServletRequestListener.class);
+        DeploymentInfo di = new DeploymentInfo()
+                .addListener(listenerInfo)
+                .setContextPath("/")
+                .addServlet(servletInfo).setDeploymentName("CdiSEServlet")
+                .setClassLoader(ClassLoader.getSystemClassLoader());
+        DeploymentManager deploymentManager = Servlets.defaultContainer().addDeployment(di);
+        deploymentManager.deploy();
+        server = Undertow.builder()
+                .addHttpListener(port, "localhost")
+                .setHandler(deploymentManager.start())
+                .build();
+        server.start();
+        return port;
+    }
+
+    protected void shutdown() throws Exception
+    {
+        server.stop();
+    }
+}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/d76094f6/deltaspike/cdictrl/servlet-test-undertow/src/test/resources/META-INF/beans.xml
----------------------------------------------------------------------
diff --git a/deltaspike/cdictrl/servlet-test-undertow/src/test/resources/META-INF/beans.xml
b/deltaspike/cdictrl/servlet-test-undertow/src/test/resources/META-INF/beans.xml
new file mode 100644
index 0000000..3ac4b3b
--- /dev/null
+++ b/deltaspike/cdictrl/servlet-test-undertow/src/test/resources/META-INF/beans.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+  ~ Copyright (c) 2013 - 2014 Sparta Systems, Inc.
+  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+<beans xmlns="http://java.sun.com/xml/ns/javaee"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
+</beans>

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/d76094f6/deltaspike/cdictrl/servlet/pom.xml
----------------------------------------------------------------------
diff --git a/deltaspike/cdictrl/servlet/pom.xml b/deltaspike/cdictrl/servlet/pom.xml
new file mode 100644
index 0000000..9e40c97
--- /dev/null
+++ b/deltaspike/cdictrl/servlet/pom.xml
@@ -0,0 +1,157 @@
+<?xml version="1.0" encoding="UTF-8"?>
+    <!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+  ~ Copyright (c) 2013 - 2014 Sparta Systems, Inc.
+  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.deltaspike.cdictrl</groupId>
+        <artifactId>cdictrl-project</artifactId>
+        <version>1.0.2-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+
+    <artifactId>deltaspike-cdictrl-servlet</artifactId>
+    <packaging>jar</packaging>
+
+    <name>Apache DeltaSpike CDI Servlet-ContainerControl</name>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.httpcomponents</groupId>
+            <artifactId>httpclient</artifactId>
+            <version>4.2.5</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.deltaspike.cdictrl</groupId>
+            <artifactId>deltaspike-cdictrl-api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>javax.el</groupId>
+            <artifactId>el-api</artifactId>
+            <version>2.2</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-jta_1.1_spec</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.deltaspike.test</groupId>
+            <artifactId>test-utils</artifactId>
+            <version>${project.version}</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>io.undertow</groupId>
+            <artifactId>undertow-servlet</artifactId>
+            <version>1.1.0.Beta6</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>io.undertow</groupId>
+            <artifactId>undertow-core</artifactId>
+            <version>1.1.0.Beta6</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.eclipse.jetty</groupId>
+            <artifactId>jetty-server</artifactId>
+            <version>9.2.2.v20140723</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.eclipse.jetty</groupId>
+            <artifactId>jetty-servlet</artifactId>
+            <version>9.2.2.v20140723</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-servlet_3.0_spec</artifactId>
+            <version>1.0</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-jcdi_1.0_spec</artifactId>
+            <optional>true</optional>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-atinject_1.0_spec</artifactId>
+            <optional>true</optional>
+        </dependency>
+        <dependency>
+            <groupId>org.hamcrest</groupId>
+            <artifactId>hamcrest-library</artifactId>
+            <version>1.3</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+    <profiles>
+        <profile>
+            <id>Weld</id>
+            <dependencies>
+                <dependency>
+                    <groupId>org.apache.deltaspike.cdictrl</groupId>
+                    <artifactId>deltaspike-cdictrl-weld</artifactId>
+                    <scope>test</scope>
+                </dependency>
+                <dependency>
+                    <groupId>org.jboss.weld.se</groupId>
+                    <artifactId>weld-se</artifactId>
+                    <version>${weld.version}</version>
+                    <scope>test</scope>
+                </dependency>
+            </dependencies>
+        </profile>
+        <profile>
+            <id>OWB</id>
+            <activation>
+                <activeByDefault>true</activeByDefault>
+            </activation>
+            <dependencies>
+                <dependency>
+                    <groupId>org.apache.geronimo.specs</groupId>
+                    <artifactId>geronimo-interceptor_1.1_spec</artifactId>
+                    <scope>test</scope>
+                </dependency>
+                <dependency>
+                    <groupId>org.apache.openwebbeans</groupId>
+                    <artifactId>openwebbeans-impl</artifactId>
+                    <scope>provided</scope>
+                </dependency>
+                <dependency>
+                    <groupId>org.apache.openwebbeans</groupId>
+                    <artifactId>openwebbeans-spi</artifactId>
+                    <scope>provided</scope>
+                </dependency>
+                <dependency>
+                    <groupId>org.apache.deltaspike.cdictrl</groupId>
+                    <artifactId>deltaspike-cdictrl-owb</artifactId>
+                    <scope>test</scope>
+                </dependency>
+            </dependencies>
+        </profile>
+    </profiles>
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-jar-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>test-jar</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+</project>

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/d76094f6/deltaspike/cdictrl/servlet/src/main/java/org/apache/deltaspike/cdise/servlet/CdiServletContextListener.java
----------------------------------------------------------------------
diff --git a/deltaspike/cdictrl/servlet/src/main/java/org/apache/deltaspike/cdise/servlet/CdiServletContextListener.java
b/deltaspike/cdictrl/servlet/src/main/java/org/apache/deltaspike/cdise/servlet/CdiServletContextListener.java
new file mode 100644
index 0000000..985033d
--- /dev/null
+++ b/deltaspike/cdictrl/servlet/src/main/java/org/apache/deltaspike/cdise/servlet/CdiServletContextListener.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.deltaspike.cdise.servlet;
+
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+
+/**
+ * Adds a listener to the context for enabling requests.
+ */
+public class CdiServletContextListener implements ServletContextListener
+{
+    @Override
+    public void contextInitialized(ServletContextEvent servletContextEvent)
+    {
+        servletContextEvent.getServletContext().addListener(CdiServletRequestListener.class);
+    }
+
+    @Override
+    public void contextDestroyed(ServletContextEvent servletContextEvent)
+    {
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/d76094f6/deltaspike/cdictrl/servlet/src/main/java/org/apache/deltaspike/cdise/servlet/CdiServletRequestListener.java
----------------------------------------------------------------------
diff --git a/deltaspike/cdictrl/servlet/src/main/java/org/apache/deltaspike/cdise/servlet/CdiServletRequestListener.java
b/deltaspike/cdictrl/servlet/src/main/java/org/apache/deltaspike/cdise/servlet/CdiServletRequestListener.java
new file mode 100644
index 0000000..840cada
--- /dev/null
+++ b/deltaspike/cdictrl/servlet/src/main/java/org/apache/deltaspike/cdise/servlet/CdiServletRequestListener.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.deltaspike.cdise.servlet;
+
+import org.apache.deltaspike.cdise.api.CdiContainer;
+import org.apache.deltaspike.cdise.api.CdiContainerLoader;
+import org.apache.deltaspike.cdise.api.ContextControl;
+
+import javax.enterprise.context.RequestScoped;
+import javax.servlet.ServletRequestEvent;
+import javax.servlet.ServletRequestListener;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * Starts a request context for each incoming HTTP request.
+ */
+public class CdiServletRequestListener implements ServletRequestListener
+{
+    private static final Logger LOG = Logger.getLogger(CdiServletRequestListener.class.getName());
+    private static final String CDI_REQ_CONTEXT = "cdiRequestContext";
+
+    @Override
+    public void requestDestroyed(ServletRequestEvent servletRequestEvent)
+    {
+        LOG.log(Level.FINER,"Request done.");
+        ContextControl contextControl = (ContextControl)servletRequestEvent.getServletRequest()
+                .getAttribute(CDI_REQ_CONTEXT);
+        contextControl.stopContext(RequestScoped.class);
+    }
+
+    @Override
+    public void requestInitialized(ServletRequestEvent servletRequestEvent)
+    {
+        LOG.log(Level.FINER,"Incoming request.");
+        ContextControl contextControl = getContextControl();
+        servletRequestEvent.getServletRequest().setAttribute(CDI_REQ_CONTEXT, contextControl);
+        contextControl.startContext(RequestScoped.class);
+    }
+
+    private ContextControl getContextControl()
+    {
+        CdiContainer container = CdiContainerLoader.getCdiContainer();
+        return container.createContextControl();
+    }
+}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/d76094f6/deltaspike/cdictrl/servlet/src/test/java/org/apache/deltaspike/cdise/servlet/test/EmbeddedServletContainer.java
----------------------------------------------------------------------
diff --git a/deltaspike/cdictrl/servlet/src/test/java/org/apache/deltaspike/cdise/servlet/test/EmbeddedServletContainer.java
b/deltaspike/cdictrl/servlet/src/test/java/org/apache/deltaspike/cdise/servlet/test/EmbeddedServletContainer.java
new file mode 100644
index 0000000..a156c1a
--- /dev/null
+++ b/deltaspike/cdictrl/servlet/src/test/java/org/apache/deltaspike/cdise/servlet/test/EmbeddedServletContainer.java
@@ -0,0 +1,75 @@
+/*******************************************************************************
+ * Copyright (c) 2013 - 2014 Sparta Systems, Inc.
+ ******************************************************************************/
+
+package org.apache.deltaspike.cdise.servlet.test;
+
+import io.undertow.Undertow;
+import io.undertow.servlet.Servlets;
+import io.undertow.servlet.api.DeploymentInfo;
+import io.undertow.servlet.api.DeploymentManager;
+import io.undertow.servlet.api.ListenerInfo;
+import io.undertow.servlet.api.ServletInfo;
+import org.apache.deltaspike.cdise.api.CdiContainer;
+import org.apache.deltaspike.cdise.api.CdiContainerLoader;
+import org.apache.deltaspike.cdise.servlet.CdiServletRequestListener;
+import org.apache.deltaspike.cdise.servlet.test.content.RequestServlet;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.impl.client.DefaultHttpClient;
+import org.junit.Test;
+
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.util.Random;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Created by johnament on 8/5/14.
+ */
+public abstract class EmbeddedServletContainer
+{
+    protected int getPort()
+    {
+        Random r = new Random();
+        for(int i = 0;i<10;i++)
+        {
+            int p = r.nextInt(9999);
+            if(p > 1000)
+            {
+                return p;
+            }
+        }
+        return 1001;
+    }
+
+    protected abstract int createServer() throws Exception;
+
+    protected abstract void shutdown() throws Exception;
+
+    @Test
+    public void testBootRequest() throws Exception
+    {
+        CdiContainer cdiContainer = CdiContainerLoader.getCdiContainer();
+        cdiContainer.boot();
+        cdiContainer.getContextControl().startContexts();
+        int port = createServer();
+        testRead(port);
+        shutdown();
+    }
+
+    private void testRead(int port) throws Exception
+    {
+        String url = new URL("http","localhost",port,"/").toString();
+        HttpResponse response = new DefaultHttpClient().execute(new HttpGet(url));
+        assertEquals(200, response.getStatusLine().getStatusCode());
+        InputStream is = response.getEntity().getContent();
+        BufferedReader br = new BufferedReader(new InputStreamReader(is));
+        String data = br.readLine();
+        is.close();
+        assertEquals("Hello, world!",data);
+    }
+}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/d76094f6/deltaspike/cdictrl/servlet/src/test/java/org/apache/deltaspike/cdise/servlet/test/content/RequestScopedBean.java
----------------------------------------------------------------------
diff --git a/deltaspike/cdictrl/servlet/src/test/java/org/apache/deltaspike/cdise/servlet/test/content/RequestScopedBean.java
b/deltaspike/cdictrl/servlet/src/test/java/org/apache/deltaspike/cdise/servlet/test/content/RequestScopedBean.java
new file mode 100644
index 0000000..1f855ad
--- /dev/null
+++ b/deltaspike/cdictrl/servlet/src/test/java/org/apache/deltaspike/cdise/servlet/test/content/RequestScopedBean.java
@@ -0,0 +1,19 @@
+/*******************************************************************************
+ * Copyright (c) 2013 - 2014 Sparta Systems, Inc.
+ ******************************************************************************/
+
+package org.apache.deltaspike.cdise.servlet.test.content;
+
+import javax.enterprise.context.RequestScoped;
+
+/**
+ * a simple request scoped object.
+ */
+@RequestScoped
+public class RequestScopedBean
+{
+    public String greet()
+    {
+        return "Hello, world!";
+    }
+}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/d76094f6/deltaspike/cdictrl/servlet/src/test/java/org/apache/deltaspike/cdise/servlet/test/content/RequestServlet.java
----------------------------------------------------------------------
diff --git a/deltaspike/cdictrl/servlet/src/test/java/org/apache/deltaspike/cdise/servlet/test/content/RequestServlet.java
b/deltaspike/cdictrl/servlet/src/test/java/org/apache/deltaspike/cdise/servlet/test/content/RequestServlet.java
new file mode 100644
index 0000000..85100ae
--- /dev/null
+++ b/deltaspike/cdictrl/servlet/src/test/java/org/apache/deltaspike/cdise/servlet/test/content/RequestServlet.java
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (c) 2013 - 2014 Sparta Systems, Inc.
+ ******************************************************************************/
+
+package org.apache.deltaspike.cdise.servlet.test.content;
+
+import org.apache.deltaspike.cdise.api.CdiContainerLoader;
+
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Set;
+import java.util.logging.Logger;
+
+/**
+ * A simple servlet that calls a request scoped object.
+ */
+public class RequestServlet extends HttpServlet
+{
+    private final Logger LOG = Logger.getLogger(RequestServlet.class.getName());
+    @Override
+    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException,
IOException
+    {
+        LOG.warning("incoming request "+Thread.currentThread().getName());
+        PrintWriter out = resp.getWriter();
+        RequestScopedBean bean = getRequestScopedBean();
+        out.write(bean.greet());
+        out.close();
+    }
+
+    private RequestScopedBean getRequestScopedBean()
+    {
+        BeanManager beanManager = CdiContainerLoader.getCdiContainer().getBeanManager();
+
+        if (beanManager == null)
+        {
+            return null;
+        }
+        Set<Bean<?>> beans = beanManager.getBeans(RequestScopedBean.class);
+        Bean<RequestScopedBean> reqScpdBean = (Bean<RequestScopedBean>) beanManager.resolve(beans);
+
+        CreationalContext<RequestScopedBean> reqScpdCC =
+                beanManager.createCreationalContext(reqScpdBean);
+
+        RequestScopedBean instance = (RequestScopedBean)
+                beanManager.getReference(reqScpdBean, RequestScopedBean.class, reqScpdCC);
+        return instance;
+    }
+}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/d76094f6/deltaspike/cdictrl/servlet/src/test/resources/META-INF/beans.xml
----------------------------------------------------------------------
diff --git a/deltaspike/cdictrl/servlet/src/test/resources/META-INF/beans.xml b/deltaspike/cdictrl/servlet/src/test/resources/META-INF/beans.xml
new file mode 100644
index 0000000..4070730
--- /dev/null
+++ b/deltaspike/cdictrl/servlet/src/test/resources/META-INF/beans.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+-->
+<beans xmlns="http://java.sun.com/xml/ns/javaee"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
+</beans>


Mime
View raw message