deltaspike-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From johndam...@apache.org
Subject svn commit: r1616770 - in /deltaspike/site/trunk: content/container-control.mdtext content/documentation.mdtext deltaspike-site-project.iml pom.xml
Date Fri, 08 Aug 2014 14:18:48 GMT
Author: johndament
Date: Fri Aug  8 14:18:48 2014
New Revision: 1616770

URL: http://svn.apache.org/r1616770
Log:
Added docs for Servlet embedded mode.

Added:
    deltaspike/site/trunk/deltaspike-site-project.iml
Modified:
    deltaspike/site/trunk/content/container-control.mdtext
    deltaspike/site/trunk/content/documentation.mdtext
    deltaspike/site/trunk/pom.xml

Modified: deltaspike/site/trunk/content/container-control.mdtext
URL: http://svn.apache.org/viewvc/deltaspike/site/trunk/content/container-control.mdtext?rev=1616770&r1=1616769&r2=1616770&view=diff
==============================================================================
--- deltaspike/site/trunk/content/container-control.mdtext (original)
+++ deltaspike/site/trunk/content/container-control.mdtext Fri Aug  8 14:18:48 2014
@@ -104,4 +104,65 @@ Controlling the request-context for a Qu
                 ctxCtrl.stopContext(RequestScoped.class);
             }
         }
-    }
\ No newline at end of file
+    }
+
+## Embedded Servlet Support
+
+Starting with 1.0.2, you can use DeltaSpike to power embedded Servlet runtimes.  This work
is done via Servlet Listeners.  The configuration is specific to each container, below are
some examples.
+
+The two main listeners are `CdiServletRequestListener` and `CdiServletContextListener`. 
`CdiServletRequestListener` is responsible for starting a `RequestContext` on each incoming
request.  In most containers this is all you need.  For Tomcat specifically, you need to use
`CdiServletContextListener` which registers the `CdiServletRequestListener`.
+
+The main usecase for this feature is for lightweight embedded runtimes, microservices.  For
each of these, it is assumed that you are using the following start up code somewhere:
+
+    :::java
+        CdiContainer cdiContainer = CdiContainerLoader.getCdiContainer();
+        cdiContainer.boot();
+        cdiContainer.getContextControl().startContexts();
+
+### Jetty
+For Jetty, you need to add an `EventListener` which will be your `CdiServletRequestListener`.
 The object must be instantiated.  This must be done before the server is started.
+
+    :::java
+        Server server = new Server(port);
+        ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
+        context.setContextPath("/");
+        server.setHandler(context);
+
+        context.addEventListener(new CdiServletRequestListener());
+        context.addServlet(new ServletHolder(new YourServlet()),"/*");
+
+        server.start();
+
+### Undertow
+For Undertow, you register the `CdiServletRequestListener` via `ListenerInfo` by passing
in the class to their builders.  Then you add the `ListenerInfo` to your deployment before
starting.
+
+    :::java
+        ServletInfo servletInfo = Servlets.servlet("RequestServlet", YourServlet.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();
+        Undertow server = Undertow.builder()
+                .addHttpListener(port, "localhost")
+                .setHandler(deploymentManager.start())
+                .build();
+        server.start();
+
+### Tomcat
+For Tomcat, you need to register the `CdiServletContextListener` instead of the `CdiServletRequestListener`.
 It is added as an `ApplicationListener` by passing in the class name as a `String`.
+
+    :::java
+        Tomcat tomcat = new Tomcat();
+        tomcat.setPort(port);
+        File base = new File("...");
+        Context ctx = tomcat.addContext("/",base.getAbsolutePath());
+        StandardContext standardContext = (StandardContext)ctx;
+        standardContext.addApplicationListener(CdiServletContextListener.class.getName());
+        Wrapper wrapper = Tomcat.addServlet(ctx,"YourServlet",YourServlet.class.getName());
+        wrapper.addMapping("/*");
+        tomcat.start();
\ No newline at end of file

Modified: deltaspike/site/trunk/content/documentation.mdtext
URL: http://svn.apache.org/viewvc/deltaspike/site/trunk/content/documentation.mdtext?rev=1616770&r1=1616769&r2=1616770&view=diff
==============================================================================
--- deltaspike/site/trunk/content/documentation.mdtext (original)
+++ deltaspike/site/trunk/content/documentation.mdtext Fri Aug  8 14:18:48 2014
@@ -132,13 +132,13 @@ You can manually <a href="download.html"
 In the listings below replace the placeholders for the version with the version of your choice
or use:
 
     <properties>
-        <deltaspike.version>1.0.0</deltaspike.version>
+        <deltaspike.version>1.0.1</deltaspike.version>
     </properties>
  
 Or if you want to very bleeding edge, point to our current snapshot.
 
     <properties>
-        <deltaspike.version>1.0.1-SNAPSHOT</deltaspike.version>
+        <deltaspike.version>1.0.2-SNAPSHOT</deltaspike.version>
     </properties>
 
 ### Configuration of DeltaSpike Core
@@ -355,6 +355,15 @@ In the listings below replace the placeh
         <scope>runtime</scope>
     </dependency>
 
+### For Embedded Servlet Runtimes, you can add
+
+    <dependency>
+        <groupId>org.apache.deltaspike.cdictrl</groupId>
+        <artifactId>deltaspike-cdictrl-servlet</artifactId>
+        <version>${deltaspike.version}</version>
+        <scope>compile</scope>
+    </dependency>
+
 ### Testing Snapshots
 
 If you would like to test the latest Snapshot, you can [build](http://deltaspike.apache.org/build.html)
DeltaSpike locally or you get it from the Apache Snapshot-Repository:

Added: deltaspike/site/trunk/deltaspike-site-project.iml
URL: http://svn.apache.org/viewvc/deltaspike/site/trunk/deltaspike-site-project.iml?rev=1616770&view=auto
==============================================================================
--- deltaspike/site/trunk/deltaspike-site-project.iml (added)
+++ deltaspike/site/trunk/deltaspike-site-project.iml Fri Aug  8 14:18:48 2014
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE"
version="4">
+  <component name="NewModuleRootManager" inherit-compiler-output="false">
+    <output url="file://$MODULE_DIR$/target/classes" />
+    <output-test url="file://$MODULE_DIR$/target/test-classes" />
+    <content url="file://$MODULE_DIR$">
+      <sourceFolder url="file://$MODULE_DIR$/content" type="java-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/templates" type="java-resource" />
+      <excludeFolder url="file://$MODULE_DIR$/target" />
+    </content>
+    <orderEntry type="inheritedJdk" />
+    <orderEntry type="sourceFolder" forTests="false" />
+  </component>
+</module>
+

Modified: deltaspike/site/trunk/pom.xml
URL: http://svn.apache.org/viewvc/deltaspike/site/trunk/pom.xml?rev=1616770&r1=1616769&r2=1616770&view=diff
==============================================================================
--- deltaspike/site/trunk/pom.xml (original)
+++ deltaspike/site/trunk/pom.xml Fri Aug  8 14:18:48 2014
@@ -29,7 +29,7 @@
 
     <groupId>org.apache.deltaspike</groupId>
     <artifactId>deltaspike-site-project</artifactId>
-    <version>0.3-incubating-SNAPSHOT</version>
+    <version>1.0.1-SNAPSHOT</version>
     <packaging>pom</packaging>
 
     <!--



Mime
View raw message