You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltaspike.apache.org by st...@apache.org on 2012/03/17 21:35:49 UTC

[1/2] git commit: DELTASPIKE-92 split Container and Context stuff

Updated Branches:
  refs/heads/master 9906b1a32 -> fd790135a


DELTASPIKE-92 split Container and Context stuff

I also fixed a few workarounds for owb and weld properly


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

Branch: refs/heads/master
Commit: fd790135ab6efdf20f8f323a19e7a0672ae8ef29
Parents: 9906b1a
Author: Mark Struberg <st...@apache.org>
Authored: Sat Mar 17 21:34:12 2012 +0100
Committer: Mark Struberg <st...@apache.org>
Committed: Sat Mar 17 21:34:12 2012 +0100

----------------------------------------------------------------------
 deltaspike/cdictrl/api/pom.xml                     |   60 +++
 .../apache/deltaspike/cdise/api/CdiContainer.java  |   59 +++
 .../deltaspike/cdise/api/CdiContainerLoader.java   |   80 ++++
 .../deltaspike/cdise/api/ContextControl.java       |   58 +++
 deltaspike/cdictrl/impl-owb/pom.xml                |  112 +++++
 .../deltaspike/cdise/owb/MockHttpSession.java      |  112 +++++
 .../deltaspike/cdise/owb/MockServletContext.java   |  167 ++++++++
 .../cdise/owb/OpenWebBeansContainerControl.java    |   87 ++++
 .../cdise/owb/OpenWebBeansContextControl.java      |  212 ++++++++++
 .../impl-owb/src/main/resources/META-INF/beans.xml |   23 +
 .../org.apache.deltaspike.cdise.api.CdiContainer   |   20 +
 deltaspike/cdictrl/impl-weld/pom.xml               |  105 +++++
 .../deltaspike/cdise/weld/ContextController.java   |  261 ++++++++++++
 .../cdise/weld/WeldContainerControl.java           |   78 ++++
 .../deltaspike/cdise/weld/WeldContextControl.java  |  253 ++++++++++++
 .../src/main/resources/META-INF/beans.xml          |   23 +
 .../org.apache.deltaspike.cdise.api.CdiContainer   |   20 +
 deltaspike/cdictrl/pom.xml                         |   42 ++
 deltaspike/cdictrl/tck/pom.xml                     |  188 +++++++++
 .../deltaspike/cdise/tck/ContainerCtrlTckTest.java |  179 ++++++++
 .../org/apache/deltaspike/cdise/tck/beans/Car.java |   40 ++
 .../deltaspike/cdise/tck/beans/CarRepair.java      |   39 ++
 .../apache/deltaspike/cdise/tck/beans/User.java    |   40 ++
 .../tck/src/main/resources/META-INF/beans.xml      |   23 +
 deltaspike/cdise/api/pom.xml                       |   60 ---
 .../apache/deltaspike/cdise/api/CdiContainer.java  |   93 -----
 .../deltaspike/cdise/api/CdiContainerLoader.java   |   80 ----
 deltaspike/cdise/impl-owb/pom.xml                  |  112 -----
 .../deltaspike/cdise/owb/MockHttpSession.java      |  112 -----
 .../deltaspike/cdise/owb/MockServletContext.java   |  167 --------
 .../cdise/owb/OpenWebBeansContainerControl.java    |  317 ---------------
 .../org.apache.deltaspike.cdise.api.CdiContainer   |   20 -
 deltaspike/cdise/impl-weld/pom.xml                 |  105 -----
 .../deltaspike/cdise/weld/ContextController.java   |  261 ------------
 .../cdise/weld/WeldContainerControl.java           |  224 ----------
 .../org.apache.deltaspike.cdise.api.CdiContainer   |   20 -
 deltaspike/cdise/pom.xml                           |   42 --
 deltaspike/cdise/tck/pom.xml                       |  188 ---------
 .../deltaspike/cdise/tck/ContainerCtrlTckTest.java |  153 -------
 .../org/apache/deltaspike/cdise/tck/beans/Car.java |   40 --
 .../deltaspike/cdise/tck/beans/CarRepair.java      |   39 --
 .../apache/deltaspike/cdise/tck/beans/User.java    |   40 --
 .../tck/src/main/resources/META-INF/beans.xml      |   23 -
 deltaspike/pom.xml                                 |    2 +-
 44 files changed, 2282 insertions(+), 2097 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/fd790135/deltaspike/cdictrl/api/pom.xml
----------------------------------------------------------------------
diff --git a/deltaspike/cdictrl/api/pom.xml b/deltaspike/cdictrl/api/pom.xml
new file mode 100644
index 0000000..d9d0327
--- /dev/null
+++ b/deltaspike/cdictrl/api/pom.xml
@@ -0,0 +1,60 @@
+<?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.
+    -->
+
+<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>0.2-incubating-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+
+    <artifactId>deltaspike-cdictrl-api</artifactId>
+    <packaging>jar</packaging>
+
+    <name>Apache DeltaSpike CDI ContainerControl API</name>
+
+    <description>
+        This project provides a way to genericly run CDI containers 
+        from inside of unit tests or Java SE applications.
+    </description>
+
+    <dependencies>
+        <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.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-interceptor_1.1_spec</artifactId>
+            <optional>true</optional>
+        </dependency>
+    </dependencies>
+
+</project>

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/fd790135/deltaspike/cdictrl/api/src/main/java/org/apache/deltaspike/cdise/api/CdiContainer.java
----------------------------------------------------------------------
diff --git a/deltaspike/cdictrl/api/src/main/java/org/apache/deltaspike/cdise/api/CdiContainer.java b/deltaspike/cdictrl/api/src/main/java/org/apache/deltaspike/cdise/api/CdiContainer.java
new file mode 100644
index 0000000..f85fdf0
--- /dev/null
+++ b/deltaspike/cdictrl/api/src/main/java/org/apache/deltaspike/cdise/api/CdiContainer.java
@@ -0,0 +1,59 @@
+/*
+ * 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.api;
+
+
+import javax.enterprise.inject.spi.BeanManager;
+
+
+/**
+ * <p>A CdiTestContainer provides access to an underlying JSR-299 (CDI)
+ * Container. It allows starting and stopping the container and to start
+ * and stop the built-in contexts of that container.</p>
+ *
+ * <p>The intention is to provide a portable control for CDI containers in
+ * Java SE environments. It is <b>not</b> intended for environments in which the
+ * CDI container is under full control of the server already, e.g. in
+ * EE-containers.</p>
+ */
+public interface CdiContainer
+{
+    /**
+     * Booting the CdiTestContainer will scan the whole classpath
+     * for Beans and extensions available.
+     * The container might throw a DeploymentException or similar on startup.
+     */
+    void boot();
+    
+    /**
+     * This will shutdown the underlying CDI container.
+     */
+    void shutdown();
+    
+
+    /**
+     * @return the {@link BeanManager} or <code>null</code> it not available
+     */
+    BeanManager getBeanManager();
+
+    /**
+     * @return ContextControl for the started Container. <code>null</code> if the container is not yet started
+     */
+    ContextControl getContextControl();
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/fd790135/deltaspike/cdictrl/api/src/main/java/org/apache/deltaspike/cdise/api/CdiContainerLoader.java
----------------------------------------------------------------------
diff --git a/deltaspike/cdictrl/api/src/main/java/org/apache/deltaspike/cdise/api/CdiContainerLoader.java b/deltaspike/cdictrl/api/src/main/java/org/apache/deltaspike/cdise/api/CdiContainerLoader.java
new file mode 100644
index 0000000..743a1a1
--- /dev/null
+++ b/deltaspike/cdictrl/api/src/main/java/org/apache/deltaspike/cdise/api/CdiContainerLoader.java
@@ -0,0 +1,80 @@
+/*
+ * 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.api;
+
+import java.util.Iterator;
+import java.util.ServiceLoader;
+
+/**
+ * <p>This class provides access to the ContainerControl.</p>
+ * <p>It uses the {@code java.util.ServiceLoader} mechanism  to 
+ * automatically pickup the container providers from the classpath.</p>
+ */
+public final class CdiContainerLoader
+{
+    private CdiContainerLoader()
+    {
+        // private ct to prevent instantiation
+    }
+
+    
+    public static CdiContainer getCdiContainer()
+    {
+        CdiContainer testContainer;
+
+        //doesn't support the implementation loader (there is no dependency to owb-impl
+        ServiceLoader<CdiContainer> cdiContainerLoader = ServiceLoader.load(CdiContainer.class);
+        Iterator<CdiContainer> cdiIt = cdiContainerLoader.iterator();
+        if (cdiIt.hasNext())
+        {
+            testContainer = cdiIt.next();
+        }
+        else 
+        {
+            throw new IllegalStateException("Could not find an implementation of " + CdiContainer.class.getName() +
+                " available in the classpath!");
+        }
+        
+        if (cdiIt.hasNext())
+        {
+            String foundContainers = getContainerDetails();
+            throw new IllegalStateException("Too many implementations of " + CdiContainer.class.getName() +
+                " found in the classpath! Details: " + foundContainers);
+        }
+        
+        return testContainer;
+    }
+
+    private static String getContainerDetails()
+    {
+        StringBuilder result = new StringBuilder();
+
+        Class containerClass;
+        for (CdiContainer cdiContainer : ServiceLoader.load(CdiContainer.class))
+        {
+            containerClass = cdiContainer.getClass();
+            result.append(containerClass.getProtectionDomain().getCodeSource().getLocation().toExternalForm());
+            result.append(containerClass.getName());
+
+            result.append(System.getProperty("line.separator"));
+        }
+
+        return result.toString();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/fd790135/deltaspike/cdictrl/api/src/main/java/org/apache/deltaspike/cdise/api/ContextControl.java
----------------------------------------------------------------------
diff --git a/deltaspike/cdictrl/api/src/main/java/org/apache/deltaspike/cdise/api/ContextControl.java b/deltaspike/cdictrl/api/src/main/java/org/apache/deltaspike/cdise/api/ContextControl.java
new file mode 100644
index 0000000..c0c5cdb
--- /dev/null
+++ b/deltaspike/cdictrl/api/src/main/java/org/apache/deltaspike/cdise/api/ContextControl.java
@@ -0,0 +1,58 @@
+/*
+ * 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.api;
+
+import java.lang.annotation.Annotation;
+
+/**
+ * Control native CDI Container Contexts.
+ * Just inject this interface and you gain manual access over built-in Contexts.
+ * The respective integration code will provide a &064;Dependent scoped instance.
+ */
+public interface ContextControl
+{
+    /**
+     * This will start all container built-in Contexts
+     */
+    void startContexts();
+
+    /**
+     * Stop all container built-in Contexts and destroy all beans properly
+     */
+    void stopContexts();
+
+    /**
+     * Start the specified scope. This only works for scopes which are handled
+     * by the CDI container itself. Custom scoped of 3rd party
+     * Context implementations shall be started directly (they are portable anyway).
+     *
+     * @param scopeClass e.g. RequestScoped.class
+     */
+    void startContext(Class<? extends Annotation> scopeClass);
+
+    /**
+     * Stop the specified scope. This only works for scopes which are handled
+     * by the CDI container itself. Custom scoped of 3rd party
+     * Context implementations shall be stopped directly (they are portable anyway).
+     *
+     * @param scopeClass e.g. RequestScoped.class
+     */
+    void stopContext(Class<? extends Annotation> scopeClass);
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/fd790135/deltaspike/cdictrl/impl-owb/pom.xml
----------------------------------------------------------------------
diff --git a/deltaspike/cdictrl/impl-owb/pom.xml b/deltaspike/cdictrl/impl-owb/pom.xml
new file mode 100644
index 0000000..f928b59
--- /dev/null
+++ b/deltaspike/cdictrl/impl-owb/pom.xml
@@ -0,0 +1,112 @@
+<?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.
+    -->
+
+<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>0.2-incubating-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+
+    <artifactId>deltaspike-cdictrl-owb</artifactId>
+    <packaging>jar</packaging>
+
+    <name>Apache DeltaSpike CDI OWB-ContainerControl</name>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.deltaspike.cdictrl</groupId>
+            <artifactId>deltaspike-cdictrl-api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.deltaspike.cdictrl</groupId>
+            <artifactId>deltaspike-cdictrl-tck</artifactId>
+            <version>${project.version}</version>
+            <scope>test</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-servlet_2.5_spec</artifactId>
+            <version>1.2</version>
+            <scope>provided</scope>
+        </dependency>
+
+        <!-- OWB specific dependencies-->
+        <dependency>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-atinject_1.0_spec</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-interceptor_1.1_spec</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.openwebbeans</groupId>
+            <artifactId>openwebbeans-impl</artifactId>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.openwebbeans</groupId>
+            <artifactId>openwebbeans-spi</artifactId>
+            <scope>compile</scope>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <artifactId>maven-dependency-plugin</artifactId>
+                <groupId>org.apache.maven.plugins</groupId>
+                <executions>
+                    <execution>
+                        <id>unpack</id>
+                        <phase>process-test-classes</phase>
+                        <goals>
+                            <goal>unpack</goal>
+                        </goals>
+                        <configuration>
+                            <artifactItems>
+                                <artifactItem>
+                                    <groupId>org.apache.deltaspike.cdictrl</groupId>
+                                    <artifactId>deltaspike-cdictrl-tck</artifactId>
+                                    <version>${project.version}</version>
+                                    <outputDirectory>${project.build.directory}/test-classes/</outputDirectory>
+                                </artifactItem>
+                            </artifactItems>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+
+
+
+        </plugins>
+    </build>
+
+</project>

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/fd790135/deltaspike/cdictrl/impl-owb/src/main/java/org/apache/deltaspike/cdise/owb/MockHttpSession.java
----------------------------------------------------------------------
diff --git a/deltaspike/cdictrl/impl-owb/src/main/java/org/apache/deltaspike/cdise/owb/MockHttpSession.java b/deltaspike/cdictrl/impl-owb/src/main/java/org/apache/deltaspike/cdise/owb/MockHttpSession.java
new file mode 100644
index 0000000..195a0df
--- /dev/null
+++ b/deltaspike/cdictrl/impl-owb/src/main/java/org/apache/deltaspike/cdise/owb/MockHttpSession.java
@@ -0,0 +1,112 @@
+/*
+ * 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.owb;
+
+import java.util.Enumeration;
+
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpSession;
+import javax.servlet.http.HttpSessionContext;
+
+/**
+ * A simple mock HttpSession
+ */
+public class MockHttpSession implements HttpSession
+{
+
+    public long getCreationTime()
+    {
+        return 0;
+    }
+
+    public String getId()
+    {
+        return "sessId1";
+    }
+
+    public long getLastAccessedTime()
+    {
+        return 0;
+    }
+
+    public ServletContext getServletContext()
+    {
+        return null;
+    }
+
+    public void setMaxInactiveInterval(int interval)
+    {
+    }
+
+    public int getMaxInactiveInterval()
+    {
+        return 0;
+    }
+
+    public HttpSessionContext getSessionContext()
+    {
+        return null;
+    }
+
+    public Object getAttribute(String name)
+    {
+        return null;
+    }
+
+    public Object getValue(String name)
+    {
+        return null;
+    }
+
+    public Enumeration getAttributeNames()
+    {
+        return null;
+    }
+
+    public String[] getValueNames()
+    {
+        return new String[0];
+    }
+
+    public void setAttribute(String name, Object value)
+    {
+    }
+
+    public void putValue(String name, Object value)
+    {
+    }
+
+    public void removeAttribute(String name)
+    {
+    }
+
+    public void removeValue(String name)
+    {
+    }
+
+    public void invalidate()
+    {
+    }
+
+    public boolean isNew()
+    {
+        return false;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/fd790135/deltaspike/cdictrl/impl-owb/src/main/java/org/apache/deltaspike/cdise/owb/MockServletContext.java
----------------------------------------------------------------------
diff --git a/deltaspike/cdictrl/impl-owb/src/main/java/org/apache/deltaspike/cdise/owb/MockServletContext.java b/deltaspike/cdictrl/impl-owb/src/main/java/org/apache/deltaspike/cdise/owb/MockServletContext.java
new file mode 100644
index 0000000..519b8db
--- /dev/null
+++ b/deltaspike/cdictrl/impl-owb/src/main/java/org/apache/deltaspike/cdise/owb/MockServletContext.java
@@ -0,0 +1,167 @@
+/*
+ * 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.owb;
+
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.Set;
+import java.util.StringTokenizer;
+
+import javax.servlet.RequestDispatcher;
+import javax.servlet.Servlet;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+
+/**
+ * Mock ServletContext needed to startup the container.
+ *
+ */
+public class MockServletContext implements ServletContext
+{
+    private Hashtable attributes = new Hashtable();
+
+    public Object getAttribute(String name)
+    {
+        return attributes.get(name);
+    }
+
+    public Enumeration getAttributeNames()
+    {
+        return attributes.keys();
+    }
+
+    public ServletContext getContext(String uripath)
+    {
+        return this;
+    }
+
+    public String getContextPath()
+    {
+        return "mockContextpath";
+    }
+
+    public String getInitParameter(String name)
+    {
+        return null;
+    }
+
+    public Enumeration getInitParameterNames()
+    {
+        return new StringTokenizer(""); // 'standard' empty Enumeration
+    }
+
+    public int getMajorVersion()
+    {
+        return 2;
+    }
+
+    public String getMimeType(String file)
+    {
+        return null;
+    }
+
+    public int getMinorVersion()
+    {
+        return 0;
+    }
+
+    public RequestDispatcher getNamedDispatcher(String name)
+    {
+        return null;
+    }
+
+    public String getRealPath(String path)
+    {
+        return "mockRealPath";
+    }
+
+    public RequestDispatcher getRequestDispatcher(String path)
+    {
+        return null;
+    }
+
+    public URL getResource(String path) throws MalformedURLException
+    {
+        return null;
+    }
+
+    public InputStream getResourceAsStream(String path)
+    {
+        return null;
+    }
+
+    public Set getResourcePaths(String path)
+    {
+        return null;
+    }
+
+    public String getServerInfo()
+    {
+        return "mockServer";
+    }
+
+    public Servlet getServlet(String name) throws ServletException
+    {
+        return null;
+    }
+
+    public String getServletContextName()
+    {
+        return null;
+    }
+
+    public Enumeration getServletNames()
+    {
+        return null;
+    }
+
+    public Enumeration getServlets()
+    {
+        return null;
+    }
+
+    public void log(String msg)
+    {
+        // TODO
+    }
+
+    public void log(Exception exception, String msg)
+    {
+        // TODO
+    }
+
+    public void log(String message, Throwable throwable)
+    {
+        // TODO
+    }
+
+    public void removeAttribute(String name)
+    {
+        attributes.remove(name);
+    }
+
+    @SuppressWarnings("unchecked")
+    public void setAttribute(String name, Object object)
+    {
+        attributes.put(name, object);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/fd790135/deltaspike/cdictrl/impl-owb/src/main/java/org/apache/deltaspike/cdise/owb/OpenWebBeansContainerControl.java
----------------------------------------------------------------------
diff --git a/deltaspike/cdictrl/impl-owb/src/main/java/org/apache/deltaspike/cdise/owb/OpenWebBeansContainerControl.java b/deltaspike/cdictrl/impl-owb/src/main/java/org/apache/deltaspike/cdise/owb/OpenWebBeansContainerControl.java
new file mode 100644
index 0000000..34fabd6
--- /dev/null
+++ b/deltaspike/cdictrl/impl-owb/src/main/java/org/apache/deltaspike/cdise/owb/OpenWebBeansContainerControl.java
@@ -0,0 +1,87 @@
+/*
+ * 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.owb;
+
+import org.apache.deltaspike.cdise.api.CdiContainer;
+import org.apache.deltaspike.cdise.api.ContextControl;
+import org.apache.webbeans.config.WebBeansContext;
+import org.apache.webbeans.spi.ContainerLifecycle;
+
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.BeanManager;
+import java.util.Set;
+
+/**
+ * OpenWebBeans specific implementation of {@link org.apache.deltaspike.cdise.api.CdiContainer}.
+ */
+public class OpenWebBeansContainerControl implements CdiContainer
+{
+
+    private ContainerLifecycle lifecycle;
+
+    private ContextControl ctxCtrl = null;
+    private Bean<ContextControl> ctxCtrlBean = null;
+    private CreationalContext<ContextControl> ctxCtrlCreationalContext = null;
+
+    @Override
+    public  BeanManager getBeanManager()
+    {
+        return lifecycle.getBeanManager();
+    }
+
+    @Override
+    public synchronized void boot()
+    {
+
+        lifecycle = WebBeansContext.getInstance().getService(ContainerLifecycle.class);
+        lifecycle.startApplication(null);
+    }
+
+    @Override
+    public synchronized void shutdown()
+    {
+        if (ctxCtrl != null)
+        {
+            ctxCtrlBean.destroy(ctxCtrl, ctxCtrlCreationalContext);
+
+        }
+
+        if (lifecycle != null) 
+        {
+            lifecycle.stopApplication(null);
+        }
+    }
+
+    @Override
+    public synchronized ContextControl getContextControl()
+    {
+        if (ctxCtrl == null)
+        {
+            Set<Bean<?>> beans = getBeanManager().getBeans(ContextControl.class);
+            ctxCtrlBean = (Bean<ContextControl>) getBeanManager().resolve(beans);
+            ctxCtrlCreationalContext = getBeanManager().createCreationalContext(ctxCtrlBean);
+            ctxCtrl = (ContextControl)
+                    getBeanManager().getReference(ctxCtrlBean, ContextControl.class, ctxCtrlCreationalContext);
+        }
+        return ctxCtrl;
+    }
+
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/fd790135/deltaspike/cdictrl/impl-owb/src/main/java/org/apache/deltaspike/cdise/owb/OpenWebBeansContextControl.java
----------------------------------------------------------------------
diff --git a/deltaspike/cdictrl/impl-owb/src/main/java/org/apache/deltaspike/cdise/owb/OpenWebBeansContextControl.java b/deltaspike/cdictrl/impl-owb/src/main/java/org/apache/deltaspike/cdise/owb/OpenWebBeansContextControl.java
new file mode 100644
index 0000000..b1bcabe
--- /dev/null
+++ b/deltaspike/cdictrl/impl-owb/src/main/java/org/apache/deltaspike/cdise/owb/OpenWebBeansContextControl.java
@@ -0,0 +1,212 @@
+/*
+ * 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.owb;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.context.ConversationScoped;
+import javax.enterprise.context.Dependent;
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.context.SessionScoped;
+import javax.enterprise.context.spi.Context;
+
+import java.lang.annotation.Annotation;
+import java.util.logging.Logger;
+
+import org.apache.deltaspike.cdise.api.ContextControl;
+import org.apache.webbeans.config.WebBeansContext;
+import org.apache.webbeans.context.ContextFactory;
+import org.apache.webbeans.context.type.ContextTypes;
+
+/**
+ * OWB specific impl of the {@link ContextControl}
+ */
+@Dependent
+public class OpenWebBeansContextControl implements ContextControl
+{
+
+    private static final Logger LOG = Logger.getLogger(OpenWebBeansContextControl.class.getName());
+
+    private MockHttpSession session = new MockHttpSession();;
+    private MockServletContext servletContext  = new MockServletContext();
+
+
+    @Override
+    public void startContexts()
+    {
+        ContextFactory contextFactory = getContextFactory();
+
+        contextFactory.initSingletonContext(servletContext);
+        contextFactory.initApplicationContext(servletContext);
+        contextFactory.initSessionContext(session);
+        contextFactory.initRequestContext(null);
+        contextFactory.initConversationContext(null);
+    }
+
+
+    public void stopContexts()
+    {
+        stopSessionScope();
+        stopConversationScope();
+        stopRequestScope();
+        stopApplicationScope();
+        stopSingletonScope();
+    }
+
+
+
+    @Override
+    public void startContext(Class<? extends Annotation> scopeClass)
+    {
+        if (scopeClass.isAssignableFrom(ApplicationScoped.class))
+        {
+            startApplicationScope();
+        }
+        else if (scopeClass.isAssignableFrom(SessionScoped.class))
+        {
+            startSessionScope();
+        }
+        else if (scopeClass.isAssignableFrom(RequestScoped.class))
+        {
+            startRequestScope();
+        }
+        else if (scopeClass.isAssignableFrom(ConversationScoped.class))
+        {
+            startConversationScope();
+        }
+    }
+
+
+    public void stopContext(Class<? extends Annotation> scopeClass)
+    {
+        if (scopeClass.isAssignableFrom(ApplicationScoped.class))
+        {
+            stopApplicationScope();
+        }
+        else if (scopeClass.isAssignableFrom(SessionScoped.class))
+        {
+            stopSessionScope();
+        }
+        else if (scopeClass.isAssignableFrom(RequestScoped.class))
+        {
+            stopRequestScope();
+        }
+        else if (scopeClass.isAssignableFrom(ConversationScoped.class))
+        {
+            stopConversationScope();
+        }
+    }
+
+    /*
+    * start scopes
+    */
+
+    private void startApplicationScope()
+    {
+        ContextFactory contextFactory = getContextFactory();
+
+        contextFactory.initApplicationContext(servletContext);
+    }
+
+    private void startSessionScope()
+    {
+        ContextFactory contextFactory = getContextFactory();
+
+        contextFactory.initSessionContext(session);
+    }
+
+    private void startRequestScope()
+    {
+        ContextFactory contextFactory = getContextFactory();
+
+        contextFactory.initRequestContext(null);
+    }
+
+    private void startConversationScope()
+    {
+        ContextFactory contextFactory = getContextFactory();
+
+        contextFactory.initConversationContext(null);
+    }
+
+    /*
+     * stop scopes
+     */
+
+    private void stopSingletonScope()
+    {
+        ContextFactory contextFactory = getContextFactory();
+
+        Context context = contextFactory.getStandardContext(ContextTypes.SINGLETON);
+        if (context != null)
+        {
+            contextFactory.destroySingletonContext(servletContext);
+        }
+    }
+
+    private void stopApplicationScope()
+    {
+        ContextFactory contextFactory = getContextFactory();
+
+        Context context = contextFactory.getStandardContext(ContextTypes.APPLICATION);
+        if (context != null)
+        {
+            contextFactory.destroyApplicationContext(servletContext);
+        }
+    }
+
+    private void stopSessionScope()
+    {
+        ContextFactory contextFactory = getContextFactory();
+
+        Context context = contextFactory.getStandardContext(ContextTypes.SESSION);
+        if (context != null)
+        {
+            contextFactory.destroySessionContext(session);
+        }
+    }
+
+    private void stopRequestScope()
+    {
+        ContextFactory contextFactory = getContextFactory();
+
+        Context context = contextFactory.getStandardContext(ContextTypes.REQUEST);
+        if (context != null)
+        {
+            contextFactory.destroyRequestContext(null);
+        }
+    }
+
+    private void stopConversationScope()
+    {
+        ContextFactory contextFactory = getContextFactory();
+
+        Context context = contextFactory.getStandardContext(ContextTypes.CONVERSATION);
+        if (context != null)
+        {
+            contextFactory.destroyConversationContext();
+        }
+    }
+
+    private ContextFactory getContextFactory()
+    {
+        WebBeansContext webBeansContext = WebBeansContext.getInstance();
+        return webBeansContext.getContextFactory();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/fd790135/deltaspike/cdictrl/impl-owb/src/main/resources/META-INF/beans.xml
----------------------------------------------------------------------
diff --git a/deltaspike/cdictrl/impl-owb/src/main/resources/META-INF/beans.xml b/deltaspike/cdictrl/impl-owb/src/main/resources/META-INF/beans.xml
new file mode 100644
index 0000000..4070730
--- /dev/null
+++ b/deltaspike/cdictrl/impl-owb/src/main/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>

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/fd790135/deltaspike/cdictrl/impl-owb/src/main/resources/META-INF/services/org.apache.deltaspike.cdise.api.CdiContainer
----------------------------------------------------------------------
diff --git a/deltaspike/cdictrl/impl-owb/src/main/resources/META-INF/services/org.apache.deltaspike.cdise.api.CdiContainer b/deltaspike/cdictrl/impl-owb/src/main/resources/META-INF/services/org.apache.deltaspike.cdise.api.CdiContainer
new file mode 100644
index 0000000..63fc8cb
--- /dev/null
+++ b/deltaspike/cdictrl/impl-owb/src/main/resources/META-INF/services/org.apache.deltaspike.cdise.api.CdiContainer
@@ -0,0 +1,20 @@
+#####################################################################################
+# 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.
+#####################################################################################
+
+org.apache.deltaspike.cdise.owb.OpenWebBeansContainerControl

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/fd790135/deltaspike/cdictrl/impl-weld/pom.xml
----------------------------------------------------------------------
diff --git a/deltaspike/cdictrl/impl-weld/pom.xml b/deltaspike/cdictrl/impl-weld/pom.xml
new file mode 100644
index 0000000..12daa2f
--- /dev/null
+++ b/deltaspike/cdictrl/impl-weld/pom.xml
@@ -0,0 +1,105 @@
+<?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.
+    -->
+
+<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>0.2-incubating-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+
+    <artifactId>deltaspike-cdictrl-weld</artifactId>
+    <packaging>jar</packaging>
+
+    <name>Apache DeltaSpike CDI Weld-ContainerControl</name>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.deltaspike.cdictrl</groupId>
+            <artifactId>deltaspike-cdictrl-api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.deltaspike.cdictrl</groupId>
+            <artifactId>deltaspike-cdictrl-tck</artifactId>
+            <version>${project.version}</version>
+            <scope>test</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-servlet_2.5_spec</artifactId>
+            <version>1.2</version>
+            <scope>provided</scope>
+        </dependency>
+
+        <!-- OWB specific dependencies-->
+        <dependency>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-atinject_1.0_spec</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-interceptor_1.1_spec</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.jboss.weld.se</groupId>
+            <artifactId>weld-se</artifactId>
+            <version>${weld.version}</version>
+            <scope>provided</scope>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <artifactId>maven-dependency-plugin</artifactId>
+                <groupId>org.apache.maven.plugins</groupId>
+                <executions>
+                    <execution>
+                        <id>unpack</id>
+                        <phase>process-test-classes</phase>
+                        <goals>
+                            <goal>unpack</goal>
+                        </goals>
+                        <configuration>
+                            <artifactItems>
+                                <artifactItem>
+                                    <groupId>org.apache.deltaspike.cdictrl</groupId>
+                                    <artifactId>deltaspike-cdictrl-tck</artifactId>
+                                    <version>${project.version}</version>
+                                    <outputDirectory>${project.build.directory}/test-classes/</outputDirectory>
+                                </artifactItem>
+                            </artifactItems>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+</project>

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/fd790135/deltaspike/cdictrl/impl-weld/src/main/java/org/apache/deltaspike/cdise/weld/ContextController.java
----------------------------------------------------------------------
diff --git a/deltaspike/cdictrl/impl-weld/src/main/java/org/apache/deltaspike/cdise/weld/ContextController.java b/deltaspike/cdictrl/impl-weld/src/main/java/org/apache/deltaspike/cdise/weld/ContextController.java
new file mode 100644
index 0000000..26b3ade
--- /dev/null
+++ b/deltaspike/cdictrl/impl-weld/src/main/java/org/apache/deltaspike/cdise/weld/ContextController.java
@@ -0,0 +1,261 @@
+/*
+ * 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.weld;
+
+import org.jboss.weld.context.ApplicationContext;
+import org.jboss.weld.context.api.ContextualInstance;
+import org.jboss.weld.context.beanstore.BeanStore;
+import org.jboss.weld.context.bound.BoundConversationContext;
+import org.jboss.weld.context.bound.BoundRequestContext;
+import org.jboss.weld.context.bound.BoundSessionContext;
+import org.jboss.weld.context.bound.MutableBoundRequest;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.context.SessionScoped;
+import javax.enterprise.inject.Typed;
+import javax.inject.Inject;
+import javax.inject.Singleton;
+import java.lang.reflect.Field;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * Weld specific controller for all supported context implementations
+ */
+@Typed()
+public class ContextController
+{
+    @Inject
+    private ApplicationContext applicationContext;
+
+    @Inject
+    private BoundSessionContext sessionContext;
+
+    @Inject
+    private BoundRequestContext requestContext;
+
+    @Inject
+    private BoundConversationContext conversationContext;
+
+    private Map<String, Object> sessionMap;
+
+    private Map<String, Object> requestMap;
+
+    private boolean applicationScopeStarted;
+
+    private boolean singletonScopeStarted;
+
+    private Boolean resetSuccessful;
+
+    //X TODO check if we can remove it
+    void startApplicationScope()
+    {
+        if (this.applicationScopeStarted)
+        {
+            throw new IllegalStateException(ApplicationScoped.class.getName() + " started already");
+        }
+        this.applicationScopeStarted = true;
+    }
+
+    void stopApplicationScope()
+    {
+        if (Boolean.FALSE.equals(this.resetSuccessful) /*|| TODO detect weld 2.x+*/)
+        {
+            if (applicationContext.isActive())
+            {
+                applicationContext.invalidate();
+                this.applicationScopeStarted = false;
+            }
+            return;
+        }
+
+        if (applicationContext.isActive())
+        {
+            //workaround for weld 1.x (see WELD-1072)
+            org.jboss.weld.bootstrap.api.Singleton<BeanStore> beanStoreHolder = null;
+            BeanStore originalBeanStore = null;
+            try
+            {
+                Field field = this.applicationContext.getClass().getSuperclass().getDeclaredField("beanStore");
+                field.setAccessible(true);
+                beanStoreHolder = (org.jboss.weld.bootstrap.api.Singleton)field.get(this.applicationContext);
+                final BeanStore beanStore = beanStoreHolder.get();
+                originalBeanStore = beanStore;
+
+                beanStoreHolder.set(new BeanStore()
+                {
+                    @Override
+                    public <T> ContextualInstance<T> get(String id)
+                    {
+                        return beanStore.get(id);
+                    }
+
+                    @Override
+                    public boolean contains(String id)
+                    {
+                        return beanStore.contains(id);
+                    }
+
+                    @Override
+                    public void clear()
+                    {
+                        //do nothing
+                    }
+
+                    @Override
+                    public Iterator<String> iterator()
+                    {
+                        return beanStore.iterator();
+                    }
+
+                    @Override
+                    public <T> void put(String id, ContextualInstance<T> contextualInstance)
+                    {
+                        beanStore.put(id, contextualInstance);
+                    }
+                });
+            }
+            catch (Exception e)
+            {
+                //do nothing
+                this.resetSuccessful = false;
+            }
+            catch (LinkageError e)
+            {
+                //do nothing - a new version of weld is used which introduced other required dependencies.
+                //WELD-1072 should be fixed in this version already
+                this.resetSuccessful = false;
+            }
+
+            applicationContext.invalidate();
+
+            if (beanStoreHolder != null)
+            {
+                Iterator<String> idIterator = originalBeanStore.iterator();
+
+                String currentId;
+                ContextualInstance<Object> currentContextualInstance;
+                while (idIterator.hasNext())
+                {
+                    currentId = idIterator.next();
+                    currentContextualInstance = originalBeanStore.get(currentId);
+
+                    //keep (weld) internal application scoped beans - TODO check possible side-effects
+                    if (currentContextualInstance.getInstance().getClass().getName().startsWith("org.jboss."))
+                    {
+                        //internalBeanList.add(currentContextualInstance);
+                        continue;
+                    }
+                    idIterator.remove();
+                }
+
+                beanStoreHolder.set(originalBeanStore);
+            }
+
+            this.applicationScopeStarted = false;
+
+            this.resetSuccessful = true;
+        }
+    }
+
+    //X TODO check if we can remove it
+    void startSingletonScope()
+    {
+        if (this.singletonScopeStarted)
+        {
+            throw new IllegalStateException(Singleton.class.getName() + " started already");
+        }
+        this.singletonScopeStarted = true;
+    }
+
+    void stopSingletonScope()
+    {
+        this.singletonScopeStarted = false;
+    }
+
+    void startSessionScope()
+    {
+        if (this.sessionMap == null)
+        {
+            this.sessionMap = new HashMap<String, Object>();
+        }
+        else
+        {
+            throw new IllegalStateException(SessionScoped.class.getName() + " started already");
+        }
+
+        this.sessionContext.associate(this.sessionMap);
+        this.sessionContext.activate();
+    }
+
+    void stopSessionScope()
+    {
+        if (this.sessionContext.isActive())
+        {
+            this.sessionContext.invalidate();
+            this.sessionContext.deactivate();
+            this.sessionContext.dissociate(this.sessionMap);
+            this.sessionMap = null;
+        }
+    }
+
+    void startConversationScope(String cid)
+    {
+        this.conversationContext.associate(new MutableBoundRequest(this.requestMap, this.sessionMap));
+        this.conversationContext.activate(cid);
+    }
+
+    void stopConversationScope()
+    {
+        if (conversationContext.isActive())
+        {
+            this.conversationContext.invalidate();
+            this.conversationContext.deactivate();
+            this.conversationContext.dissociate(new MutableBoundRequest(this.requestMap, this.sessionMap));
+        }
+    }
+
+    void startRequestScope()
+    {
+        if (this.requestMap == null)
+        {
+            this.requestMap = new HashMap<String, Object>();
+        }
+        else
+        {
+            throw new IllegalStateException(RequestScoped.class.getName() + " started already");
+        }
+
+        this.requestContext.associate(this.requestMap);
+        this.requestContext.activate();
+    }
+
+    void stopRequestScope()
+    {
+        if (this.requestContext.isActive())
+        {
+            this.requestContext.invalidate();
+            this.requestContext.deactivate();
+            this.requestContext.dissociate(this.requestMap);
+            this.requestMap = null;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/fd790135/deltaspike/cdictrl/impl-weld/src/main/java/org/apache/deltaspike/cdise/weld/WeldContainerControl.java
----------------------------------------------------------------------
diff --git a/deltaspike/cdictrl/impl-weld/src/main/java/org/apache/deltaspike/cdise/weld/WeldContainerControl.java b/deltaspike/cdictrl/impl-weld/src/main/java/org/apache/deltaspike/cdise/weld/WeldContainerControl.java
new file mode 100644
index 0000000..3c12f8f
--- /dev/null
+++ b/deltaspike/cdictrl/impl-weld/src/main/java/org/apache/deltaspike/cdise/weld/WeldContainerControl.java
@@ -0,0 +1,78 @@
+/*
+ * 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.weld;
+
+import org.apache.deltaspike.cdise.api.CdiContainer;
+import org.apache.deltaspike.cdise.api.ContextControl;
+import org.jboss.weld.environment.se.Weld;
+import org.jboss.weld.environment.se.WeldContainer;
+
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.BeanManager;
+import java.util.Set;
+
+/**
+ * Weld specific implementation of {@link org.apache.deltaspike.cdise.api.CdiContainer}.
+ */
+@SuppressWarnings("UnusedDeclaration")
+public class WeldContainerControl implements CdiContainer
+{
+    private Weld weld;
+    private WeldContainer weldContainer;
+
+    private ContextControl ctxCtrl = null;
+    private Bean<ContextControl> ctxCtrlBean = null;
+    private CreationalContext<ContextControl> ctxCtrlCreationalContext = null;
+
+
+    @Override
+    public BeanManager getBeanManager()
+    {
+        return this.weldContainer.getBeanManager();
+    }
+
+
+    @Override
+    public void boot()
+    {
+        this.weld = new Weld();
+        this.weldContainer = weld.initialize();
+    }
+
+    @Override
+    public void shutdown()
+    {
+        this.weld.shutdown();
+    }
+
+    @Override
+    public ContextControl getContextControl()
+    {
+        if (ctxCtrl == null)
+        {
+            Set<Bean<?>> beans = getBeanManager().getBeans(ContextControl.class);
+            ctxCtrlBean = (Bean<ContextControl>) getBeanManager().resolve(beans);
+            ctxCtrlCreationalContext = getBeanManager().createCreationalContext(ctxCtrlBean);
+            ctxCtrl = (ContextControl)
+                    getBeanManager().getReference(ctxCtrlBean, ContextControl.class, ctxCtrlCreationalContext);
+        }
+        return ctxCtrl;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/fd790135/deltaspike/cdictrl/impl-weld/src/main/java/org/apache/deltaspike/cdise/weld/WeldContextControl.java
----------------------------------------------------------------------
diff --git a/deltaspike/cdictrl/impl-weld/src/main/java/org/apache/deltaspike/cdise/weld/WeldContextControl.java b/deltaspike/cdictrl/impl-weld/src/main/java/org/apache/deltaspike/cdise/weld/WeldContextControl.java
new file mode 100644
index 0000000..4dca925
--- /dev/null
+++ b/deltaspike/cdictrl/impl-weld/src/main/java/org/apache/deltaspike/cdise/weld/WeldContextControl.java
@@ -0,0 +1,253 @@
+/*
+ * 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.weld;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.context.ConversationScoped;
+import javax.enterprise.context.Dependent;
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.context.SessionScoped;
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.AnnotatedType;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.inject.spi.InjectionTarget;
+import javax.inject.Inject;
+import javax.inject.Singleton;
+import java.lang.annotation.Annotation;
+
+import org.apache.deltaspike.cdise.api.ContextControl;
+
+/**
+ * Weld specific impl of the {@link org.apache.deltaspike.cdise.api.ContextControl}
+ */
+@Dependent
+public class WeldContextControl implements ContextControl
+{
+    private ContextController contextController;
+
+    @Inject
+    private BeanManager beanManager;
+
+    @Override
+    public void startContexts()
+    {
+        startApplicationScope();
+        startSessionScope();
+        startRequestScope();
+        startConversationScope();
+    }
+
+    @Override
+    public void startContext(Class<? extends Annotation> scopeClass)
+    {
+        if (scopeClass.isAssignableFrom(ApplicationScoped.class))
+        {
+            startApplicationScope();
+        }
+        else if (scopeClass.isAssignableFrom(SessionScoped.class))
+        {
+            startSessionScope();
+        }
+        else if (scopeClass.isAssignableFrom(RequestScoped.class))
+        {
+            startRequestScope();
+        }
+        else if (scopeClass.isAssignableFrom(ConversationScoped.class))
+        {
+            startConversationScope();
+        }
+    }
+
+    /**
+     * Currently we can't stop the {@link ApplicationScoped} due to WELD-1072
+     *
+     * {@inheritDoc}
+     */
+    @Override
+    public void stopContexts()
+    {
+        stopConversationScope();
+        stopRequestScope();
+        stopSessionScope();
+        stopApplicationScope(); //can't be done because of WELD-1072
+        stopSingletonScope();
+    }
+
+    @Override
+    public void stopContext(Class<? extends Annotation> scopeClass)
+    {
+        if (scopeClass.isAssignableFrom(ApplicationScoped.class))
+        {
+            stopApplicationScope();
+        }
+        else if (scopeClass.isAssignableFrom(SessionScoped.class))
+        {
+            stopSessionScope();
+        }
+        else if (scopeClass.isAssignableFrom(RequestScoped.class))
+        {
+            stopRequestScope();
+        }
+        else if (scopeClass.isAssignableFrom(ConversationScoped.class))
+        {
+            stopConversationScope();
+        }
+        else if (scopeClass.isAssignableFrom(Singleton.class))
+        {
+            stopSingletonScope();
+        }
+    }
+
+    /*
+     * start scopes
+     */
+    private void startApplicationScope()
+    {
+        try
+        {
+            getContextController().startApplicationScope();
+        }
+        catch (IllegalStateException ise)
+        {
+            // weld throws an ISE if the context was already started...
+        }
+    }
+
+    private void startSessionScope()
+    {
+        try
+        {
+            getContextController().startSessionScope();
+        }
+        catch (IllegalStateException ise)
+        {
+            // weld throws an ISE if the context was already started...
+        }
+    }
+
+    private void startConversationScope()
+    {
+        try
+        {
+            getContextController().startConversationScope(null);
+        }
+        catch (IllegalStateException ise)
+        {
+            // weld throws an ISE if the context was already started...
+        }
+    }
+
+    private void startRequestScope()
+    {
+        try
+        {
+            getContextController().startRequestScope();
+        }
+        catch (IllegalStateException ise)
+        {
+            // weld throws an ISE if the context was already started...
+        }
+    }
+
+    /*
+     * stop scopes
+     */
+
+    private void stopApplicationScope()
+    {
+        try
+        {
+            getContextController().stopApplicationScope();
+        }
+        catch (IllegalStateException ise)
+        {
+            // weld throws an ISE if the context was already stopped...
+        }
+    }
+
+    private void stopSessionScope()
+    {
+        try
+        {
+            getContextController().stopSessionScope();
+        }
+        catch (IllegalStateException ise)
+        {
+            // weld throws an ISE if the context was already stopped...
+        }
+    }
+
+    private void stopConversationScope()
+    {
+        try
+        {
+            getContextController().stopConversationScope();
+        }
+        catch (IllegalStateException ise)
+        {
+            // weld throws an ISE if the context was already stopped...
+        }
+    }
+
+    private void stopRequestScope()
+    {
+        try
+        {
+            getContextController().stopRequestScope();
+        }
+        catch (IllegalStateException ise)
+        {
+            // weld throws an ISE if the context was already stopped...
+        }
+    }
+
+    private void stopSingletonScope()
+    {
+        try
+        {
+            getContextController().stopSingletonScope();
+        }
+        catch (IllegalStateException ise)
+        {
+            // weld throws an ISE if the context was already stopped...
+        }
+    }
+
+    private ContextController getContextController()
+    {
+        if (this.contextController != null)
+        {
+            return this.contextController;
+        }
+
+        this.contextController = new ContextController();
+        return tryToInjectFields(this.contextController);
+    }
+
+    private <T> T tryToInjectFields(T instance)
+    {
+        CreationalContext creationalContext = beanManager.createCreationalContext(null);
+
+        AnnotatedType annotatedType = beanManager.createAnnotatedType(instance.getClass());
+        InjectionTarget injectionTarget = beanManager.createInjectionTarget(annotatedType);
+        injectionTarget.inject(instance, creationalContext);
+        return instance;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/fd790135/deltaspike/cdictrl/impl-weld/src/main/resources/META-INF/beans.xml
----------------------------------------------------------------------
diff --git a/deltaspike/cdictrl/impl-weld/src/main/resources/META-INF/beans.xml b/deltaspike/cdictrl/impl-weld/src/main/resources/META-INF/beans.xml
new file mode 100644
index 0000000..4070730
--- /dev/null
+++ b/deltaspike/cdictrl/impl-weld/src/main/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>

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/fd790135/deltaspike/cdictrl/impl-weld/src/main/resources/META-INF/services/org.apache.deltaspike.cdise.api.CdiContainer
----------------------------------------------------------------------
diff --git a/deltaspike/cdictrl/impl-weld/src/main/resources/META-INF/services/org.apache.deltaspike.cdise.api.CdiContainer b/deltaspike/cdictrl/impl-weld/src/main/resources/META-INF/services/org.apache.deltaspike.cdise.api.CdiContainer
new file mode 100644
index 0000000..201cfcc
--- /dev/null
+++ b/deltaspike/cdictrl/impl-weld/src/main/resources/META-INF/services/org.apache.deltaspike.cdise.api.CdiContainer
@@ -0,0 +1,20 @@
+#####################################################################################
+# 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.
+#####################################################################################
+
+org.apache.deltaspike.cdise.weld.WeldContainerControl

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/fd790135/deltaspike/cdictrl/pom.xml
----------------------------------------------------------------------
diff --git a/deltaspike/cdictrl/pom.xml b/deltaspike/cdictrl/pom.xml
new file mode 100644
index 0000000..b4b2e62
--- /dev/null
+++ b/deltaspike/cdictrl/pom.xml
@@ -0,0 +1,42 @@
+<?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.
+-->
+<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</groupId>
+        <artifactId>parent</artifactId>
+        <version>0.2-incubating-SNAPSHOT</version>
+        <relativePath>../parent/pom.xml</relativePath>
+    </parent>
+
+    <groupId>org.apache.deltaspike.cdictrl</groupId>
+    <artifactId>cdictrl-project</artifactId>
+    <packaging>pom</packaging>
+
+    <name>Apache DeltaSpike ContainerControl parent</name>
+
+    <modules>
+        <module>api</module>
+        <module>tck</module>
+        <module>impl-owb</module>
+        <module>impl-weld</module>
+    </modules>
+</project>

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/fd790135/deltaspike/cdictrl/tck/pom.xml
----------------------------------------------------------------------
diff --git a/deltaspike/cdictrl/tck/pom.xml b/deltaspike/cdictrl/tck/pom.xml
new file mode 100644
index 0000000..aa134c5
--- /dev/null
+++ b/deltaspike/cdictrl/tck/pom.xml
@@ -0,0 +1,188 @@
+<?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.
+-->
+
+<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>0.2-incubating-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+
+    <artifactId>deltaspike-cdictrl-tck</artifactId>
+    <packaging>jar</packaging>
+
+    <name>Apache DeltaSpike CDI ContainerControl TCK</name>
+
+    <description>
+        The TCK for testing ContainerControl implementations
+    </description>
+
+    <dependencies>
+        <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.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-interceptor_1.1_spec</artifactId>
+            <optional>true</optional>
+        </dependency>
+
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>compile</scope>
+            <optional>true</optional>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.deltaspike.cdictrl</groupId>
+            <artifactId>deltaspike-cdictrl-api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+    </dependencies>
+
+    <!-- profiles for executing the tck directly in the ide -->
+    <profiles>
+        <profile>
+            <!-- activate this profile in the ide to execute the tck with owb directly in the ide -->
+            <id>ide-owb</id>
+            <dependencies>
+                <dependency>
+                    <groupId>org.apache.geronimo.specs</groupId>
+                    <artifactId>geronimo-jcdi_1.0_spec</artifactId>
+                    <scope>compile</scope>
+                </dependency>
+
+                <dependency>
+                    <groupId>org.apache.geronimo.specs</groupId>
+                    <artifactId>geronimo-atinject_1.0_spec</artifactId>
+                    <scope>compile</scope>
+                </dependency>
+
+                <dependency>
+                    <groupId>org.apache.geronimo.specs</groupId>
+                    <artifactId>geronimo-interceptor_1.1_spec</artifactId>
+                    <scope>compile</scope>
+                </dependency>
+
+                <dependency>
+                    <groupId>org.apache.geronimo.specs</groupId>
+                    <artifactId>geronimo-servlet_2.5_spec</artifactId>
+                    <scope>compile</scope>
+                </dependency>
+
+                <dependency>
+                    <groupId>junit</groupId>
+                    <artifactId>junit</artifactId>
+                    <scope>compile</scope>
+                </dependency>
+
+                <dependency>
+                    <groupId>org.apache.deltaspike.cdictrl</groupId>
+                    <artifactId>deltaspike-cdictrl-api</artifactId>
+                    <scope>compile</scope>
+                </dependency>
+
+                <dependency>
+                    <groupId>org.apache.deltaspike.cdictrl</groupId>
+                    <artifactId>deltaspike-cdictrl-owb</artifactId>
+                </dependency>
+
+                <!-- OWB specific dependencies-->
+                <dependency>
+                    <groupId>org.apache.openwebbeans</groupId>
+                    <artifactId>openwebbeans-impl</artifactId>
+                    <scope>runtime</scope>
+                </dependency>
+
+                <dependency>
+                    <groupId>org.apache.openwebbeans</groupId>
+                    <artifactId>openwebbeans-spi</artifactId>
+                    <scope>runtime</scope>
+                </dependency>
+            </dependencies>
+        </profile>
+
+        <profile>
+            <!-- activate this profile in the ide to execute the tck with weld directly in the ide -->
+            <id>ide-weld</id>
+            <dependencies>
+                <dependency>
+                    <groupId>org.apache.geronimo.specs</groupId>
+                    <artifactId>geronimo-jcdi_1.0_spec</artifactId>
+                    <scope>compile</scope>
+                </dependency>
+
+                <dependency>
+                    <groupId>org.apache.geronimo.specs</groupId>
+                    <artifactId>geronimo-atinject_1.0_spec</artifactId>
+                    <scope>compile</scope>
+                </dependency>
+
+                <dependency>
+                    <groupId>org.apache.geronimo.specs</groupId>
+                    <artifactId>geronimo-interceptor_1.1_spec</artifactId>
+                    <scope>compile</scope>
+                </dependency>
+
+                <!--dependency>
+                    <groupId>org.apache.geronimo.specs</groupId>
+                    <artifactId>geronimo-servlet_2.5_spec</artifactId>
+                    <scope>compile</scope>
+                </dependency-->
+
+                <dependency>
+                    <groupId>junit</groupId>
+                    <artifactId>junit</artifactId>
+                    <scope>compile</scope>
+                </dependency>
+
+                <dependency>
+                    <groupId>org.apache.deltaspike.cdictrl</groupId>
+                    <artifactId>deltaspike-cdictrl-api</artifactId>
+                    <scope>compile</scope>
+                </dependency>
+
+                <dependency>
+                    <groupId>org.apache.deltaspike.cdictrl</groupId>
+                    <artifactId>deltaspike-cdictrl-weld</artifactId>
+                </dependency>
+
+                <dependency>
+                    <groupId>org.jboss.weld.se</groupId>
+                    <artifactId>weld-se</artifactId>
+                    <version>${weld.version}</version>
+                    <scope>runtime</scope>
+                </dependency>
+            </dependencies>
+        </profile>
+    </profiles>
+</project>

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/fd790135/deltaspike/cdictrl/tck/src/main/java/org/apache/deltaspike/cdise/tck/ContainerCtrlTckTest.java
----------------------------------------------------------------------
diff --git a/deltaspike/cdictrl/tck/src/main/java/org/apache/deltaspike/cdise/tck/ContainerCtrlTckTest.java b/deltaspike/cdictrl/tck/src/main/java/org/apache/deltaspike/cdise/tck/ContainerCtrlTckTest.java
new file mode 100644
index 0000000..e37c5de
--- /dev/null
+++ b/deltaspike/cdictrl/tck/src/main/java/org/apache/deltaspike/cdise/tck/ContainerCtrlTckTest.java
@@ -0,0 +1,179 @@
+/*
+ * 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.tck;
+
+
+import org.apache.deltaspike.cdise.api.CdiContainer;
+import org.apache.deltaspike.cdise.api.CdiContainerLoader;
+import org.apache.deltaspike.cdise.tck.beans.Car;
+import org.apache.deltaspike.cdise.tck.beans.CarRepair;
+import org.junit.Assert;
+import org.junit.Test;
+
+import javax.enterprise.context.ContextNotActiveException;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.BeanManager;
+import java.util.Set;
+
+/**
+ * TCK test for the {@link org.apache.deltaspike.cdise.api.CdiContainer}
+ */
+public class ContainerCtrlTckTest
+{
+    @Test
+    public void testContainerBoot()
+    {
+        CdiContainer cc = CdiContainerLoader.getCdiContainer();
+        Assert.assertNotNull(cc);
+
+        cc.boot();
+        cc.getContextControl().startContexts();
+
+        BeanManager bm = cc.getBeanManager();
+        Assert.assertNotNull(bm);
+        
+        Set<Bean<?>> beans = bm.getBeans(CarRepair.class);
+        Bean<?> bean = bm.resolve(beans);
+        
+        CarRepair carRepair = (CarRepair) bm.getReference(bean, CarRepair.class, bm.createCreationalContext(bean));
+        Assert.assertNotNull(carRepair);
+
+        Assert.assertNotNull(carRepair.getCar());
+        Assert.assertNotNull(carRepair.getCar().getUsr());
+
+        cc.shutdown();
+    }
+
+    @Test
+    public void testSimpleContainerBoot()
+    {
+        CdiContainer cc = CdiContainerLoader.getCdiContainer();
+        Assert.assertNotNull(cc);
+
+        cc.boot();
+        cc.getContextControl().startContexts();
+
+        BeanManager bm = cc.getBeanManager();
+        Assert.assertNotNull(bm);
+
+        Set<Bean<?>> beans = bm.getBeans(CarRepair.class);
+        Bean<?> bean = bm.resolve(beans);
+
+        CarRepair carRepair = (CarRepair) bm.getReference(bean, CarRepair.class, bm.createCreationalContext(bean));
+        Assert.assertNotNull(carRepair);
+
+        Assert.assertNotNull(carRepair.getCar());
+        Assert.assertNotNull(carRepair.getCar().getUsr());
+
+        cc.shutdown();
+    }
+
+    /**
+     * Stops and starts: application-, session- and request-scope.
+     * <p/>
+     * application-scoped instance has a ref to
+     * request-scoped instance which has a ref to
+     * session-scoped instance.
+     * <p/>
+     * If the deepest ref has the expected value, all levels in between were resetted correctly.
+     */
+    @Test
+    public void testRestartContexts()
+    {
+        CdiContainer cdiContainer = CdiContainerLoader.getCdiContainer();
+        Assert.assertNotNull(cdiContainer);
+
+        cdiContainer.boot();
+        cdiContainer.getContextControl().startContexts();
+
+        BeanManager beanManager = cdiContainer.getBeanManager();
+        Assert.assertNotNull(beanManager);
+
+        Set<Bean<?>> beans = beanManager.getBeans(CarRepair.class);
+        Bean<?> bean = beanManager.resolve(beans);
+
+        CarRepair carRepair = (CarRepair)
+            beanManager.getReference(bean, CarRepair.class, beanManager.createCreationalContext(bean));
+
+        Assert.assertNotNull(carRepair);
+
+        Car car = carRepair.getCar();
+
+        Assert.assertNotNull(car);
+        Assert.assertNotNull(car.getUsr());
+
+
+        carRepair.getCar().getUsr().setName("tester");
+        Assert.assertEquals("tester", car.getUsr().getName());
+
+        cdiContainer.getContextControl().stopContexts();
+
+        try
+        {
+            Assert.assertNotNull(car.getUsr());
+
+            // accessing the car should have triggered a ContextNotActiveException
+            Assert.fail();
+        }
+        catch (ContextNotActiveException e)
+        {
+            //do nothing - exception expected
+        }
+
+        cdiContainer.getContextControl().startContexts();
+
+        carRepair = (CarRepair)
+            beanManager.getReference(bean, CarRepair.class, beanManager.createCreationalContext(bean));
+
+        Assert.assertNotNull(carRepair.getCar());
+        Assert.assertNotNull(carRepair.getCar().getUsr());
+        Assert.assertNull(carRepair.getCar().getUsr().getName());
+
+        cdiContainer.shutdown();
+    }
+
+    @Test
+    public void testShutdownWithInactiveContexts()
+    {
+        CdiContainer cdiContainer = CdiContainerLoader.getCdiContainer();
+        Assert.assertNotNull(cdiContainer);
+
+        cdiContainer.boot();
+        cdiContainer.getContextControl().startContexts();
+
+        // now do some randmo stuff
+        BeanManager beanManager = cdiContainer.getBeanManager();
+        Assert.assertNotNull(beanManager);
+
+        Set<Bean<?>> beans = beanManager.getBeans(CarRepair.class);
+        Bean<?> bean = beanManager.resolve(beans);
+
+        CarRepair carRepair = (CarRepair)
+                beanManager.getReference(bean, CarRepair.class, beanManager.createCreationalContext(bean));
+
+        Assert.assertNotNull(carRepair);
+
+        Car car = carRepair.getCar();
+        Assert.assertNotNull(car);
+
+        cdiContainer.getContextControl().startContexts();
+
+        cdiContainer.shutdown();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/fd790135/deltaspike/cdictrl/tck/src/main/java/org/apache/deltaspike/cdise/tck/beans/Car.java
----------------------------------------------------------------------
diff --git a/deltaspike/cdictrl/tck/src/main/java/org/apache/deltaspike/cdise/tck/beans/Car.java b/deltaspike/cdictrl/tck/src/main/java/org/apache/deltaspike/cdise/tck/beans/Car.java
new file mode 100644
index 0000000..8367572
--- /dev/null
+++ b/deltaspike/cdictrl/tck/src/main/java/org/apache/deltaspike/cdise/tck/beans/Car.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.tck.beans;
+
+
+import javax.enterprise.context.RequestScoped;
+import javax.inject.Inject;
+
+@RequestScoped
+public class Car
+{
+    @Inject
+    private User usr;
+
+    public User getUsr()
+    {
+        return usr;
+    }
+
+    public void setUsr(User usr)
+    {
+        this.usr = usr;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/fd790135/deltaspike/cdictrl/tck/src/main/java/org/apache/deltaspike/cdise/tck/beans/CarRepair.java
----------------------------------------------------------------------
diff --git a/deltaspike/cdictrl/tck/src/main/java/org/apache/deltaspike/cdise/tck/beans/CarRepair.java b/deltaspike/cdictrl/tck/src/main/java/org/apache/deltaspike/cdise/tck/beans/CarRepair.java
new file mode 100644
index 0000000..beec2f5
--- /dev/null
+++ b/deltaspike/cdictrl/tck/src/main/java/org/apache/deltaspike/cdise/tck/beans/CarRepair.java
@@ -0,0 +1,39 @@
+/*
+ * 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.tck.beans;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Inject;
+
+@ApplicationScoped
+public class CarRepair
+{
+    @Inject
+    private Car car;
+
+    public Car getCar()
+    {
+        return car;
+    }
+
+    public void setCar(Car car)
+    {
+        this.car = car;
+    }
+}