You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by bu...@apache.org on 2013/02/07 20:18:35 UTC

svn commit: r849802 - in /websites/production/camel/content: cache/main.pageCache servlet-tomcat-no-spring-example.html servletlistener-component.html

Author: buildbot
Date: Thu Feb  7 19:18:34 2013
New Revision: 849802

Log:
Production update by buildbot for camel

Modified:
    websites/production/camel/content/cache/main.pageCache
    websites/production/camel/content/servlet-tomcat-no-spring-example.html
    websites/production/camel/content/servletlistener-component.html

Modified: websites/production/camel/content/cache/main.pageCache
==============================================================================
Binary files - no diff available.

Modified: websites/production/camel/content/servlet-tomcat-no-spring-example.html
==============================================================================
--- websites/production/camel/content/servlet-tomcat-no-spring-example.html (original)
+++ websites/production/camel/content/servlet-tomcat-no-spring-example.html Thu Feb  7 19:18:34 2013
@@ -96,7 +96,7 @@ The example contains a Camel routes that
 <h3><a shape="rect" name="ServletTomcatNoSpringExample-Implementation"></a>Implementation</h3>
 
 <p>In the <tt>web.xml</tt> file in the <tt>src/main/webapp/WEB-INF</tt> folder we have both a CamelServlet and CamelContextListener defined.<br clear="none">
-The CamelServlet is mandatory to do when using the <a shape="rect" href="servlet.html" title="SERVLET">Servlet</a> component. And the <tt>CamelServletContextListener</tt> is used to bootstrap the Camel application. </p>
+The CamelServlet is mandatory to do when using the <a shape="rect" href="servlet.html" title="SERVLET">Servlet</a> component. And the <tt>JndiCamelServletContextListener</tt> is used to bootstrap the Camel application. </p>
 
 <div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader" style="border-bottom-width: 1px;"><b>web.xml</b></div><div class="codeContent panelContent">
 <pre class="code-xml">&lt;web-app version=<span class="code-quote">"2.4"</span> xmlns=<span class="code-quote">"http://java.sun.com/xml/ns/j2ee"</span>
@@ -121,7 +121,7 @@ The CamelServlet is mandatory to do when
 
   <span class="code-tag"><span class="code-comment">&lt;!-- the listener that kick-starts Camel --&gt;</span></span>
   <span class="code-tag">&lt;listener&gt;</span>
-    <span class="code-tag">&lt;listener-class&gt;</span>org.apache.camel.component.servletlistener.CamelServletContextListener<span class="code-tag">&lt;/listener-class&gt;</span>
+    <span class="code-tag">&lt;listener-class&gt;</span>org.apache.camel.component.servletlistener.JndiCamelServletContextListener<span class="code-tag">&lt;/listener-class&gt;</span>
   <span class="code-tag">&lt;/listener&gt;</span>
 
   <span class="code-tag"><span class="code-comment">&lt;!-- Camel servlet used in the Camel application --&gt;</span></span>

Modified: websites/production/camel/content/servletlistener-component.html
==============================================================================
--- websites/production/camel/content/servletlistener-component.html (original)
+++ websites/production/camel/content/servletlistener-component.html Thu Feb  7 19:18:34 2013
@@ -99,6 +99,10 @@ Though Servlet 2.x requires to use a web
 
 <h3><a shape="rect" name="ServletListenerComponent-Using"></a>Using</h3>
 
+<p>You would need to chose one of the following implementations of the abstract class <tt>org.apache.camel.component.servletlistener.CamelServletContextListener</tt>.</p>
+<ul class="alternate" type="square"><li><tt>JndiCamelServletContextListener</tt> which uses the <tt>JndiRegistry</tt> to leverage JNDI for its registry.</li><li><tt>SimpleCamelServletContextListener</tt> which uses the <tt>SimpleRegistry} to leverage a {{java.util.Map</tt> as its registry.</li></ul>
+
+
 <p>To use this you need to configure the <tt>org.apache.camel.component.servletlistener.CamelServletContextListener</tt> in the <tt>WEB-INF/web.xml</tt> file as shown below:</p>
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
 <pre class="code-xml"><span class="code-tag">&lt;web-app&gt;</span>
@@ -125,7 +129,7 @@ Though Servlet 2.x requires to use a web
 
   <span class="code-tag"><span class="code-comment">&lt;!-- register Camel as a listener so we can bootstrap Camel when the web application starts --&gt;</span></span>
   <span class="code-tag">&lt;listener&gt;</span>
-    <span class="code-tag">&lt;listener-class&gt;</span>org.apache.camel.component.servletlistener.CamelServletContextListener<span class="code-tag">&lt;/listener-class&gt;</span>
+    <span class="code-tag">&lt;listener-class&gt;</span>org.apache.camel.component.servletlistener.SimpleCamelServletContextListener<span class="code-tag">&lt;/listener-class&gt;</span>
   <span class="code-tag">&lt;/listener&gt;</span>
 
 <span class="code-tag">&lt;/web-app&gt;</span>
@@ -263,16 +267,16 @@ In the web.xml you refer to the XML file
 </div></div>
 
 
-<h3><a shape="rect" name="ServletListenerComponent-JNDIandCamelRegistry"></a>JNDI and Camel <a shape="rect" href="registry.html" title="Registry">Registry</a></h3>
+<h3><a shape="rect" name="ServletListenerComponent-JNDIorSimpleasCamelRegistry"></a>JNDI or Simple as Camel <a shape="rect" href="registry.html" title="Registry">Registry</a></h3>
 
-<p>This component uses JNDI/<tt>javax.naming.Context</tt> using the <tt>org.apache.camel.util.jndi.JndiContext</tt> as the <a shape="rect" href="registry.html" title="Registry">Registry</a> implementation.<br clear="none">
+<p>This component uses either JNDI or Simple as the <a shape="rect" href="registry.html" title="Registry">Registry</a>.<br clear="none">
 This allows you to lookup <a shape="rect" href="bean.html" title="Bean">Bean</a>s and other services in JNDI, and as well to bind and unbind your own <a shape="rect" href="bean.html" title="Bean">Bean</a>s.</p>
 
-<p>This is done from Java code by implementing the <tt>org.apache.camel.component.servletlistener.CamelContextLifecycle</tt>. There is a base class <tt>org.apache.camel.component.servletlistener.CamelContextLifecycleSupport</tt> which is easier to extend, than implementing the interface.</p>
+<p>This is done from Java code by implementing the <tt>org.apache.camel.component.servletlistener.CamelContextLifecycle</tt>.</p>
 
-<h4><a shape="rect" name="ServletListenerComponent-UsingcustomCamelContextLifecycleSupport"></a>Using custom CamelContextLifecycleSupport</h4>
+<h4><a shape="rect" name="ServletListenerComponent-UsingcustomCamelContextLifecycle"></a>Using custom CamelContextLifecycle</h4>
 
-<p>In the code below we use the callbacks <tt>beforeStart</tt> and <tt>afterStop</tt> to enlist our custom bean in the JNDI <a shape="rect" href="registry.html" title="Registry">Registry</a>, and as well to cleanup when we stop.</p>
+<p>In the code below we use the callbacks <tt>beforeStart</tt> and <tt>afterStop</tt> to enlist our custom bean in the Simple <a shape="rect" href="registry.html" title="Registry">Registry</a>, and as well to cleanup when we stop.</p>
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
 <pre class="code-java">/**
  * Our custom {@link CamelContextLifecycle} which allows us to enlist beans in the {@link JndiContext}
@@ -280,24 +284,34 @@ This allows you to lookup <a shape="rect
  * &lt;p/&gt;
  * We can of course also <span class="code-keyword">do</span> other kind of custom logic as well.
  */
-<span class="code-keyword">public</span> class MyLifecycle <span class="code-keyword">extends</span> CamelContextLifecycleSupport {
+<span class="code-keyword">public</span> class MyLifecycle <span class="code-keyword">implements</span> CamelContextLifecycle&lt;SimpleRegistry&gt; {
 
     @Override
-    <span class="code-keyword">public</span> void beforeStart(ServletCamelContext camelContext, JndiContext jndi) <span class="code-keyword">throws</span> Exception {
+    <span class="code-keyword">public</span> void beforeStart(ServletCamelContext camelContext, SimpleRegistry registry) <span class="code-keyword">throws</span> Exception {
         <span class="code-comment">// enlist our bean(s) in the registry
-</span>        jndi.bind(<span class="code-quote">"myBean"</span>, <span class="code-keyword">new</span> HelloBean());
+</span>        registry.put(<span class="code-quote">"myBean"</span>, <span class="code-keyword">new</span> HelloBean());
     }
 
     @Override
-    <span class="code-keyword">public</span> void afterStop(ServletCamelContext camelContext, JndiContext jndi) <span class="code-keyword">throws</span> Exception {
+    <span class="code-keyword">public</span> void afterStart(ServletCamelContext camelContext, SimpleRegistry registry) <span class="code-keyword">throws</span> Exception {
+        <span class="code-comment">// noop
+</span>    }
+
+    @Override
+    <span class="code-keyword">public</span> void beforeStop(ServletCamelContext camelContext, SimpleRegistry registry) <span class="code-keyword">throws</span> Exception {
+        <span class="code-comment">// noop
+</span>    }
+
+    @Override
+    <span class="code-keyword">public</span> void afterStop(ServletCamelContext camelContext, SimpleRegistry registry) <span class="code-keyword">throws</span> Exception {
         <span class="code-comment">// unbind our bean when Camel has been stopped
-</span>        jndi.unbind(<span class="code-quote">"myBean"</span>);
+</span>        registry.remove(<span class="code-quote">"myBean"</span>);
     }
 }
 </pre>
 </div></div>
 
-<p>Then we need to register this class in the web.xml file as shown below, using the parameter name "CamelContextLifecycle". The value must be a FQN which refers to the class implementing the <tt>org.apache.camel.component.servletlistener.CamelContextLifecycleSupport</tt> interface.</p>
+<p>Then we need to register this class in the web.xml file as shown below, using the parameter name "CamelContextLifecycle". The value must be a FQN which refers to the class implementing the <tt>org.apache.camel.component.servletlistener.CamelContextLifecycle</tt> interface.</p>
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
 <pre class="code-xml">
   <span class="code-tag">&lt;context-param&gt;</span>
@@ -321,7 +335,7 @@ This allows you to lookup <a shape="rect
 </pre>
 </div></div>
 
-<div class="panelMacro"><table class="tipMacro"><colgroup span="1"><col span="1" width="24"><col span="1"></colgroup><tr><td colspan="1" rowspan="1" valign="top"><img align="middle" src="https://cwiki.apache.org/confluence/images/icons/emoticons/check.gif" width="16" height="16" alt="" border="0"></td><td colspan="1" rowspan="1">In the CamelContextLifecycleSupport implementation you can of course do any kind of code in the callback methods. There is 4 callbacks for before/after starting <a shape="rect" href="camelcontext.html" title="CamelContext">CamelContext</a>, and as well for before/after stopping as well.</td></tr></table></div>
+<p><b>Important:</b> If you use <tt>org.apache.camel.component.servletlistener.JndiCamelServletContextListener</tt> then the <tt>CamelContextLifecycle</tt> must use the <tt>JndiRegistry</tt> as well. And likewise if the servlet is <tt>org.apache.camel.component.servletlistener.SimpleCamelServletContextListener</tt> then the <tt>CamelContextLifecycle</tt> must use the <tt>SimpleRegistry</tt> </p>
 
 <h3><a shape="rect" name="ServletListenerComponent-SeeAlso"></a>See Also</h3>
 <ul class="alternate" type="square"><li><a shape="rect" href="servlet.html" title="SERVLET">SERVLET</a></li><li><a shape="rect" href="servlet-tomcat-example.html" title="Servlet Tomcat Example">Servlet Tomcat Example</a></li><li><a shape="rect" href="servlet-tomcat-no-spring-example.html" title="Servlet Tomcat No Spring Example">Servlet Tomcat No Spring Example</a></li></ul>