You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2009/02/05 09:30:00 UTC

svn commit: r741044 - in /camel/trunk/examples/camel-example-reportincident: ./ src/main/java/org/apache/camel/example/reportincident/ src/main/resources/ src/test/java/org/apache/camel/example/reportincident/

Author: ningjiang
Date: Thu Feb  5 08:29:59 2009
New Revision: 741044

URL: http://svn.apache.org/viewvc?rev=741044&view=rev
Log:
CAMEL-1314 fixed the tomcat issue of camel-example-reportincident

Modified:
    camel/trunk/examples/camel-example-reportincident/README.txt
    camel/trunk/examples/camel-example-reportincident/build.xml
    camel/trunk/examples/camel-example-reportincident/pom.xml
    camel/trunk/examples/camel-example-reportincident/src/main/java/org/apache/camel/example/reportincident/FilenameGenerator.java
    camel/trunk/examples/camel-example-reportincident/src/main/java/org/apache/camel/example/reportincident/ReportIncidentRoutes.java
    camel/trunk/examples/camel-example-reportincident/src/main/resources/camel-config.xml
    camel/trunk/examples/camel-example-reportincident/src/test/java/org/apache/camel/example/reportincident/ReportIncidentRoutesTest.java

Modified: camel/trunk/examples/camel-example-reportincident/README.txt
URL: http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-reportincident/README.txt?rev=741044&r1=741043&r2=741044&view=diff
==============================================================================
--- camel/trunk/examples/camel-example-reportincident/README.txt (original)
+++ camel/trunk/examples/camel-example-reportincident/README.txt Thu Feb  5 08:29:59 2009
@@ -14,7 +14,7 @@
   mvn jetty:run
 
 The webservice is exposed at:
-  http://localhost:9080/reportincident/webservice/incident
+  http://localhost:9080/camel-example-reportincident/webservices/incident
 
 
 To run the example with Ant
@@ -42,7 +42,7 @@
     ant run
 
 The webservice is exposed at:
-  http://localhost:9080/reportincident/webservice/incident
+  http://localhost:9080/camel-example-reportincident/webservices/incident
 
 
 To stop the example hit ctrl + c

Modified: camel/trunk/examples/camel-example-reportincident/build.xml
URL: http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-reportincident/build.xml?rev=741044&r1=741043&r2=741044&view=diff
==============================================================================
--- camel/trunk/examples/camel-example-reportincident/build.xml (original)
+++ camel/trunk/examples/camel-example-reportincident/build.xml Thu Feb  5 08:29:59 2009
@@ -25,7 +25,7 @@
 	<fail unless="env.SPRING_HOME" message="You must download Spring2.5 and set your CXF_HOME to run this demo."/>
 	<fail unless="env.JETTY_HOME" message="You must download Jetty6 and set your JETTY_HOME to run this demo."/>
 
-	<property name="project.name" value="camel-example-cxf"/>
+	<property name="project.name" value="camel-example-reportincident"/>
 
 	<property name="jetty.home" value="${env.JETTY_HOME}"/>
 	<path id="jetty.classpath">
@@ -63,8 +63,8 @@
 	</target>
 
 	<target name="run" depends="generate.code,build"
-		description="Compile and run the sample of camel-cxf component">
-		<camelrun mainClass="org.apache.camel.example.cxf.CamelCxfExample" />
+		description="Compile and run the sample of reportincident component">
+		<camelrun mainClass="org.apache.camel.example.reportincident.ReportIncidentRoutes" />
 	</target>
 
 	<available property="wsdl.dir" value="${build.resources.dir}" file="${build.resources.dir}/report_incident.wsdl" />

Modified: camel/trunk/examples/camel-example-reportincident/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-reportincident/pom.xml?rev=741044&r1=741043&r2=741044&view=diff
==============================================================================
--- camel/trunk/examples/camel-example-reportincident/pom.xml (original)
+++ camel/trunk/examples/camel-example-reportincident/pom.xml Thu Feb  5 08:29:59 2009
@@ -15,7 +15,7 @@
     <description>An example based on real life use case for reporting incidents using webservice that are transformed
         and send as emails to a backing system
     </description>
-    
+    <packaging>war</packaging>
 
     <dependencies>
         <dependency>
@@ -142,6 +142,14 @@
                 <groupId>org.mortbay.jetty</groupId>
                 <artifactId>maven-jetty-plugin</artifactId>
                 <version>${jetty-version}</version>
+                <configuration>
+                   <connectors>
+                      <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
+                        <port>9080</port>
+                        <maxIdleTime>60000</maxIdleTime>
+                      </connector>
+                   </connectors>                   
+                </configuration>
             </plugin>
 
         </plugins>

Modified: camel/trunk/examples/camel-example-reportincident/src/main/java/org/apache/camel/example/reportincident/FilenameGenerator.java
URL: http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-reportincident/src/main/java/org/apache/camel/example/reportincident/FilenameGenerator.java?rev=741044&r1=741043&r2=741044&view=diff
==============================================================================
--- camel/trunk/examples/camel-example-reportincident/src/main/java/org/apache/camel/example/reportincident/FilenameGenerator.java (original)
+++ camel/trunk/examples/camel-example-reportincident/src/main/java/org/apache/camel/example/reportincident/FilenameGenerator.java Thu Feb  5 08:29:59 2009
@@ -21,7 +21,7 @@
  */
 public class FilenameGenerator {
 
-    public String generateFilename(InputReportIncident input) {
+    public String generateFilename(InputReportIncident input) {        
         // compute the filename
         return "incident-" + input.getIncidentId() + ".txt";
     }

Modified: camel/trunk/examples/camel-example-reportincident/src/main/java/org/apache/camel/example/reportincident/ReportIncidentRoutes.java
URL: http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-reportincident/src/main/java/org/apache/camel/example/reportincident/ReportIncidentRoutes.java?rev=741044&r1=741043&r2=741044&view=diff
==============================================================================
--- camel/trunk/examples/camel-example-reportincident/src/main/java/org/apache/camel/example/reportincident/ReportIncidentRoutes.java (original)
+++ camel/trunk/examples/camel-example-reportincident/src/main/java/org/apache/camel/example/reportincident/ReportIncidentRoutes.java Thu Feb  5 08:29:59 2009
@@ -16,8 +16,10 @@
  */
 package org.apache.camel.example.reportincident;
 
+import org.apache.camel.CamelContext;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.file.FileComponent;
+import org.apache.camel.component.file.NewFileComponent;
+import org.apache.camel.impl.DefaultCamelContext;
 import org.apache.camel.language.bean.BeanLanguage;
 
 /**
@@ -26,14 +28,25 @@
  * In the configure method we have all kind of DSL methods we use for expressing our routes.
  */
 public class ReportIncidentRoutes extends RouteBuilder {
+    private boolean usingServletTransport = true;
+    
+    public void setUsingServletTransport(boolean flag) {
+        usingServletTransport = flag;
+    }
 
     public void configure() throws Exception {
         // webservice response for OK
         OutputReportIncident ok = new OutputReportIncident();
         ok.setCode("0");
 
-        // endpoint to our CXF webservice
-        String cxfEndpoint = "cxf://http://localhost:9080/reportincident/webservices/incident"
+        // endpoint to our CXF webservice  
+        // We should use the related path to publish the service, when using the ServletTransport
+        String cxfEndpointAddress = "cxf:/incident";
+        // Using the full http address for stand alone running
+        if (!usingServletTransport) {
+            cxfEndpointAddress = "cxf://http://localhost:9080/camel-example-reportincident/webservices/incident";
+        }
+        String cxfEndpoint = cxfEndpointAddress
                 + "?serviceClass=org.apache.camel.example.reportincident.ReportIncidentEndpoint"
                 + "&wsdlURL=report_incident.wsdl";
 
@@ -42,20 +55,28 @@
             // we need to convert the CXF payload to InputReportIncident that FilenameGenerator and velocity expects
             .convertBodyTo(InputReportIncident.class)
             // then set the file name using the FilenameGenerator bean
-            .setHeader(FileComponent.HEADER_FILE_NAME, BeanLanguage.bean(FilenameGenerator.class, "generateFilename"))
+            .setHeader(NewFileComponent.HEADER_FILE_NAME, BeanLanguage.bean(FilenameGenerator.class, "generateFilename"))
             // and create the mail body using velocity templating
             .to("velocity:MailBody.vm")
             // and store the file
-            .to("file://target/subfolder")
+            .to("newfile://target/subfolder")
             // return OK as response
             .transform(constant(ok));
 
         // second part from the file backup -> send email
-        from("file://target/subfolder")
+        from("newfile://target/subfolder")
             // set the subject of the email
             .setHeader("subject", constant("new incident reported"))
             // send the email
             .to("smtp://someone@localhost?password=secret&to=incident@mycompany.com");
     }
+    
+    public static void main(String args[]) throws Exception {
+        CamelContext camel = new DefaultCamelContext();
+        ReportIncidentRoutes routes = new ReportIncidentRoutes();
+        routes.setUsingServletTransport(false);
+        camel.addRoutes(routes);
+        camel.start();
+    }
 
 }

Modified: camel/trunk/examples/camel-example-reportincident/src/main/resources/camel-config.xml
URL: http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-reportincident/src/main/resources/camel-config.xml?rev=741044&r1=741043&r2=741044&view=diff
==============================================================================
--- camel/trunk/examples/camel-example-reportincident/src/main/resources/camel-config.xml (original)
+++ camel/trunk/examples/camel-example-reportincident/src/main/resources/camel-config.xml Thu Feb  5 08:29:59 2009
@@ -21,7 +21,10 @@
        xsi:schemaLocation="
             http://activemq.apache.org/camel/schema/spring http://activemq.apache.org/camel/schema/spring/camel-spring.xsd
             http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
-
+    <import resource="classpath:META-INF/cxf/cxf.xml"/>
+    <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml"/>
+    <import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>
+    
     <!-- create a camel context as to start Camel -->
     <camelContext id="camel" xmlns="http://activemq.apache.org/camel/schema/spring">
         <package>org.apache.camel.example.reportincident</package>

Modified: camel/trunk/examples/camel-example-reportincident/src/test/java/org/apache/camel/example/reportincident/ReportIncidentRoutesTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-reportincident/src/test/java/org/apache/camel/example/reportincident/ReportIncidentRoutesTest.java?rev=741044&r1=741043&r2=741044&view=diff
==============================================================================
--- camel/trunk/examples/camel-example-reportincident/src/test/java/org/apache/camel/example/reportincident/ReportIncidentRoutesTest.java (original)
+++ camel/trunk/examples/camel-example-reportincident/src/test/java/org/apache/camel/example/reportincident/ReportIncidentRoutesTest.java Thu Feb  5 08:29:59 2009
@@ -28,13 +28,15 @@
 public class ReportIncidentRoutesTest extends TestCase {
 
     // should be the same address as we have in our route
-    private static final String URL = "http://localhost:9080/reportincident/webservices/incident";
+    private static final String URL = "http://localhost:9080/camel-example-reportincident/webservices/incident";
 
     private CamelContext camel;
 
     protected void startCamel() throws Exception {
         camel = new DefaultCamelContext();
-        camel.addRoutes(new ReportIncidentRoutes());
+        ReportIncidentRoutes routes = new ReportIncidentRoutes();
+        routes.setUsingServletTransport(false);
+        camel.addRoutes(routes);
         camel.start();
     }