You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2015/06/08 17:35:31 UTC

camel git commit: CAMEL-8846: camel-archetype-web - Should use servlet as example

Repository: camel
Updated Branches:
  refs/heads/master 40e0e07fe -> f6ddd5e8e


CAMEL-8846: camel-archetype-web - Should use servlet as example


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

Branch: refs/heads/master
Commit: f6ddd5e8e34be970c5dc924865908936d18684e6
Parents: 40e0e07
Author: Claus Ibsen <da...@apache.org>
Authored: Mon Jun 8 17:40:37 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Mon Jun 8 17:40:37 2015 +0200

----------------------------------------------------------------------
 .../main/resources/archetype-resources/pom.xml  |  2 +-
 .../src/main/resources/log4j.properties         |  2 --
 .../main/webapp/WEB-INF/applicationContext.xml  | 38 ++++++++++++--------
 .../src/main/webapp/WEB-INF/web.xml             | 33 +++++++++++------
 .../src/main/webapp/index.html                  | 23 +++++++++---
 5 files changed, 67 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/f6ddd5e8/tooling/archetypes/camel-archetype-web/src/main/resources/archetype-resources/pom.xml
----------------------------------------------------------------------
diff --git a/tooling/archetypes/camel-archetype-web/src/main/resources/archetype-resources/pom.xml b/tooling/archetypes/camel-archetype-web/src/main/resources/archetype-resources/pom.xml
index e74525a..1151fdf 100644
--- a/tooling/archetypes/camel-archetype-web/src/main/resources/archetype-resources/pom.xml
+++ b/tooling/archetypes/camel-archetype-web/src/main/resources/archetype-resources/pom.xml
@@ -49,7 +49,7 @@
     </dependency>
     <dependency>
       <groupId>org.apache.camel</groupId>
-      <artifactId>camel-stream</artifactId>
+      <artifactId>camel-servlet</artifactId>
       <version>${camel-version}</version>
     </dependency>
 

http://git-wip-us.apache.org/repos/asf/camel/blob/f6ddd5e8/tooling/archetypes/camel-archetype-web/src/main/resources/archetype-resources/src/main/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/tooling/archetypes/camel-archetype-web/src/main/resources/archetype-resources/src/main/resources/log4j.properties b/tooling/archetypes/camel-archetype-web/src/main/resources/archetype-resources/src/main/resources/log4j.properties
index f257e58..a937abd 100644
--- a/tooling/archetypes/camel-archetype-web/src/main/resources/archetype-resources/src/main/resources/log4j.properties
+++ b/tooling/archetypes/camel-archetype-web/src/main/resources/archetype-resources/src/main/resources/log4j.properties
@@ -22,8 +22,6 @@ log4j.rootLogger=INFO, out
 # uncomment the following line to turn on Camel debugging
 #log4j.logger.org.apache.camel=DEBUG
 
-log4j.logger.org.springframework=WARN
-
 # CONSOLE appender not used by default
 log4j.appender.out=org.apache.log4j.ConsoleAppender
 log4j.appender.out.layout=org.apache.log4j.PatternLayout

http://git-wip-us.apache.org/repos/asf/camel/blob/f6ddd5e8/tooling/archetypes/camel-archetype-web/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/applicationContext.xml
----------------------------------------------------------------------
diff --git a/tooling/archetypes/camel-archetype-web/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/applicationContext.xml b/tooling/archetypes/camel-archetype-web/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/applicationContext.xml
index d12a23c..2e9525c 100644
--- a/tooling/archetypes/camel-archetype-web/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/applicationContext.xml
+++ b/tooling/archetypes/camel-archetype-web/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/applicationContext.xml
@@ -16,22 +16,32 @@
 ## limitations under the License.
 ## ------------------------------------------------------------------------
 <beans xmlns="http://www.springframework.org/schema/beans"
-    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-    xsi:schemaLocation="
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
 
-    <!--
-        Simple camel route which send every one minute a message on the console.
-    -->
-    <camelContext xmlns="http://camel.apache.org/schema/spring">
-        <route id="timer-to-console">
-            <from uri="timer://foo?fixedRate=true&amp;period=10s"/>
-            <transform>
-               <simple>I am ${sysenv.HOSTNAME} and I have run ${header.CamelTimerCounter} times</simple>
-            </transform>
-            <to uri="stream:out"/>
-        </route>
-    </camelContext>
+  <camelContext xmlns="http://camel.apache.org/schema/spring">
+    <route id="helloRoute">
+      <!-- incoming requests from the servlet is routed -->
+      <from uri="servlet:///hello"/>
+      <choice>
+        <when>
+          <!-- is there a header with the key name? -->
+          <header>name</header>
+          <!-- yes so return back a message to the user -->
+          <transform>
+            <simple>Hello ${header.name} how are you?</simple>
+          </transform>
+        </when>
+        <otherwise>
+          <!-- if no name parameter then output a syntax to the user -->
+          <transform>
+            <constant>Add a name parameter to uri, eg ?name=foo</constant>
+          </transform>
+        </otherwise>
+      </choice>
+    </route>
+  </camelContext>
 
 </beans>

http://git-wip-us.apache.org/repos/asf/camel/blob/f6ddd5e8/tooling/archetypes/camel-archetype-web/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/tooling/archetypes/camel-archetype-web/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml b/tooling/archetypes/camel-archetype-web/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml
index cf7c4a1..2ef0ba8 100644
--- a/tooling/archetypes/camel-archetype-web/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml
+++ b/tooling/archetypes/camel-archetype-web/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml
@@ -19,17 +19,30 @@
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
 
-    <display-name>Camel Routes</display-name>
+  <display-name>Camel Routes</display-name>
 
-    <!-- location of spring xml files -->
-    <context-param>
-        <param-name>contextConfigLocation</param-name>
-        <param-value>/WEB-INF/applicationContext.xml</param-value>
-    </context-param>
+  <!-- location of spring xml files -->
+  <context-param>
+    <param-name>contextConfigLocation</param-name>
+    <param-value>/WEB-INF/applicationContext.xml</param-value>
+  </context-param>
 
-    <!-- the listener that kick-starts Spring -->
-    <listener>
-        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
-    </listener>
+  <!-- the listener that kick-starts Spring -->
+  <listener>
+    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
+  </listener>
+
+  <!-- Camel servlet -->
+  <servlet>
+    <servlet-name>CamelServlet</servlet-name>
+    <servlet-class>org.apache.camel.component.servlet.CamelHttpTransportServlet</servlet-class>
+    <load-on-startup>1</load-on-startup>
+  </servlet>
+
+  <!-- Camel servlet mapping -->
+  <servlet-mapping>
+    <servlet-name>CamelServlet</servlet-name>
+    <url-pattern>/camel/*</url-pattern>
+  </servlet-mapping>
 
 </web-app>

http://git-wip-us.apache.org/repos/asf/camel/blob/f6ddd5e8/tooling/archetypes/camel-archetype-web/src/main/resources/archetype-resources/src/main/webapp/index.html
----------------------------------------------------------------------
diff --git a/tooling/archetypes/camel-archetype-web/src/main/resources/archetype-resources/src/main/webapp/index.html b/tooling/archetypes/camel-archetype-web/src/main/resources/archetype-resources/src/main/webapp/index.html
index 7e212ba..2512003 100644
--- a/tooling/archetypes/camel-archetype-web/src/main/resources/archetype-resources/src/main/webapp/index.html
+++ b/tooling/archetypes/camel-archetype-web/src/main/resources/archetype-resources/src/main/webapp/index.html
@@ -1,12 +1,27 @@
 <html>
 
 <body>
-<h2>Camel Archetype Web</h2>
+<h2>Camel Servlet example</h2>
 
-  This is a simple example that was created with camel-archetype-web.
-  <p/>
-  A Camel route is deployed that logs to system.out every 10 seconds.
+This example shows how to route messages from HTTP using servlets with Apache Camel.
+<br/>
+<br/>
+To get started click <a href="camel/hello">this link</a>.
+<br/>
+<br/>
+This example is documented at
+<a href="http://camel.apache.org/servlet-tomcat-example.html">servlet tomcat example</a>
 
+<br/>
+If you hit any problems please let us know on the
+<a href="http://camel.apache.org/discussion-forums.html">Camel Forums</a>
+<br/>
+<br/>
+Please help us make Apache Camel better - we appreciate any feedback you may
+have. Enjoy!
+<br/>
+<br/>
+The Camel riders!
 </body>
 
 </html>
\ No newline at end of file