camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Camel > Class
Date Sat, 12 Jun 2010 17:09:00 GMT
<html>
<head>
    <base href="https://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/1810/9/1/_/styles/combined.css?spaceKey=CAMEL&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://cwiki.apache.org/confluence/display/CAMEL/Class">Class</a></h2>
    <h4>Page  <b>added</b> by             <a href="https://cwiki.apache.org/confluence/display/~davsclaus">Claus
Ibsen</a>
    </h4>
         <br/>
    <div class="notificationGreySide">
         <h2><a name="Class-ClassComponent"></a>Class Component</h2>
<p><b>Available as of Camel 2.4</b></p>

<p>The <b>class:</b> component binds beans to Camel message exchanges. It
works in the same way as the <a href="/confluence/display/CAMEL/Bean" title="Bean">Bean</a>
component but instead of looking up beans from a <a href="/confluence/display/CAMEL/Registry"
title="Registry">Registry</a> it creates the bean based on the class name.</p>

<h3><a name="Class-URIformat"></a>URI format</h3>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
class:className[?options]
</pre>
</div></div>
<p>Where <b>className</b> is the fully qualified class name to create and
use as bean.</p>

<h3><a name="Class-Options"></a>Options</h3>
<div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Name </th>
<th class='confluenceTh'> Type </th>
<th class='confluenceTh'> Default </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> <tt>method</tt> </td>
<td class='confluenceTd'> <tt>String</tt> </td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> The method name that bean will be invoked. If not provided,
Camel will try to pick the method itself. In case of ambiguity an exception is thrown. See
<a href="/confluence/display/CAMEL/Bean+Binding" title="Bean Binding">Bean Binding</a>
for more details. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>multiParameterArray</tt> </td>
<td class='confluenceTd'> <tt>boolean</tt> </td>
<td class='confluenceTd'> <tt>false</tt> </td>
<td class='confluenceTd'> How to treat the parameters which are passed from the message
body; if it is <tt>true</tt>, the In message body should be an array of parameters.
</td>
</tr>
</tbody></table>
</div>


<p>You can append query options to the URI in the following format, <tt>?option=value&amp;option=value&amp;...</tt></p>

<h3><a name="Class-Using"></a>Using</h3>

<p>You simply use the <b>class</b> component just as the <a href="/confluence/display/CAMEL/Bean"
title="Bean">Bean</a> component but by specifying the fully qualified classname instead.<br/>
For example to use the <tt>MyFooBean</tt> you have to do as follows:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
    from(<span class="code-quote">"direct:start"</span>).to(<span class="code-quote">"class:org.apache.camel.component.bean.MyFooBean"</span>).to(<span
class="code-quote">"mock:result"</span>);
</pre>
</div></div>

<p>You can also specify which method to invoke on the <tt>MyFooBean</tt>,
for example <tt>hello</tt>:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
    from(<span class="code-quote">"direct:start"</span>).to(<span class="code-quote">"class:org.apache.camel.component.bean.MyFooBean?method=hello"</span>).to(<span
class="code-quote">"mock:result"</span>);
</pre>
</div></div>

<h2><a name="Class-Settingpropertiesonthecreatedinstance"></a>Setting properties
on the created instance</h2>

<p>In the endpoint uri you can specify properties to set on the created instance, for
example if it has a <tt>setPrefix</tt> method:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
    from(<span class="code-quote">"direct:start"</span>)
        .to(<span class="code-quote">"class:org.apache.camel.component.bean.MyPrefixBean?prefix=Bye"</span>)
        .to(<span class="code-quote">"mock:result"</span>);
</pre>
</div></div>

<p>And you can also use the <tt>#</tt> syntax to refer to properties to
be looked up in the <a href="/confluence/display/CAMEL/Registry" title="Registry">Registry</a>.</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
    from(<span class="code-quote">"direct:start"</span>)
        .to(<span class="code-quote">"class:org.apache.camel.component.bean.MyPrefixBean?cool=#foo"</span>)
        .to(<span class="code-quote">"mock:result"</span>);
</pre>
</div></div>
<p>Which will lookup a bean from the <a href="/confluence/display/CAMEL/Registry"
title="Registry">Registry</a> with the id <tt>foo</tt> and invoke the
<tt>setCool</tt> method on the created instance of the <tt>MyPrefixBean</tt>
class.</p>

<div class='panelMacro'><table class='tipMacro'><colgroup><col width='24'><col></colgroup><tr><td
valign='top'><img src="/confluence/images/icons/emoticons/check.gif" width="16" height="16"
align="absmiddle" alt="" border="0"></td><td><b>See more</b><br
/>See more details at the <a href="/confluence/display/CAMEL/Bean" title="Bean">Bean</a>
component as the <b>class</b> component works in much the same way.</td></tr></table></div>

<h3><a name="Class-SeeAlso"></a>See Also</h3>
<ul>
	<li><a href="/confluence/display/CAMEL/Configuring+Camel" title="Configuring Camel">Configuring
Camel</a></li>
	<li><a href="/confluence/display/CAMEL/Component" title="Component">Component</a></li>
	<li><a href="/confluence/display/CAMEL/Endpoint" title="Endpoint">Endpoint</a></li>
	<li><a href="/confluence/display/CAMEL/Getting+Started" title="Getting Started">Getting
Started</a></li>
</ul>

<ul>
	<li><a href="/confluence/display/CAMEL/Bean" title="Bean">Bean</a></li>
	<li><a href="/confluence/display/CAMEL/Bean+Binding" title="Bean Binding">Bean
Binding</a></li>
	<li><a href="/confluence/display/CAMEL/Bean+Integration" title="Bean Integration">Bean
Integration</a></li>
</ul>

    </div>
    <div id="commentsSection" class="wiki-content pageSection">
       <div style="float: right;">
            <a href="https://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
       </div>
       <a href="https://cwiki.apache.org/confluence/display/CAMEL/Class">View Online</a>
              |
       <a href="https://cwiki.apache.org/confluence/display/CAMEL/Class?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
           </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message