Clone URL (Committers only):
https://cms.apache.org/redirect?new=anonymous;action=diff;uri=http://deltaspike.apache.org/container-control.mdtext

Karl Kildén

Index: trunk/content/container-control.mdtext
===================================================================
--- trunk/content/container-control.mdtext      (revision 1588841)
+++ trunk/content/container-control.mdtext      (working copy)
@@ -28,9 +28,26 @@
   - The **ContextControl** interface allows to control the life-cycle of the 
built-in contexts of the CDI container.
 
 ## CdiContainer
+You can use the CdiContainerLoader as a simple factory to gain access to the 
underlying CdiContainer implementation. This is of little interest for Java EE 
applications since the CDI Container 
+already gets properly booted and shut down by the Servlet container 
integration.
+    
 
-See the Java SE part [above](#start-a-cdi-container-using-java-se).
+    :::java
+    // this will give you a CdiContainer for Weld or OWB, depending on the jar 
you added
+    CdiContainer cdiContainer = CdiContainerLoader.getCdiContainer();
 
+    // now we gonna boot the CDI container. This will trigger the classpath 
scan, etc
+       cdiContainer.boot();
+
+    // and finally we like to start all built-in contexts
+    cdiContainer.getContextControl().startContexts();
+
+    // now we can use CDI in our SE application.
+    // And there is not a single line of OWB or Weld specific code in your 
project!
+
+    // finally we gonna stop the container
+    cdiContainer.shutdown();
+
 ## ContextControl usage
 
 The `ContextControl` interface allows you to start and stop built-in standard 
Contexts like `@RequestScoped`, `@ConversationScoped`, `@SessionScoped`, etc. 
It is provided as `@Dependent` bean and can get injected in the classic CDI 
way. This is not only usable in Java SE projects but also very helpful in 
Servlets and Java EE containers.

Reply via email to