Modified: websites/production/camel/content/tutorial-osgi-camel-part2.html
==============================================================================
--- websites/production/camel/content/tutorial-osgi-camel-part2.html (original)
+++ websites/production/camel/content/tutorial-osgi-camel-part2.html Tue Sep 22
14:26:24 2015
@@ -107,7 +107,7 @@
<p>Here is a picture of the report incident application that this tutorial
will cover :</p>
-<p><span class="confluence-embedded-file-wrapper"><img
class="confluence-embedded-image"
src="tutorial-osgi-camel-part2.data/routing.jpg"></span> </p>
+<p><span class="confluence-embedded-file-wrapper"><img
class="confluence-embedded-image"
src="tutorial-osgi-camel-part2.data/routing.jpg"
data-image-src="/confluence/download/attachments/113428/routing.jpg?version=1&modificationDate=1239939817000&api=v2"
data-unresolved-comment-count="0" data-linked-resource-id="10434"
data-linked-resource-version="1" data-linked-resource-type="attachment"
data-linked-resource-default-alias="routing.jpg"
data-base-url="https://cwiki.apache.org/confluence"
data-linked-resource-content-type="image/jpeg"
data-linked-resource-container-id="113428"
data-linked-resource-container-version="53"></span> </p>
<p>To summarize, the application is listening for incidents coming from web
service or files. According to the origin, the content (= incidents) are
transformed into their corresponding objects using for the CSV file, a new
camel component : <a shape="rect" class="external-link"
href="http://camel.apache.org/bindy.html">camel-bindy</a> and for the Web
Service <a shape="rect" class="external-link"
href="http://camel.apache.org/cxf.html">camel-cxf component</a>. Each message
transformed is placed in a queue handled by <a shape="rect"
class="external-link" href="http://activemq.apache.org/">ActiveMQ</a> engine.
All the messages (containing the objects) are next processed by a Bean service
who will (with the help of injection of dependency provided by Spring) save the
incidents in a DB using Spring and Hibernate frameworks.<br clear="none">
A small <a shape="rect" class="external-link"
href="http://wicket.apache.org/">Apache Wicket</a> web application running in
<a shape="rect" class="external-link" href="http://www.mortbay.org/jetty/"
rel="nofollow">Jetty Web server</a> provide to the users a screen to consult
the incidents created.</p>
@@ -127,15 +127,15 @@ A small <a shape="rect" class="external-
<ul class="alternate"><li><a shape="rect" class="external-link"
href="http://maven.apache.org/download.html">Maven 2.0.9</a> to setup the
projects,</li><li><a shape="rect" class="external-link"
href="http://www.eclipse.org/downloads/packages/" rel="nofollow">Eclipse
Ganymede 3.4.x</a>,</li><li><a shape="rect" class="external-link"
href="http://m2eclipse.sonatype.org/" rel="nofollow">Maven eclipse
plugin</a>,</li><li><a shape="rect" class="external-link"
href="http://felix.apache.org/site/downloads.cgi">Apache Felix Karaf
1.4.0</a>,</li><li>Dependencies (= jars) used by the tutorial will be
downloaded (if not available locally) by Maven</li></ul>
-<p><strong>Note:</strong> The sample project can be downloaded, see the <a
shape="rect" href="tutorial-osgi-camel-part2.html">resources</a> section.</p>
+<p><strong>Note:</strong> The sample project can be downloaded, see the <a
shape="rect" href="#tutorial-osgi-camel-part2-Resources">resources</a>
section.</p>
<h2 id="tutorial-osgi-camel-part2-Step1:InitialProjectSetup">Step 1 : Initial
Project Setup</h2>
<p>Different way exist to create maven project. For the basic project like db,
we have used the archetype 'simple' with the command followed by <code>mvn
eclipse:eclipse</code> in the folder created :</p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">
+<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[
mvn archetype:generate -DinteractiveMode=false
-DgroupId=org.apache.camel.example -DartifactId=reportincident.model
-Dversion=1.0-SNAPSHOT -Dgoals=eclipse:eclipse
-</pre>
+]]></script>
</div></div>
<p>For the OSGI bundles, different approaches are available depending on the
tools that you prefer to use :</p>
@@ -150,16 +150,16 @@ mvn archetype:generate -DinteractiveMode
<p>1) Execute maven command in your Unix/Dos console :</p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">
+<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[
mvn org.ops4j:maven-pax-plugin:create-bundle
-Dpackage=org.apache.camel.example.reportincident.model
-DbundleGroupId=reportincident.model -DbundleName=reportincident.model
-Dversion=1.0-SNAPSHOT
-</pre>
+]]></script>
</div></div>
<p>2) Move to the folder created and execute the following command :</p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">
+<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[
mvn org.ops4j:maven-pax-plugin:eclipse
-</pre>
+]]></script>
</div></div>
<p>2) Import the generated eclipse project in Eclipse workspace<br
clear="none">
3) Delete non required files like readme.txt and the folders internal + java
class created<br clear="none">
@@ -182,7 +182,7 @@ The reportincident model is really simpl
<p>Here is the definition of the incident class that you can create in the
reportincident.model project directory
<code>src/main/java/org/apache/camel/example/reportincident/model</code> or use
the code imported</p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">
+<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[
import java.io.Serializable;
public class Incident implements Serializable{
@@ -301,7 +301,7 @@ public class Incident implements Seriali
}
}
-</pre>
+]]></script>
</div></div>
<h2
id="tutorial-osgi-camel-part2-Step3:MapmodellayerwithCSVfile(camel-bindy)">Step
3 : Map model layer with CSV file (camel-bindy)</h2>
@@ -315,14 +315,14 @@ public class Incident implements Seriali
<p>This annotation will help camel-bindy to discover what is the parent class
of the model and which separator is used to separate the fields. If required,
you can also use the property 'skipFirstLine' to skip the first line of your
CSV file</p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">
+<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[
import org.apache.camel.dataformat.bindy.annotation.CsvRecord;
-@CsvRecord(separator =",")
+@CsvRecord(separator =",")
public class Incident implements Serializable{
...
}
-</pre>
+]]></script>
</div></div>
<p>2) Add DataFields annotations</p>
@@ -330,17 +330,17 @@ public class Incident implements Seriali
<p>For each of the CSV field that you want to bind with your model, you must
add the @DataField annotation with its position. This is not the only property
available and you can also add 'pattern' property to by example define the
pattern of your Date field.</p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">
+<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[
import org.apache.camel.dataformat.bindy.annotation.CsvRecord;
import org.apache.camel.dataformat.bindy.annotation.DataField;
-@CsvRecord(separator =",")
+@CsvRecord(separator =",")
public class Incident implements Serializable{
@DataField(pos = 1)
private String incidentRef;
- @DataField(pos = 2, pattern = "dd-mm-yyyy")
+ @DataField(pos = 2, pattern = "dd-mm-yyyy")
private Date incidentDate;
@DataField(pos = 3)
@@ -363,15 +363,15 @@ public class Incident implements Seriali
...
}
-</pre>
+]]></script>
</div></div>
<p>To build the project, simply execute the following maven command in the
reportincident.model project</p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">
+<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[
mvn clean install
-</pre>
+]]></script>
</div></div>
<h2 id="tutorial-osgi-camel-part2-Step4:MapmodellayerwithDB(Hibernate)">Step 4
: Map model layer with DB (Hibernate)</h2>
@@ -381,28 +381,28 @@ mvn clean install
<p>Remark : The ORM uses to persist the information is Hibernate but it can be
changed to another existing like iBatis, Apache OpenJPA, ...</p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<pre class="brush: xml; gutter: false; theme: Default" style="font-size:12px;">
-<hibernate-mapping schema="REPORT">
- <class name="org.apache.camel.example.reportincident.model.Incident"
table="T_INCIDENT">
- <meta attribute="extends">Abstract</meta>
- <id name="incidentId" column="INCIDENT_ID" type="long">
- <generator class="native" />
+<script class="brush: xml; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[
+<hibernate-mapping schema="REPORT">
+ <class
name="org.apache.camel.example.reportincident.model.Incident"
table="T_INCIDENT">
+ <meta attribute="extends">Abstract</meta>
+ <id name="incidentId"
column="INCIDENT_ID" type="long">
+ <generator class="native" />
</id>
- <property column="INCIDENT_REF" name="incidentRef"
length="55" type="string" />
- <property column="INCIDENT_DATE" lazy="false" length="8"
name="incidentDate" type="timestamp" />
- <property column="GIVEN_NAME" length="35" name="givenName"
type="string" />
- <property column="FAMILY_NAME" length="35" name="familyName"
type="string" />
- <property column="SUMMARY" length="35" name="summary"
type="string" />
- <property column="DETAILS" length="255" name="details"
type="string" />
- <property column="EMAIL" length="60" name="email"
type="string" />
- <property column="PHONE" length="35" name="phone"
type="string" />
+ <property column="INCIDENT_REF"
name="incidentRef" length="55" type="string" />
+ <property column="INCIDENT_DATE"
lazy="false" length="8" name="incidentDate"
type="timestamp" />
+ <property column="GIVEN_NAME"
length="35" name="givenName" type="string" />
+ <property column="FAMILY_NAME"
length="35" name="familyName" type="string" />
+ <property column="SUMMARY" length="35"
name="summary" type="string" />
+ <property column="DETAILS" length="255"
name="details" type="string" />
+ <property column="EMAIL" length="60"
name="email" type="string" />
+ <property column="PHONE" length="35"
name="phone" type="string" />
- <property column="CREATION_DATE" generated="never"
lazy="false" name="creationDate" type="timestamp" />
- <property column="CREATION_USER" generated="never"
lazy="false" name="creationUser" type="string" />
+ <property column="CREATION_DATE"
generated="never" lazy="false"
name="creationDate" type="timestamp" />
+ <property column="CREATION_USER"
generated="never" lazy="false"
name="creationUser" type="string" />
</class>
</hibernate-mapping>
-</pre>
+]]></script>
</div></div>
<p>Remark : This file <code>Incident.hbm.xml</code> must be created in the
directory
<code>src\main\resources\META-INF\org\apache\camel\example\reportincident\model\Incident.hbm.xml</code>
of the project reportincident.model.</p>
@@ -416,33 +416,33 @@ mvn clean install
<p>Here is the content of the hibernate.cfg.xml that you must create in the
folder <code>src/config</code> of hibernate.db</p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<pre class="brush: xml; gutter: false; theme: Default" style="font-size:12px;">
+<script class="brush: xml; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[
<!-- MySQL DB -->
<hibernate-configuration>
- <session-factory name="reportincident">
- <property
name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
- <property
name="hibernate.connection.url">jdbc:mysql:///report</property>
- <property
name="hibernate.connection.username">root</property>
- <property
name="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</property>
- <property name="hibernate.connection.password" />
- <property name="hibernate.show_sql">true</property>
+ <session-factory name="reportincident">
+ <property
name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
+ <property
name="hibernate.connection.url">jdbc:mysql:///report</property>
+ <property
name="hibernate.connection.username">root</property>
+ <property
name="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</property>
+ <property name="hibernate.connection.password"
/>
+ <property
name="hibernate.show_sql">true</property>
<!-- mapping files -->
- <mapping
resource="META-INF/org/apache/camel/example/reportincident/model/Incident.hbm.xml"/>
+ <mapping
resource="META-INF/org/apache/camel/example/reportincident/model/Incident.hbm.xml"/>
</session-factory>
</hibernate-configuration>
-</pre>
+]]></script>
</div></div>
<p>The pom.xml file of your reportincident.db project must be modified like
this :</p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<pre class="brush: xml; gutter: false; theme: Default" style="font-size:12px;">
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
+<script class="brush: xml; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.camel.example</groupId>
<artifactId>reportincident.db</artifactId>
@@ -502,7 +502,7 @@ mvn clean install
</plugins>
</build>
</project>
-</pre>
+]]></script>
</div></div>
<p>Remarks :<br clear="none">
@@ -512,9 +512,9 @@ mvn clean install
<p>To create the table + SQL script, simply launch </p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">
+<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[
mvn clean install
-</pre>
+]]></script>
</div></div>
<p>command in the folder of reportincident.db </p>
@@ -527,7 +527,7 @@ mvn clean install
<p>First, we will create the interface declaring the methods that we would
like to provide/expose. Create in the folder
<code>src/main/java/org/apache/camel/example/reportincident/dao</code>, the
java class "IncidentDAO" with the following code :</p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">
+<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[
package org.apache.camel.example.reportincident.dao;
import java.util.List;
@@ -575,7 +575,7 @@ public interface IncidentDAO
public void removeIncident( long id );
}
-</pre>
+]]></script>
</div></div>
<p>There is nothing particular to mention here as this class is a simple case
of <span style="text-decoration: underline;">C</span>reate <span
style="text-decoration: underline;">R</span>ead <span style="text-decoration:
underline;">U</span>pdate <span style="text-decoration:
underline;">D</span>elete implementation. The next class who implements the
interface will provide the necessary code to connect to the database using
Hibernate framework.</p>
@@ -583,7 +583,7 @@ public interface IncidentDAO
<p>So, create the class <code>IncidentDAOImpl</code> in the directory
<code>src/main/java/org/apache/camel/example/reportincident/dao/impl</code></p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">
+<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[
package org.apache.camel.example.reportincident.dao.impl;
@@ -612,11 +612,11 @@ public class IncidentDAOImpl implements
/** The Constant findIncidentByReference. */
private final static String findIncidentByReference =
- "select i from Incident as i where i.incidentRef = :ref";
+ "select i from Incident as i where i.incidentRef = :ref";
/** The Constant findIncident. */
private final static String findIncident =
- "select i from Incident as i";
+ "select i from Incident as i";
/**
* Sets the session factory.
@@ -654,7 +654,7 @@ public class IncidentDAOImpl implements
throws HibernateException
{
q = this.sessionFactory.getCurrentSession().createQuery(
findIncidentByReference );
- q.setString("ref", key );
+ q.setString("ref", key );
List<Incident> list = q.list();
return list;
@@ -691,7 +691,7 @@ public class IncidentDAOImpl implements
}
}
-</pre>
+]]></script>
</div></div>
<p>The most important point to mention here is that this class to connect to
our database and to work with Hibernate needs to have a SessionFactory object.
This object is not instantiated by a constructor's class but only declared as a
property/field. This is where Spring will help us through its dependency
injection.</p>
@@ -699,23 +699,23 @@ public class IncidentDAOImpl implements
<p>The injection is defined in the file called
<code>spring-dao-beans.xml</code> that you will create in the folder
<code>src/main/resources/META-INF/spring</code> :</p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<pre class="brush: xml; gutter: false; theme: Default" style="font-size:12px;">
-<?xml version="1.0" encoding="UTF-8"?>
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="
+<script class="brush: xml; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+ 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://www.springframework.org/schema/beans/spring-beans.xsd">
<!-- DAO Declarations -->
- <bean id="incidentDAO"
class="org.apache.camel.example.reportincident.dao.impl.IncidentDAOImpl">
- <property name="sessionFactory">
- <ref bean="sessionFactory" />
+ <bean id="incidentDAO"
class="org.apache.camel.example.reportincident.dao.impl.IncidentDAOImpl">
+ <property name="sessionFactory">
+ <ref bean="sessionFactory" />
</property>
</bean>
</beans>
-</pre>
+]]></script>
</div></div>
<p>The sessionFactory object will be created with the help of Spring framework
but in order to communicate with the database, information about the data
source must be provided. </p>
@@ -723,41 +723,41 @@ public class IncidentDAOImpl implements
<p>So realize this goal, you will create the file
<code>spring-datasource-beans.xml</code> in the same folder directory with the
following information :</p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<pre class="brush: xml; gutter: false; theme: Default" style="font-size:12px;">
+<script class="brush: xml; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[
...
<!-- Hibernate SessionFactory Definition -->
- <bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
+ <bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
- <property name="mappingLocations">
+ <property name="mappingLocations">
<list>
<value>classpath*:META-INF/org/apache/camel/example/reportincident/model/*.hbm.xml</value>
</list>
</property>
- <property name="hibernateProperties">
+ <property name="hibernateProperties">
<props>
- <prop
key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
- <prop
key="hibernate.show_sql">false</prop>
- <prop
key="hibernate.format_sql">true</prop>
- <prop
key="hibernate.cglib.use_reflection_optimizer">true</prop>
- <prop
key="hibernate.jdbc.batch_size">10</prop>
- <prop
key="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</prop>
+ <prop
key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
+ <prop
key="hibernate.show_sql">false</prop>
+ <prop
key="hibernate.format_sql">true</prop>
+ <prop
key="hibernate.cglib.use_reflection_optimizer">true</prop>
+ <prop
key="hibernate.jdbc.batch_size">10</prop>
+ <prop
key="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</prop>
</props>
</property>
- <property name="dataSource">
- <ref bean="dataSource" />
+ <property name="dataSource">
+ <ref bean="dataSource" />
</property>
...
<!-- DB connection and persistence layer -->
<!-- DataSource Definition -->
- <bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
- <property name="driverClassName" value="${driverClassName}"
/>
- <property name="url" value="${url}" />
- <property name="username" value="${username}" />
- <property name="password" value="${password}" />
+ <bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
+ <property name="driverClassName"
value="${driverClassName}" />
+ <property name="url" value="${url}" />
+ <property name="username"
value="${username}" />
+ <property name="password"
value="${password}" />
</bean>
-</pre>
+]]></script>
</div></div>
<p>This file is not complete but we will review later in the tutorial when we
will cover specific OSGI stuffs and Spring transaction management. Now, we will
design the Spring service part</p>
@@ -769,7 +769,7 @@ public class IncidentDAOImpl implements
<p>Create the following interface <code>IncidentService</code> in the folder
<code>src/main/java/org/apache/camel/example/reportincident/service</code> with
the code :</p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">
+<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[
package org.apache.camel.example.reportincident.service;
import java.util.List;
@@ -817,13 +817,13 @@ public interface IncidentService
public void removeIncident( long id );
}
-</pre>
+]]></script>
</div></div>
<p>and its implementation <code>IncidentServiceImpl</code> in the folder
<code>src/main/java/org/apache/camel/example/reportincident/service</code> </p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">
+<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[
package org.apache.camel.example.reportincident.service.impl;
import java.util.List;
@@ -887,19 +887,19 @@ public class IncidentServiceImpl impleme
}
}
-</pre>
+]]></script>
</div></div>
<p>The same remark as explained previously applies here concerning the DAO
injection. So, you will create the following file
<code>spring-service-beans-dao.xml</code> in the folder
<code>src/main/resources/META-INF/spring</code> to inject the dependency of the
DAO to our service.</p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<pre class="brush: xml; gutter: false; theme: Default" style="font-size:12px;">
- <bean id="incidentServiceTarget"
class="org.apache.camel.example.reportincident.service.impl.IncidentServiceImpl">
- <property name="incidentDAO">
+<script class="brush: xml; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[
+ <bean id="incidentServiceTarget"
class="org.apache.camel.example.reportincident.service.impl.IncidentServiceImpl">
+ <property name="incidentDAO">
...
</property>
</bean>
-</pre>
+]]></script>
</div></div>
<p>Obviously, this file is not complete because the reference of the DAO class
is not mentioned except the property name. Don't panic, we will come back later
on when we will discuss Spring Blueprint services.</p>
@@ -912,37 +912,37 @@ public class IncidentServiceImpl impleme
<p>To generate the code that our application will use, we will work with
following WSDL contract <code>report_incident.wsdl</code> that you create in
the directory <code>src/main/resources/META-INF/wsdl</code>:</p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<pre class="brush: xml; gutter: false; theme: Default" style="font-size:12px;">
-<?xml version="1.0" encoding="UTF-8"?>
+<script class="brush: xml; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[
+<?xml version="1.0" encoding="UTF-8"?>
-<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
- xmlns:tns="http://reportincident.example.camel.apache.org"
- xmlns:xs="http://www.w3.org/2001/XMLSchema"
- xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
- xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
- targetNamespace="http://reportincident.example.camel.apache.org">
+<wsdl:definitions
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:tns="http://reportincident.example.camel.apache.org"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+
targetNamespace="http://reportincident.example.camel.apache.org">
<!-- Type definitions for input- and output parameters for webservice
-->
<wsdl:types>
- <xs:schema
targetNamespace="http://reportincident.example.camel.apache.org">
- <xs:element name="inputReportIncident">
- <xs:complexType name="inputReportIncident">
+ <xs:schema
targetNamespace="http://reportincident.example.camel.apache.org">
+ <xs:element name="inputReportIncident">
+ <xs:complexType name="inputReportIncident">
<xs:sequence>
- <xs:element type="xs:string" name="incidentId"/>
- <xs:element type="xs:string"
name="incidentDate"/>
- <xs:element type="xs:string" name="givenName"/>
- <xs:element type="xs:string" name="familyName"/>
- <xs:element type="xs:string" name="summary"/>
- <xs:element type="xs:string" name="details"/>
- <xs:element type="xs:string" name="email"/>
- <xs:element type="xs:string" name="phone"/>
+ <xs:element type="xs:string"
name="incidentId"/>
+ <xs:element type="xs:string"
name="incidentDate"/>
+ <xs:element type="xs:string"
name="givenName"/>
+ <xs:element type="xs:string"
name="familyName"/>
+ <xs:element type="xs:string"
name="summary"/>
+ <xs:element type="xs:string"
name="details"/>
+ <xs:element type="xs:string"
name="email"/>
+ <xs:element type="xs:string"
name="phone"/>
</xs:sequence>
</xs:complexType>
</xs:element>
- <xs:element name="outputReportIncident">
- <xs:complexType name="outputReportIncident">
+ <xs:element name="outputReportIncident">
+ <xs:complexType name="outputReportIncident">
<xs:sequence>
- <xs:element type="xs:string" name="code"/>
+ <xs:element type="xs:string"
name="code"/>
</xs:sequence>
</xs:complexType>
</xs:element>
@@ -950,52 +950,52 @@ public class IncidentServiceImpl impleme
</wsdl:types>
<!-- Message definitions for input and output -->
- <wsdl:message name="inputReportIncident">
- <wsdl:part name="in" element="tns:inputReportIncident"/>
+ <wsdl:message name="inputReportIncident">
+ <wsdl:part name="in"
element="tns:inputReportIncident"/>
</wsdl:message>
- <wsdl:message name="outputReportIncident">
- <wsdl:part name="out" element="tns:outputReportIncident"/>
+ <wsdl:message name="outputReportIncident">
+ <wsdl:part name="out"
element="tns:outputReportIncident"/>
</wsdl:message>
<!-- Port (interface) definitions -->
- <wsdl:portType name="ReportIncidentEndpoint">
- <wsdl:operation name="ReportIncident">
- <wsdl:input message="tns:inputReportIncident"/>
- <wsdl:output message="tns:outputReportIncident"/>
+ <wsdl:portType name="ReportIncidentEndpoint">
+ <wsdl:operation name="ReportIncident">
+ <wsdl:input message="tns:inputReportIncident"/>
+ <wsdl:output message="tns:outputReportIncident"/>
</wsdl:operation>
</wsdl:portType>
<!-- Port bindings to transports and encoding - HTTP, document literal
encoding is used -->
- <wsdl:binding name="ReportIncidentBinding"
type="tns:ReportIncidentEndpoint">
- <soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
- <wsdl:operation name="ReportIncident">
+ <wsdl:binding name="ReportIncidentBinding"
type="tns:ReportIncidentEndpoint">
+ <soap:binding
transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="ReportIncident">
<soap:operation
-
soapAction="http://reportincident.example.camel.apache.org/ReportIncident"
- style="document"/>
+
soapAction="http://reportincident.example.camel.apache.org/ReportIncident"
+ style="document"/>
<wsdl:input>
- <soap:body parts="in" use="literal"/>
+ <soap:body parts="in" use="literal"/>
</wsdl:input>
<wsdl:output>
- <soap:body parts="out" use="literal"/>
+ <soap:body parts="out"
use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<!-- Service definition -->
- <wsdl:service name="ReportIncidentEndpointService">
- <wsdl:port name="ReportIncidentPort"
binding="tns:ReportIncidentBinding">
- <soap:address
location="http://localhost:8080/camel-example/incident"/>
+ <wsdl:service name="ReportIncidentEndpointService">
+ <wsdl:port name="ReportIncidentPort"
binding="tns:ReportIncidentBinding">
+ <soap:address
location="http://localhost:8080/camel-example/incident"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
-</pre>
+]]></script>
</div></div>
<p>The code will be generated thanks to a maven plugin :
cxf-codegen-plugin.</p>
<p>Add the following line in your <code>pom.xml</code> of the project
<code>reportincident.webservice</code></p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<pre class="brush: xml; gutter: false; theme: Default" style="font-size:12px;">
+<script class="brush: xml; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[
<!-- CXF wsdl2java generator, will plugin to the compile goal -->
<plugin>
<groupId>org.apache.cxf</groupId>
@@ -1020,13 +1020,13 @@ public class IncidentServiceImpl impleme
</executions>
</plugin>
-</pre>
+]]></script>
</div></div>
<p>The code is generated using the maven command :</p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">
+<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[
mvn generate-sources
-</pre>
+]]></script>
</div></div>
<p>Remark : the code is generated in the directory
<code>target/src/main/java</code></p>
@@ -1041,7 +1041,7 @@ mvn generate-sources
<ul class="alternate"><li>Part 2 : real example, architecture, project setup,
database creation</li><li><a shape="rect"
href="tutorial-osgi-camel-part2a.html">Part 2a : transform projects in
bundles</a></li><li><a shape="rect" href="tutorial-osgi-camel-part2b.html">Part
2b : add infrastructure and routing</a></li><li><a shape="rect"
href="tutorial-osgi-camel-part2c.html">Part 2c : web and
deployment</a></li></ul>
-<h2 id="tutorial-osgi-camel-part2-#Resources"><a shape="rect"
href="tutorial-osgi-camel-part2.html">#Resources</a></h2>
+<h2 id="tutorial-osgi-camel-part2-#Resources"><a shape="rect"
href="#tutorial-osgi-camel-part2-Resources">#Resources</a></h2>
<ul><li>
@@ -1053,7 +1053,7 @@ mvn generate-sources
<input type="hidden" class="plugin_attachments_macro_render_param"
name="pageId" value="113428">
<input type="hidden" name="deleteConfirmMessage" value="Are you
sure you want to send the attached file " _0="_0" to="to" the="the"
trash="trash" only="only" a="a" space="space" administrator="administrator"
can="can" undo="undo" this="this" action.="action.">
<input type="hidden"
class="plugin_attachments_macro_render_param" name="patterns"
value=".*part2.zip">
- <input
type="hidden" name="outputType" value="email">
+ <input
type="hidden" name="outputType" value="display">
</fieldset>
@@ -1082,7 +1082,7 @@ mvn generate-sources
</td><td colspan="1" rowspan="1"
class="attachment-created modified-column">
<span>Apr 01, 2010</span>
<span>by</span>
- <a shape="rect" class="url fn confluence-userlink"
href="https://cwiki.apache.org/confluence/display/~cmoulliard">charles
Moulliard</a> </td></tr><tr class="attachment-summary
attachment-summary-14975065 hidden" data-attachment-id="14975065"
data-attachment-filename="tutorial-osgi-camel-part2.zip"><td colspan="1"
rowspan="1" class="attachment-summary-toggle"></td><td colspan="2" rowspan="1"
class="attachment-details-wrapper">
+ <a shape="rect" class="url fn confluence-userlink"
href=" /confluence/display/~cmoulliard ">charles Moulliard</a>
</td></tr><tr class="attachment-summary attachment-summary-14975065 hidden"
data-attachment-id="14975065"
data-attachment-filename="tutorial-osgi-camel-part2.zip"><td colspan="1"
rowspan="1" class="attachment-summary-toggle"></td><td colspan="2" rowspan="1"
class="attachment-details-wrapper">
<p class="attachment-labels">Labels</p>
@@ -1122,7 +1122,7 @@ mvn generate-sources
<div class="navigation">
<div class="navigation_top">
<!-- NavigationBar -->
-<div class="navigation_bottom" id="navigation_bottom"><h3
id="Navigation-Overviewhttps://cwiki.apache.org/confluence/pages/viewpage.action?pageId=49132"><a
shape="rect" href="overview.html">Overview</a></h3><ul
class="alternate"><li><a shape="rect" href="index.html">Home</a></li><li><a
shape="rect" href="download.html">Download</a></li><li><a shape="rect"
href="getting-started.html">Getting Started</a></li><li><a shape="rect"
href="faq.html">FAQ</a></li></ul><h3
id="Navigation-Documentationhttps://cwiki.apache.org/confluence/pages/viewpage.action?pageId=49534"><a
shape="rect" href="documentation.html">Documentation</a></h3><ul
class="alternate"><li><a shape="rect" href="user-guide.html">User
Guide</a></li><li><a shape="rect" href="manual.html">Manual</a></li><li><a
shape="rect" href="books.html">Books</a></li><li><a shape="rect"
href="tutorials.html">Tutorials</a></li><li><a shape="rect"
href="examples.html">Examples</a></li><li><a shape="rect"
href="cookbook.html">Cookbook</a></li>
<li><a shape="rect" href="architecture.html">Architecture</a></li><li><a
shape="rect" href="enterprise-integration-patterns.html">Enterprise Integration
Patterns</a></li><li><a shape="rect" href="dsl.html">DSL</a></li><li><a
shape="rect" href="components.html">Components</a></li><li><a shape="rect"
href="data-format.html">Data Format</a></li><li><a shape="rect"
href="languages.html">Languages</a></li><li><a shape="rect"
href="security.html">Security</a></li><li><a shape="rect"
href="security-advisories.html">Security Advisories</a></li></ul><h3
id="Navigation-Search">Search</h3><form
enctype="application/x-www-form-urlencoded" method="get" id="cse-search-box"
action="http://www.google.com/cse">
+<div class="navigation_bottom" id="navigation_bottom"><h3
id="Navigation-Overview"><a shape="rect"
href="overview.html">Overview</a></h3><ul class="alternate"><li><a shape="rect"
href="index.html">Home</a></li><li><a shape="rect"
href="download.html">Download</a></li><li><a shape="rect"
href="getting-started.html">Getting Started</a></li><li><a shape="rect"
href="faq.html">FAQ</a></li></ul><h3 id="Navigation-Documentation"><a
shape="rect" href="documentation.html">Documentation</a></h3><ul
class="alternate"><li><a shape="rect" href="user-guide.html">User
Guide</a></li><li><a shape="rect" href="manual.html">Manual</a></li><li><a
shape="rect" href="books.html">Books</a></li><li><a shape="rect"
href="tutorials.html">Tutorials</a></li><li><a shape="rect"
href="examples.html">Examples</a></li><li><a shape="rect"
href="cookbook.html">Cookbook</a></li><li><a shape="rect"
href="architecture.html">Architecture</a></li><li><a shape="rect"
href="enterprise-integration-patterns.html">Enterprise
Integration Patterns</a></li><li><a shape="rect"
href="dsl.html">DSL</a></li><li><a shape="rect"
href="components.html">Components</a></li><li><a shape="rect"
href="data-format.html">Data Format</a></li><li><a shape="rect"
href="languages.html">Languages</a></li><li><a shape="rect"
href="security.html">Security</a></li><li><a shape="rect"
href="security-advisories.html">Security Advisories</a></li></ul><h3
id="Navigation-Search">Search</h3><form
enctype="application/x-www-form-urlencoded" method="get" id="cse-search-box"
action="http://www.google.com/cse">
<div>
<input type="hidden" name="cx" value="007878419884033443453:m5nhvy4hmyq">
<input type="hidden" name="ie" value="UTF-8">
@@ -1130,7 +1130,7 @@ mvn generate-sources
<input type="submit" name="sa" value="Search">
</div>
</form>
-<script type="text/javascript"
src="http://www.google.com/coop/cse/brand?form=cse-search-box&lang=en"></script><h3
id="Navigation-Communityhttps://cwiki.apache.org/confluence/pages/viewpage.action?pageId=49115"><a
shape="rect" href="community.html">Community</a></h3><ul
class="alternate"><li><a shape="rect"
href="support.html">Support</a></li><li><a shape="rect"
href="contributing.html">Contributing</a></li><li><a shape="rect"
href="discussion-forums.html">Discussion Forums</a></li><li><a shape="rect"
href="mailing-lists.html">Mailing Lists</a></li><li><a shape="rect"
href="user-stories.html">User Stories</a></li><li><a shape="rect"
href="news.html">News</a></li><li><a shape="rect"
href="articles.html">Articles</a></li><li><a shape="rect"
href="site.html">Site</a></li><li><a shape="rect"
href="team.html">Team</a></li><li><a shape="rect" class="external-link"
href="http://camel-extra.googlecode.com/" rel="nofollow">Camel
Extra</a></li></ul><h3 id="Navigation-Developershttps://cwi
ki.apache.org/confluence/pages/viewpage.action?pageId=49124"><a shape="rect"
href="developers.html">Developers</a></h3><ul class="alternate"><li><a
shape="rect" href="developers.html">Developer Guide</a></li><li><a shape="rect"
href="source.html">Source</a></li><li><a shape="rect"
href="building.html">Building</a></li><li><a shape="rect"
href="javadoc.html">JavaDoc</a></li><li><a shape="rect"
href="irc-room.html">IRC Room</a></li></ul><h3
id="Navigation-ApacheSoftwareFoundation">Apache Software Foundation</h3><ul
class="alternate"><li><a shape="rect" class="external-link"
href="http://www.apache.org/licenses/">License</a></li><li><a shape="rect"
class="external-link"
href="http://www.apache.org/foundation/sponsorship.html">Sponsorship</a></li><li><a
shape="rect" class="external-link"
href="http://www.apache.org/foundation/thanks.html">Thanks</a></li><li><a
shape="rect" class="external-link"
href="http://www.apache.org/security/">Security</a></li></ul></div>
+<script type="text/javascript"
src="http://www.google.com/coop/cse/brand?form=cse-search-box&lang=en"></script><h3
id="Navigation-Community"><a shape="rect"
href="community.html">Community</a></h3><ul class="alternate"><li><a
shape="rect" href="support.html">Support</a></li><li><a shape="rect"
href="contributing.html">Contributing</a></li><li><a shape="rect"
href="discussion-forums.html">Discussion Forums</a></li><li><a shape="rect"
href="mailing-lists.html">Mailing Lists</a></li><li><a shape="rect"
href="user-stories.html">User Stories</a></li><li><a shape="rect"
href="news.html">News</a></li><li><a shape="rect"
href="articles.html">Articles</a></li><li><a shape="rect"
href="site.html">Site</a></li><li><a shape="rect"
href="team.html">Team</a></li><li><a shape="rect" class="external-link"
href="http://camel-extra.googlecode.com/" rel="nofollow">Camel
Extra</a></li></ul><h3 id="Navigation-Developers"><a shape="rect"
href="developers.html">Developers</a></h3><ul class="alternate"
><li><a shape="rect" href="developers.html">Developer Guide</a></li><li><a
>shape="rect" href="source.html">Source</a></li><li><a shape="rect"
>href="building.html">Building</a></li><li><a shape="rect"
>href="javadoc.html">JavaDoc</a></li><li><a shape="rect"
>href="irc-room.html">IRC Room</a></li></ul><h3
>id="Navigation-ApacheSoftwareFoundation">Apache Software Foundation</h3><ul
>class="alternate"><li><a shape="rect" class="external-link"
>href="http://www.apache.org/licenses/">License</a></li><li><a shape="rect"
>class="external-link"
>href="http://www.apache.org/foundation/sponsorship.html">Sponsorship</a></li><li><a
> shape="rect" class="external-link"
>href="http://www.apache.org/foundation/thanks.html">Thanks</a></li><li><a
>shape="rect" class="external-link"
>href="http://www.apache.org/security/">Security</a></li></ul></div>
<!-- NavigationBar -->
</div>
</div>
Modified:
websites/production/camel/content/unsupported-groovy-dsl-features-on-web-console.html
==============================================================================
---
websites/production/camel/content/unsupported-groovy-dsl-features-on-web-console.html
(original)
+++
websites/production/camel/content/unsupported-groovy-dsl-features-on-web-console.html
Tue Sep 22 14:26:24 2015
@@ -94,14 +94,14 @@
<p>When writing a route in Java DSL, we often create new classes. For example,
we may create a processor as follows:</p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">
-from("direct:start").process(new Processor() {
+<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[
+from("direct:start").process(new Processor() {
public void process(Exchange exchange) {
Message in = exchange.getIn();
- in.setBody(in.getBody(String.class) + " World!");
+ in.setBody(in.getBody(String.class) + " World!");
}
-}).to("mock:result");
-</pre>
+}).to("mock:result");
+]]></script>
</div></div>
<p>Here an anonymous inner class is created to process the message. But this
feature is not supported on <a shape="rect" href="web-console.html">Web
Console</a> since it use a groovy class loader to parse the route content and
you should use groovy grammar to build the processor. <br clear="none">
Using a bundle of anonymous inner classes may cause you to lost the route
definition after creating them because <a shape="rect"
href="web-console.html">Web Console</a> can't render them in the view/edit
operations.</p>
@@ -113,19 +113,19 @@ Using a bundle of anonymous inner classe
<p>This feature also appears frequently. In the try...catch DSL or onException
DSL, we may use some external or custom exception classes. But current groovy
renderer doesn't process the import packages, so you should manually add the
import lines each time you edit it. Another problem is that groovy renderer
can't return the instance name of that class. For example, you may define a
route like:</p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">
+<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[
import org.apache.camel.*;
import org.apache.camel.processor.*;
import org.apache.camel.language.groovy.GroovyRouteBuilder;
class GroovyRoute extends GroovyRouteBuilder {
void configure() {
MyValidator validator = new MyValidator();
- from("direct:start")
- .doTry().process(validator).to("mock:valid")
- .doCatch(ValidationException.class).to("mock:invalid")
+ from("direct:start")
+ .doTry().process(validator).to("mock:valid")
+ .doCatch(ValidationException.class).to("mock:invalid")
}
}
-</pre>
+]]></script>
</div></div>
<p>For this route, groovy renderer can't return the name: validator and it
only know there is a processor instance here.</p>
@@ -138,15 +138,15 @@ class GroovyRoute extends GroovyRouteBui
<p>The <a shape="rect" href="web-console.html">Web Console</a> parses routes
in groovy language by using the <a shape="rect" class="external-link"
href="http://camel.apache.org/maven/current/camel-groovy/apidocs/org/apache/camel/language/groovy/GroovyRouteBuilder.html">GroovyRouteBuilder</a>
in camel-groovy component. GroovyRouteBuilder uses the ConfigureCamel to
dynamically add methods for the route configuration behaviors. Currently it has
added closure for filter and when DSL. So you can use two method to defined a
filter through <a shape="rect" href="web-console.html">Web Console</a>:</p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">
-from("direct:start").filter(header("foo").isEqualTo("bar")).to("mock:result")
-</pre>
+<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[
+from("direct:start").filter(header("foo").isEqualTo("bar")).to("mock:result")
+]]></script>
</div></div>
<p>or</p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">
-from("direct:start").filter {e -> e.in.headers.foo ==
"bar"}.to("mock:result")
-</pre>
+<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[
+from("direct:start").filter {e -> e.in.headers.foo ==
"bar"}.to("mock:result")
+]]></script>
</div></div>
<p>However, groovy renderer can only render the first filter because a closure
is unreadable in <a shape="rect" class="unresolved" href="#">Camel
Context</a>.</p>
@@ -161,7 +161,7 @@ from("direct:start").filter {e -> e.i
<div class="navigation">
<div class="navigation_top">
<!-- NavigationBar -->
-<div class="navigation_bottom" id="navigation_bottom"><h3
id="Navigation-Overviewhttps://cwiki.apache.org/confluence/pages/viewpage.action?pageId=49132"><a
shape="rect" href="overview.html">Overview</a></h3><ul
class="alternate"><li><a shape="rect" href="index.html">Home</a></li><li><a
shape="rect" href="download.html">Download</a></li><li><a shape="rect"
href="getting-started.html">Getting Started</a></li><li><a shape="rect"
href="faq.html">FAQ</a></li></ul><h3
id="Navigation-Documentationhttps://cwiki.apache.org/confluence/pages/viewpage.action?pageId=49534"><a
shape="rect" href="documentation.html">Documentation</a></h3><ul
class="alternate"><li><a shape="rect" href="user-guide.html">User
Guide</a></li><li><a shape="rect" href="manual.html">Manual</a></li><li><a
shape="rect" href="books.html">Books</a></li><li><a shape="rect"
href="tutorials.html">Tutorials</a></li><li><a shape="rect"
href="examples.html">Examples</a></li><li><a shape="rect"
href="cookbook.html">Cookbook</a></li>
<li><a shape="rect" href="architecture.html">Architecture</a></li><li><a
shape="rect" href="enterprise-integration-patterns.html">Enterprise Integration
Patterns</a></li><li><a shape="rect" href="dsl.html">DSL</a></li><li><a
shape="rect" href="components.html">Components</a></li><li><a shape="rect"
href="data-format.html">Data Format</a></li><li><a shape="rect"
href="languages.html">Languages</a></li><li><a shape="rect"
href="security.html">Security</a></li><li><a shape="rect"
href="security-advisories.html">Security Advisories</a></li></ul><h3
id="Navigation-Search">Search</h3><form
enctype="application/x-www-form-urlencoded" method="get" id="cse-search-box"
action="http://www.google.com/cse">
+<div class="navigation_bottom" id="navigation_bottom"><h3
id="Navigation-Overview"><a shape="rect"
href="overview.html">Overview</a></h3><ul class="alternate"><li><a shape="rect"
href="index.html">Home</a></li><li><a shape="rect"
href="download.html">Download</a></li><li><a shape="rect"
href="getting-started.html">Getting Started</a></li><li><a shape="rect"
href="faq.html">FAQ</a></li></ul><h3 id="Navigation-Documentation"><a
shape="rect" href="documentation.html">Documentation</a></h3><ul
class="alternate"><li><a shape="rect" href="user-guide.html">User
Guide</a></li><li><a shape="rect" href="manual.html">Manual</a></li><li><a
shape="rect" href="books.html">Books</a></li><li><a shape="rect"
href="tutorials.html">Tutorials</a></li><li><a shape="rect"
href="examples.html">Examples</a></li><li><a shape="rect"
href="cookbook.html">Cookbook</a></li><li><a shape="rect"
href="architecture.html">Architecture</a></li><li><a shape="rect"
href="enterprise-integration-patterns.html">Enterprise
Integration Patterns</a></li><li><a shape="rect"
href="dsl.html">DSL</a></li><li><a shape="rect"
href="components.html">Components</a></li><li><a shape="rect"
href="data-format.html">Data Format</a></li><li><a shape="rect"
href="languages.html">Languages</a></li><li><a shape="rect"
href="security.html">Security</a></li><li><a shape="rect"
href="security-advisories.html">Security Advisories</a></li></ul><h3
id="Navigation-Search">Search</h3><form
enctype="application/x-www-form-urlencoded" method="get" id="cse-search-box"
action="http://www.google.com/cse">
<div>
<input type="hidden" name="cx" value="007878419884033443453:m5nhvy4hmyq">
<input type="hidden" name="ie" value="UTF-8">
@@ -169,7 +169,7 @@ from("direct:start").filter {e -> e.i
<input type="submit" name="sa" value="Search">
</div>
</form>
-<script type="text/javascript"
src="http://www.google.com/coop/cse/brand?form=cse-search-box&lang=en"></script><h3
id="Navigation-Communityhttps://cwiki.apache.org/confluence/pages/viewpage.action?pageId=49115"><a
shape="rect" href="community.html">Community</a></h3><ul
class="alternate"><li><a shape="rect"
href="support.html">Support</a></li><li><a shape="rect"
href="contributing.html">Contributing</a></li><li><a shape="rect"
href="discussion-forums.html">Discussion Forums</a></li><li><a shape="rect"
href="mailing-lists.html">Mailing Lists</a></li><li><a shape="rect"
href="user-stories.html">User Stories</a></li><li><a shape="rect"
href="news.html">News</a></li><li><a shape="rect"
href="articles.html">Articles</a></li><li><a shape="rect"
href="site.html">Site</a></li><li><a shape="rect"
href="team.html">Team</a></li><li><a shape="rect" class="external-link"
href="http://camel-extra.googlecode.com/" rel="nofollow">Camel
Extra</a></li></ul><h3 id="Navigation-Developershttps://cwi
ki.apache.org/confluence/pages/viewpage.action?pageId=49124"><a shape="rect"
href="developers.html">Developers</a></h3><ul class="alternate"><li><a
shape="rect" href="developers.html">Developer Guide</a></li><li><a shape="rect"
href="source.html">Source</a></li><li><a shape="rect"
href="building.html">Building</a></li><li><a shape="rect"
href="javadoc.html">JavaDoc</a></li><li><a shape="rect"
href="irc-room.html">IRC Room</a></li></ul><h3
id="Navigation-ApacheSoftwareFoundation">Apache Software Foundation</h3><ul
class="alternate"><li><a shape="rect" class="external-link"
href="http://www.apache.org/licenses/">License</a></li><li><a shape="rect"
class="external-link"
href="http://www.apache.org/foundation/sponsorship.html">Sponsorship</a></li><li><a
shape="rect" class="external-link"
href="http://www.apache.org/foundation/thanks.html">Thanks</a></li><li><a
shape="rect" class="external-link"
href="http://www.apache.org/security/">Security</a></li></ul></div>
+<script type="text/javascript"
src="http://www.google.com/coop/cse/brand?form=cse-search-box&lang=en"></script><h3
id="Navigation-Community"><a shape="rect"
href="community.html">Community</a></h3><ul class="alternate"><li><a
shape="rect" href="support.html">Support</a></li><li><a shape="rect"
href="contributing.html">Contributing</a></li><li><a shape="rect"
href="discussion-forums.html">Discussion Forums</a></li><li><a shape="rect"
href="mailing-lists.html">Mailing Lists</a></li><li><a shape="rect"
href="user-stories.html">User Stories</a></li><li><a shape="rect"
href="news.html">News</a></li><li><a shape="rect"
href="articles.html">Articles</a></li><li><a shape="rect"
href="site.html">Site</a></li><li><a shape="rect"
href="team.html">Team</a></li><li><a shape="rect" class="external-link"
href="http://camel-extra.googlecode.com/" rel="nofollow">Camel
Extra</a></li></ul><h3 id="Navigation-Developers"><a shape="rect"
href="developers.html">Developers</a></h3><ul class="alternate"
><li><a shape="rect" href="developers.html">Developer Guide</a></li><li><a
>shape="rect" href="source.html">Source</a></li><li><a shape="rect"
>href="building.html">Building</a></li><li><a shape="rect"
>href="javadoc.html">JavaDoc</a></li><li><a shape="rect"
>href="irc-room.html">IRC Room</a></li></ul><h3
>id="Navigation-ApacheSoftwareFoundation">Apache Software Foundation</h3><ul
>class="alternate"><li><a shape="rect" class="external-link"
>href="http://www.apache.org/licenses/">License</a></li><li><a shape="rect"
>class="external-link"
>href="http://www.apache.org/foundation/sponsorship.html">Sponsorship</a></li><li><a
> shape="rect" class="external-link"
>href="http://www.apache.org/foundation/thanks.html">Thanks</a></li><li><a
>shape="rect" class="external-link"
>href="http://www.apache.org/security/">Security</a></li></ul></div>
<!-- NavigationBar -->
</div>
</div>
Modified: websites/production/camel/content/upgrade-dependency-guide.html
==============================================================================
--- websites/production/camel/content/upgrade-dependency-guide.html (original)
+++ websites/production/camel/content/upgrade-dependency-guide.html Tue Sep 22
14:26:24 2015
@@ -106,24 +106,24 @@ The issue type should be "Task". A sampl
<h2 id="Upgradedependencyguide-6.Validatethefeatures.xml(ifnecessary)">6.
Validate the features.xml (if necessary)</h2>
<p>If you change anything in the features.xml from platform/karaf you should
run a validation test to ensure the generated features.xml file is correct. You
can do this running the following maven goal from the platform directory.</p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">
+<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[
mvn clean install -Pvalidate
-</pre>
+]]></script>
</div></div>
<h2 id="Upgradedependencyguide-7.Runacompletebuild">7. Run a complete
build</h2>
<p>To ensure you don't break anything with your upgrade, run a complete build
from the Camel root directory:</p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">
+<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[
mvn clean install
-</pre>
+]]></script>
</div></div></div>
</td>
<td valign="top">
<div class="navigation">
<div class="navigation_top">
<!-- NavigationBar -->
-<div class="navigation_bottom" id="navigation_bottom"><h3
id="Navigation-Overviewhttps://cwiki.apache.org/confluence/pages/viewpage.action?pageId=49132"><a
shape="rect" href="overview.html">Overview</a></h3><ul
class="alternate"><li><a shape="rect" href="index.html">Home</a></li><li><a
shape="rect" href="download.html">Download</a></li><li><a shape="rect"
href="getting-started.html">Getting Started</a></li><li><a shape="rect"
href="faq.html">FAQ</a></li></ul><h3
id="Navigation-Documentationhttps://cwiki.apache.org/confluence/pages/viewpage.action?pageId=49534"><a
shape="rect" href="documentation.html">Documentation</a></h3><ul
class="alternate"><li><a shape="rect" href="user-guide.html">User
Guide</a></li><li><a shape="rect" href="manual.html">Manual</a></li><li><a
shape="rect" href="books.html">Books</a></li><li><a shape="rect"
href="tutorials.html">Tutorials</a></li><li><a shape="rect"
href="examples.html">Examples</a></li><li><a shape="rect"
href="cookbook.html">Cookbook</a></li>
<li><a shape="rect" href="architecture.html">Architecture</a></li><li><a
shape="rect" href="enterprise-integration-patterns.html">Enterprise Integration
Patterns</a></li><li><a shape="rect" href="dsl.html">DSL</a></li><li><a
shape="rect" href="components.html">Components</a></li><li><a shape="rect"
href="data-format.html">Data Format</a></li><li><a shape="rect"
href="languages.html">Languages</a></li><li><a shape="rect"
href="security.html">Security</a></li><li><a shape="rect"
href="security-advisories.html">Security Advisories</a></li></ul><h3
id="Navigation-Search">Search</h3><form
enctype="application/x-www-form-urlencoded" method="get" id="cse-search-box"
action="http://www.google.com/cse">
+<div class="navigation_bottom" id="navigation_bottom"><h3
id="Navigation-Overview"><a shape="rect"
href="overview.html">Overview</a></h3><ul class="alternate"><li><a shape="rect"
href="index.html">Home</a></li><li><a shape="rect"
href="download.html">Download</a></li><li><a shape="rect"
href="getting-started.html">Getting Started</a></li><li><a shape="rect"
href="faq.html">FAQ</a></li></ul><h3 id="Navigation-Documentation"><a
shape="rect" href="documentation.html">Documentation</a></h3><ul
class="alternate"><li><a shape="rect" href="user-guide.html">User
Guide</a></li><li><a shape="rect" href="manual.html">Manual</a></li><li><a
shape="rect" href="books.html">Books</a></li><li><a shape="rect"
href="tutorials.html">Tutorials</a></li><li><a shape="rect"
href="examples.html">Examples</a></li><li><a shape="rect"
href="cookbook.html">Cookbook</a></li><li><a shape="rect"
href="architecture.html">Architecture</a></li><li><a shape="rect"
href="enterprise-integration-patterns.html">Enterprise
Integration Patterns</a></li><li><a shape="rect"
href="dsl.html">DSL</a></li><li><a shape="rect"
href="components.html">Components</a></li><li><a shape="rect"
href="data-format.html">Data Format</a></li><li><a shape="rect"
href="languages.html">Languages</a></li><li><a shape="rect"
href="security.html">Security</a></li><li><a shape="rect"
href="security-advisories.html">Security Advisories</a></li></ul><h3
id="Navigation-Search">Search</h3><form
enctype="application/x-www-form-urlencoded" method="get" id="cse-search-box"
action="http://www.google.com/cse">
<div>
<input type="hidden" name="cx" value="007878419884033443453:m5nhvy4hmyq">
<input type="hidden" name="ie" value="UTF-8">
@@ -131,7 +131,7 @@ mvn clean install
<input type="submit" name="sa" value="Search">
</div>
</form>
-<script type="text/javascript"
src="http://www.google.com/coop/cse/brand?form=cse-search-box&lang=en"></script><h3
id="Navigation-Communityhttps://cwiki.apache.org/confluence/pages/viewpage.action?pageId=49115"><a
shape="rect" href="community.html">Community</a></h3><ul
class="alternate"><li><a shape="rect"
href="support.html">Support</a></li><li><a shape="rect"
href="contributing.html">Contributing</a></li><li><a shape="rect"
href="discussion-forums.html">Discussion Forums</a></li><li><a shape="rect"
href="mailing-lists.html">Mailing Lists</a></li><li><a shape="rect"
href="user-stories.html">User Stories</a></li><li><a shape="rect"
href="news.html">News</a></li><li><a shape="rect"
href="articles.html">Articles</a></li><li><a shape="rect"
href="site.html">Site</a></li><li><a shape="rect"
href="team.html">Team</a></li><li><a shape="rect" class="external-link"
href="http://camel-extra.googlecode.com/" rel="nofollow">Camel
Extra</a></li></ul><h3 id="Navigation-Developershttps://cwi
ki.apache.org/confluence/pages/viewpage.action?pageId=49124"><a shape="rect"
href="developers.html">Developers</a></h3><ul class="alternate"><li><a
shape="rect" href="developers.html">Developer Guide</a></li><li><a shape="rect"
href="source.html">Source</a></li><li><a shape="rect"
href="building.html">Building</a></li><li><a shape="rect"
href="javadoc.html">JavaDoc</a></li><li><a shape="rect"
href="irc-room.html">IRC Room</a></li></ul><h3
id="Navigation-ApacheSoftwareFoundation">Apache Software Foundation</h3><ul
class="alternate"><li><a shape="rect" class="external-link"
href="http://www.apache.org/licenses/">License</a></li><li><a shape="rect"
class="external-link"
href="http://www.apache.org/foundation/sponsorship.html">Sponsorship</a></li><li><a
shape="rect" class="external-link"
href="http://www.apache.org/foundation/thanks.html">Thanks</a></li><li><a
shape="rect" class="external-link"
href="http://www.apache.org/security/">Security</a></li></ul></div>
+<script type="text/javascript"
src="http://www.google.com/coop/cse/brand?form=cse-search-box&lang=en"></script><h3
id="Navigation-Community"><a shape="rect"
href="community.html">Community</a></h3><ul class="alternate"><li><a
shape="rect" href="support.html">Support</a></li><li><a shape="rect"
href="contributing.html">Contributing</a></li><li><a shape="rect"
href="discussion-forums.html">Discussion Forums</a></li><li><a shape="rect"
href="mailing-lists.html">Mailing Lists</a></li><li><a shape="rect"
href="user-stories.html">User Stories</a></li><li><a shape="rect"
href="news.html">News</a></li><li><a shape="rect"
href="articles.html">Articles</a></li><li><a shape="rect"
href="site.html">Site</a></li><li><a shape="rect"
href="team.html">Team</a></li><li><a shape="rect" class="external-link"
href="http://camel-extra.googlecode.com/" rel="nofollow">Camel
Extra</a></li></ul><h3 id="Navigation-Developers"><a shape="rect"
href="developers.html">Developers</a></h3><ul class="alternate"
><li><a shape="rect" href="developers.html">Developer Guide</a></li><li><a
>shape="rect" href="source.html">Source</a></li><li><a shape="rect"
>href="building.html">Building</a></li><li><a shape="rect"
>href="javadoc.html">JavaDoc</a></li><li><a shape="rect"
>href="irc-room.html">IRC Room</a></li></ul><h3
>id="Navigation-ApacheSoftwareFoundation">Apache Software Foundation</h3><ul
>class="alternate"><li><a shape="rect" class="external-link"
>href="http://www.apache.org/licenses/">License</a></li><li><a shape="rect"
>class="external-link"
>href="http://www.apache.org/foundation/sponsorship.html">Sponsorship</a></li><li><a
> shape="rect" class="external-link"
>href="http://www.apache.org/foundation/thanks.html">Thanks</a></li><li><a
>shape="rect" class="external-link"
>href="http://www.apache.org/security/">Security</a></li></ul></div>
<!-- NavigationBar -->
</div>
</div>
Modified:
websites/production/camel/content/using-getin-or-getout-methods-on-exchange.html
==============================================================================
---
websites/production/camel/content/using-getin-or-getout-methods-on-exchange.html
(original)
+++
websites/production/camel/content/using-getin-or-getout-methods-on-exchange.html
Tue Sep 22 14:26:24 2015
@@ -84,47 +84,47 @@
<tbody>
<tr>
<td valign="top" width="100%">
-<div class="wiki-content maincontent"><h2
id="UsinggetInorgetOutmethodsonExchange-MessageexchangepatternsandtheExchangeobject">Message
exchange patterns and the Exchange object</h2><p>The Camel API is influenced
by APIs such as <a shape="rect" class="external-link"
href="http://en.wikipedia.org/wiki/Java_Business_Integration"
rel="nofollow">JBI specification</a>, <a shape="rect"
href="http://cxf.apache.org/">CXF</a> which defines a concept called Message
Exchange Patterns (MEP for short).</p><p>The MEP defines the messaging style
used such as one-way (<a shape="rect" href="event-message.html">InOnly</a>) or
request-reply (<a shape="rect" href="request-reply.html">InOut</a>),<br
clear="none"> which means you have IN and optionally OUT messages. This closely
maps to other APIs such as WS, WSDL, REST, JBI and the likes.</p><p>The <a
shape="rect" href="exchange.html">Exchange</a> API provides two methods to get
a message, either <code>getIn</code> or <code>getOut</code>.<br clear="none"
> Obviously the <code>getIn</code> gets the IN message, and the
> <code>getOut</code> gets the OUT message.</p><h2
> id="UsinggetInorgetOutmethodsonExchange-Flowofanexchangethrougharoute">Flow
> of an exchange through a route</h2><p><span
> class="confluence-embedded-file-wrapper"><img
> class="confluence-embedded-image"
> src="using-getin-or-getout-methods-on-exchange.data/Message%20flow%20in%20Route.png"></span></p><ul
> class="alternate"><li>The out message from each step is used as the in
> message for the next step</li><li>if there is no out message then the in
> message is used instead</li><li>For the InOut MEP the out from the last step
> in the route is returned to the producer. In case of InOnly the last out is
> thrown away</li></ul><div class="confluence-information-macro
> confluence-information-macro-tip"><p class="title">Beware of getOut to check
> if there is an out message</p><span class="aui-icon aui-icon-small
> aui-iconfont-approve confluence-information-macro-icon"></span><div
> class="conflu
ence-information-macro-body"><p>exchange.getOut creates an out message if
there is none. So if you want to check if there is an out message then you
should use exchange.hasOut instead</p></div></div><h2
id="UsinggetInorgetOutmethodsonExchange-UsinggetInorgetOutmethodsonExchange">Using
getIn or getOut methods on Exchange</h2><p>Now suppose you want to use a Camel
<a shape="rect" href="processor.html">Processor</a> to adjust a message. This
can be done as follows:</p><div class="code panel pdl" style="border-width:
1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">public void process(Exchange exchange) throws Exception
{
+<div class="wiki-content maincontent"><h2
id="UsinggetInorgetOutmethodsonExchange-MessageexchangepatternsandtheExchangeobject">Message
exchange patterns and the Exchange object</h2><p>The Camel API is influenced
by APIs such as <a shape="rect" class="external-link"
href="http://en.wikipedia.org/wiki/Java_Business_Integration"
rel="nofollow">JBI specification</a>, <a shape="rect"
href="http://cxf.apache.org/">CXF</a> which defines a concept called Message
Exchange Patterns (MEP for short).</p><p>The MEP defines the messaging style
used such as one-way (<a shape="rect" href="event-message.html">InOnly</a>) or
request-reply (<a shape="rect" href="request-reply.html">InOut</a>),<br
clear="none"> which means you have IN and optionally OUT messages. This closely
maps to other APIs such as WS, WSDL, REST, JBI and the likes.</p><p>The <a
shape="rect" href="exchange.html">Exchange</a> API provides two methods to get
a message, either <code>getIn</code> or <code>getOut</code>.<br clear="none"
> Obviously the <code>getIn</code> gets the IN message, and the
> <code>getOut</code> gets the OUT message.</p><h2
> id="UsinggetInorgetOutmethodsonExchange-Flowofanexchangethrougharoute">Flow
> of an exchange through a route</h2><p><span
> class="confluence-embedded-file-wrapper"><img
> class="confluence-embedded-image"
> src="using-getin-or-getout-methods-on-exchange.data/Message%20flow%20in%20Route.png"
>
> data-image-src="/confluence/download/attachments/23338837/Message%20flow%20in%20Route.png?version=6&modificationDate=1434874475000&api=v2"
> data-unresolved-comment-count="0" data-linked-resource-id="24347145"
> data-linked-resource-version="6" data-linked-resource-type="attachment"
> data-linked-resource-default-alias="Message flow in Route.png"
> data-base-url="https://cwiki.apache.org/confluence"
> data-linked-resource-content-type="image/png"
> data-linked-resource-container-id="23338837"
> data-linked-resource-container-version="19"></span></p><ul
> class="alternate"><li>The out message from eac
h step is used as the in message for the next step</li><li>if there is no out
message then the in message is used instead</li><li>For the InOut MEP the out
from the last step in the route is returned to the producer. In case of InOnly
the last out is thrown away</li></ul><div class="confluence-information-macro
confluence-information-macro-tip"><p class="title">Beware of getOut to check if
there is an out message</p><span class="aui-icon aui-icon-small
aui-iconfont-approve confluence-information-macro-icon"></span><div
class="confluence-information-macro-body"><p>exchange.getOut creates an out
message if there is none. So if you want to check if there is an out message
then you should use exchange.hasOut instead</p></div></div><h2
id="UsinggetInorgetOutmethodsonExchange-UsinggetInorgetOutmethodsonExchange">Using
getIn or getOut methods on Exchange</h2><p>Now suppose you want to use a Camel
<a shape="rect" href="processor.html">Processor</a> to adjust a message. This
can be done as f
ollows:</p><div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
+<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[public void process(Exchange exchange) throws
Exception {
String body = exchange.getIn().getBody(String.class);
// change the message to say Hello
- exchange.getOut().setBody("Hello " + body);
+ exchange.getOut().setBody("Hello " + body);
}
-</pre>
+]]></script>
</div></div><p>This seems intuitive and is what you would expect is the
<em>right</em> approach to change a message from a <a shape="rect"
href="processor.html">Processor</a>.<br clear="none"> However there is an big
issue - the <code>getOut</code> method will create a new <a shape="rect"
href="message.html">Message</a>, which means any other information<br
clear="none"> from the IN message will not be propagated; which means you will
lose that data.<br clear="none"> To remedy this we'll have to copy the data
which is done as follows:</p><div class="code panel pdl" style="border-width:
1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">public void process(Exchange exchange) throws Exception
{
+<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[public void process(Exchange exchange) throws
Exception {
String body = exchange.getIn().getBody(String.class);
// change the message to say Hello
- exchange.getOut().setBody("Hello " + body);
+ exchange.getOut().setBody("Hello " + body);
// copy headers from IN to OUT to propagate them
exchange.getOut().setHeaders(exchange.getIn().getHeaders());
}
-</pre>
+]]></script>
</div></div><p>Well that is not all, a <a shape="rect"
href="message.html">Message</a> can also contain attachments so to be sure you
need to propagate those as well:</p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">public void process(Exchange exchange) throws Exception
{
+<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[public void process(Exchange exchange) throws
Exception {
String body = exchange.getIn().getBody(String.class);
// change the message to say Hello
- exchange.getOut().setBody("Hello " + body);
+ exchange.getOut().setBody("Hello " + body);
// copy headers from IN to OUT to propagate them
exchange.getOut().setHeaders(exchange.getIn().getHeaders();
// copy attachements from IN to OUT to propagate them
exchange.getOut().setAttachments(exchange.getIn().getAttachments());
}
-</pre>
+]]></script>
</div></div><p>Now we ensure that all additional data is propagated on the new
OUT message. But its a shame we need 2 code lines to ensure data is
propagated.<br clear="none"> What you can do instead is to change the IN
message instead, as shown below:</p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">public void process(Exchange exchange) throws Exception
{
+<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[public void process(Exchange exchange) throws
Exception {
String body = exchange.getIn().getBody(String.class);
// change the existing message to say Hello
- exchange.getIn().setBody("Hello " + body);
+ exchange.getIn().setBody("Hello " + body);
}
-</pre>
+]]></script>
</div></div><div class="confluence-information-macro
confluence-information-macro-tip"><p class="title">Consider using
getIn</p><span class="aui-icon aui-icon-small aui-iconfont-approve
confluence-information-macro-icon"></span><div
class="confluence-information-macro-body"><p>As shown above you most often need
to alter the existing IN message, than creating a totally new OUT message.<br
clear="none"> And therefore it's often easier just to adjust the IN message
directly.</p></div></div><p>Changing the IN message directly is possible in
Camel as it doesn't mind. Camel will detect that the <a shape="rect"
href="exchange.html">Exchange</a> has no OUT message<br clear="none"> and
therefore use the IN message instead.</p><h3
id="UsinggetInorgetOutmethodsonExchange-AboutMessageExchangePatternandgetOut">About
Message Exchange Pattern and getOut</h3><p>If the <a shape="rect"
href="exchange.html">Exchange</a> is using <code>InOnly</code> as the MEP, then
you may think that the <a shape="rec
t" href="exchange.html">Exchange</a> has no OUT message.<br clear="none"> But
you can still invoke the <code>getOut</code> method on <a shape="rect"
href="exchange.html">Exchange</a>; Camel will not barf.</p><p>So the example
code above is possible for any kind of MEP. The MEP is <em>just</em> a flag on
the <a shape="rect" href="exchange.html">Exchange</a> which the Consumer and
Producer adhere to.<br clear="none"> You can change the MEP on the <a
shape="rect" href="exchange.html">Exchange</a> using the
<code>setPattern</code> method. And likewise there is DSL to change it as
well.</p></div>
</td>
<td valign="top">
<div class="navigation">
<div class="navigation_top">
<!-- NavigationBar -->
-<div class="navigation_bottom" id="navigation_bottom"><h3
id="Navigation-Overviewhttps://cwiki.apache.org/confluence/pages/viewpage.action?pageId=49132"><a
shape="rect" href="overview.html">Overview</a></h3><ul
class="alternate"><li><a shape="rect" href="index.html">Home</a></li><li><a
shape="rect" href="download.html">Download</a></li><li><a shape="rect"
href="getting-started.html">Getting Started</a></li><li><a shape="rect"
href="faq.html">FAQ</a></li></ul><h3
id="Navigation-Documentationhttps://cwiki.apache.org/confluence/pages/viewpage.action?pageId=49534"><a
shape="rect" href="documentation.html">Documentation</a></h3><ul
class="alternate"><li><a shape="rect" href="user-guide.html">User
Guide</a></li><li><a shape="rect" href="manual.html">Manual</a></li><li><a
shape="rect" href="books.html">Books</a></li><li><a shape="rect"
href="tutorials.html">Tutorials</a></li><li><a shape="rect"
href="examples.html">Examples</a></li><li><a shape="rect"
href="cookbook.html">Cookbook</a></li>
<li><a shape="rect" href="architecture.html">Architecture</a></li><li><a
shape="rect" href="enterprise-integration-patterns.html">Enterprise Integration
Patterns</a></li><li><a shape="rect" href="dsl.html">DSL</a></li><li><a
shape="rect" href="components.html">Components</a></li><li><a shape="rect"
href="data-format.html">Data Format</a></li><li><a shape="rect"
href="languages.html">Languages</a></li><li><a shape="rect"
href="security.html">Security</a></li><li><a shape="rect"
href="security-advisories.html">Security Advisories</a></li></ul><h3
id="Navigation-Search">Search</h3><form
enctype="application/x-www-form-urlencoded" method="get" id="cse-search-box"
action="http://www.google.com/cse">
+<div class="navigation_bottom" id="navigation_bottom"><h3
id="Navigation-Overview"><a shape="rect"
href="overview.html">Overview</a></h3><ul class="alternate"><li><a shape="rect"
href="index.html">Home</a></li><li><a shape="rect"
href="download.html">Download</a></li><li><a shape="rect"
href="getting-started.html">Getting Started</a></li><li><a shape="rect"
href="faq.html">FAQ</a></li></ul><h3 id="Navigation-Documentation"><a
shape="rect" href="documentation.html">Documentation</a></h3><ul
class="alternate"><li><a shape="rect" href="user-guide.html">User
Guide</a></li><li><a shape="rect" href="manual.html">Manual</a></li><li><a
shape="rect" href="books.html">Books</a></li><li><a shape="rect"
href="tutorials.html">Tutorials</a></li><li><a shape="rect"
href="examples.html">Examples</a></li><li><a shape="rect"
href="cookbook.html">Cookbook</a></li><li><a shape="rect"
href="architecture.html">Architecture</a></li><li><a shape="rect"
href="enterprise-integration-patterns.html">Enterprise
Integration Patterns</a></li><li><a shape="rect"
href="dsl.html">DSL</a></li><li><a shape="rect"
href="components.html">Components</a></li><li><a shape="rect"
href="data-format.html">Data Format</a></li><li><a shape="rect"
href="languages.html">Languages</a></li><li><a shape="rect"
href="security.html">Security</a></li><li><a shape="rect"
href="security-advisories.html">Security Advisories</a></li></ul><h3
id="Navigation-Search">Search</h3><form
enctype="application/x-www-form-urlencoded" method="get" id="cse-search-box"
action="http://www.google.com/cse">
<div>
<input type="hidden" name="cx" value="007878419884033443453:m5nhvy4hmyq">
<input type="hidden" name="ie" value="UTF-8">
@@ -132,7 +132,7 @@
<input type="submit" name="sa" value="Search">
</div>
</form>
-<script type="text/javascript"
src="http://www.google.com/coop/cse/brand?form=cse-search-box&lang=en"></script><h3
id="Navigation-Communityhttps://cwiki.apache.org/confluence/pages/viewpage.action?pageId=49115"><a
shape="rect" href="community.html">Community</a></h3><ul
class="alternate"><li><a shape="rect"
href="support.html">Support</a></li><li><a shape="rect"
href="contributing.html">Contributing</a></li><li><a shape="rect"
href="discussion-forums.html">Discussion Forums</a></li><li><a shape="rect"
href="mailing-lists.html">Mailing Lists</a></li><li><a shape="rect"
href="user-stories.html">User Stories</a></li><li><a shape="rect"
href="news.html">News</a></li><li><a shape="rect"
href="articles.html">Articles</a></li><li><a shape="rect"
href="site.html">Site</a></li><li><a shape="rect"
href="team.html">Team</a></li><li><a shape="rect" class="external-link"
href="http://camel-extra.googlecode.com/" rel="nofollow">Camel
Extra</a></li></ul><h3 id="Navigation-Developershttps://cwi
ki.apache.org/confluence/pages/viewpage.action?pageId=49124"><a shape="rect"
href="developers.html">Developers</a></h3><ul class="alternate"><li><a
shape="rect" href="developers.html">Developer Guide</a></li><li><a shape="rect"
href="source.html">Source</a></li><li><a shape="rect"
href="building.html">Building</a></li><li><a shape="rect"
href="javadoc.html">JavaDoc</a></li><li><a shape="rect"
href="irc-room.html">IRC Room</a></li></ul><h3
id="Navigation-ApacheSoftwareFoundation">Apache Software Foundation</h3><ul
class="alternate"><li><a shape="rect" class="external-link"
href="http://www.apache.org/licenses/">License</a></li><li><a shape="rect"
class="external-link"
href="http://www.apache.org/foundation/sponsorship.html">Sponsorship</a></li><li><a
shape="rect" class="external-link"
href="http://www.apache.org/foundation/thanks.html">Thanks</a></li><li><a
shape="rect" class="external-link"
href="http://www.apache.org/security/">Security</a></li></ul></div>
+<script type="text/javascript"
src="http://www.google.com/coop/cse/brand?form=cse-search-box&lang=en"></script><h3
id="Navigation-Community"><a shape="rect"
href="community.html">Community</a></h3><ul class="alternate"><li><a
shape="rect" href="support.html">Support</a></li><li><a shape="rect"
href="contributing.html">Contributing</a></li><li><a shape="rect"
href="discussion-forums.html">Discussion Forums</a></li><li><a shape="rect"
href="mailing-lists.html">Mailing Lists</a></li><li><a shape="rect"
href="user-stories.html">User Stories</a></li><li><a shape="rect"
href="news.html">News</a></li><li><a shape="rect"
href="articles.html">Articles</a></li><li><a shape="rect"
href="site.html">Site</a></li><li><a shape="rect"
href="team.html">Team</a></li><li><a shape="rect" class="external-link"
href="http://camel-extra.googlecode.com/" rel="nofollow">Camel
Extra</a></li></ul><h3 id="Navigation-Developers"><a shape="rect"
href="developers.html">Developers</a></h3><ul class="alternate"
><li><a shape="rect" href="developers.html">Developer Guide</a></li><li><a
>shape="rect" href="source.html">Source</a></li><li><a shape="rect"
>href="building.html">Building</a></li><li><a shape="rect"
>href="javadoc.html">JavaDoc</a></li><li><a shape="rect"
>href="irc-room.html">IRC Room</a></li></ul><h3
>id="Navigation-ApacheSoftwareFoundation">Apache Software Foundation</h3><ul
>class="alternate"><li><a shape="rect" class="external-link"
>href="http://www.apache.org/licenses/">License</a></li><li><a shape="rect"
>class="external-link"
>href="http://www.apache.org/foundation/sponsorship.html">Sponsorship</a></li><li><a
> shape="rect" class="external-link"
>href="http://www.apache.org/foundation/thanks.html">Thanks</a></li><li><a
>shape="rect" class="external-link"
>href="http://www.apache.org/security/">Security</a></li></ul></div>
<!-- NavigationBar -->
</div>
</div>
Modified: websites/production/camel/content/velocity.html
==============================================================================
--- websites/production/camel/content/velocity.html (original)
+++ websites/production/camel/content/velocity.html Tue Sep 22 14:26:24 2015
@@ -157,7 +157,7 @@ private Exchange createLetter() {
public void testVelocityLetter() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(1);
- mock.expectedBodiesReceived("Dear Ibsen, Claus\n\nThanks for the
order of Camel in Action.\n\nRegards Camel Riders Bookstore\nPS: Next beer is
on me, James");
+ mock.message(0).body(String.class).contains("Thanks for the order of
Camel in Action");
template.send("direct:a", createLetter());