camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Camel > Camel Maven Plugin
Date Fri, 04 May 2012 11:36:00 GMT
<html>
<head>
    <base href="https://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/2042/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/Camel+Maven+Plugin">Camel
Maven Plugin</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://cwiki.apache.org/confluence/display/~jkorab">jkorab</a>
    </h4>
        <br/>
                         <h4>Changes (4)</h4>
                                 
    
<div id="page-diffs">
                    <table class="diff" cellpadding="0" cellspacing="0">
    
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" > <br>h3. File based spring configuration
files <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">In
Camel 1.4 loading file based spring context files is also supported. You configure this with
the new option *fileApplicationContextUri*. Paths may be split using a semi-colon \(;\). This
is usable for projects that is web applications and you store spring configuration files in
WEB-INF.  <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">From
Camel 1.4 onwards loading Spring context files via a flie location is also supported. You
configure this with the *fileApplicationContextUri* option. Paths may be split using a semi-colon
\(;\). This sort of file location is useful for web application projects that store spring
configuration files in WEB-INF. It can also be used to replace configuration that requires
an OSGi container with an equivalent non-OSGi configuration.  <br></td></tr>
            <tr><td class="diff-unchanged" >{code:lang=xml} <br>&lt;plugin&gt;
<br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >  &lt;artifactId&gt;camel-maven-plugin&lt;/artifactId&gt;
<br>  &lt;configuration&gt; <br></td></tr>
            <tr><td class="diff-changed-lines" ><span class="diff-changed-words">&lt;fileApplicationContextUri&gt;<span
class="diff-deleted-chars"style="color:#999;background-color:#fdd;text-decoration:line-through;">src/main/webapp/WEB-INF/camel*.xml&lt;/fileApplicationContextUri&gt;</span></span>
<br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">
     src/main/webapp/WEB-INF/camel*.xml; <br>      src/test/spring/test-context.xml
<br>    &lt;/fileApplicationContextUri&gt; <br></td></tr>
            <tr><td class="diff-unchanged" >  &lt;/configuration&gt; <br>&lt;/plugin&gt;
<br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <h2><a name="CamelMavenPlugin-CamelMavenPlugin"></a>Camel Maven
Plugin</h2>

<p>The <a href="http://activemq.apache.org/camel/maven/maven-plugins/camel-maven-plugin/plugin-info.html"
class="external-link" rel="nofollow">Camel Maven Plugin</a> allows you to run your
<a href="/confluence/display/CAMEL/Enterprise+Integration+Patterns" title="Enterprise Integration
Patterns">Enterprise Integration Patterns</a> using <a href="/confluence/display/CAMEL/Spring"
title="Spring">Spring</a> for <a href="/confluence/display/CAMEL/Dependency+Injection"
title="Dependency Injection">Dependency Injection</a> inside Maven along with being
able to support <a href="/confluence/display/CAMEL/Visualisation" title="Visualisation">Visualisation</a>
along with integration of the <a href="/confluence/display/CAMEL/Visualisation" title="Visualisation">Visualisation</a>
diagrams into the standard maven reports for your project.</p>

<h3><a name="CamelMavenPlugin-GoalsSupported"></a>Goals Supported</h3>

<div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Documentation </th>
<th class='confluenceTh'> Reference </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> <a href="/confluence/display/CAMEL/Camel+Run+Maven+Goal"
title="Camel Run Maven Goal">camel:run</a> </td>
<td class='confluenceTd'> <a href="http://activemq.apache.org/camel/maven/maven-plugins/camel-maven-plugin/run-mojo.html"
class="external-link" rel="nofollow">camel:run</a> </td>
<td class='confluenceTd'> Boots up Camel in a new JVM using the <a href="/confluence/display/CAMEL/Spring"
title="Spring">Spring</a> configuration at <b>META-INF/spring/&#42;.xml</b>
and runs your routing rules </td>
</tr>
<tr>
<td class='confluenceTd'> <a href="/confluence/display/CAMEL/Camel+Embedded+Maven+Goal"
title="Camel Embedded Maven Goal">camel:embedded</a> </td>
<td class='confluenceTd'> <a href="http://activemq.apache.org/camel/maven/maven-plugins/camel-maven-plugin/embedded-mojo.html"
class="external-link" rel="nofollow">camel:embedded</a> </td>
<td class='confluenceTd'> Boots up Camel in the same JVM as Maven using the <a href="/confluence/display/CAMEL/Spring"
title="Spring">Spring</a> configuration at <b>META-INF/spring/&#42;.xml</b>
and runs your routing rules </td>
</tr>
<tr>
<td class='confluenceTd'> <a href="/confluence/display/CAMEL/Camel+Dot+Maven+Goal"
title="Camel Dot Maven Goal">camel:dot</a> </td>
<td class='confluenceTd'> <a href="http://activemq.apache.org/camel/maven/maven-plugins/camel-maven-plugin/dot-mojo.html"
class="external-link" rel="nofollow">camel:dot</a> </td>
<td class='confluenceTd'> Generates DOT files and then HTML, PNG, SVG files for your
EIP routing rules with integration into Maven Reports </td>
</tr>
</tbody></table>
</div>


<h3><a name="CamelMavenPlugin-Addingtheplugintoyourpom.xml"></a>Adding the
plugin to your pom.xml</h3>

<p>Add the following in your &lt;build&gt;&lt;plugins&gt; section</p>

<div class='panelMacro'><table class='noteMacro'><colgroup><col width='24'><col></colgroup><tr><td
valign='top'><img src="/confluence/images/icons/emoticons/warning.gif" width="16" height="16"
align="absmiddle" alt="" border="0"></td><td>You may override the default Spring
application context file uri <b>META-INF/spring/&#42;.xml</b> by using the
applicationContextUri property in the camel-maven-plugin configuration.  Paths may be split
using a semi-colon &#40;;&#41;.</td></tr></table></div>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">
<span class="code-tag">&lt;plugin&gt;</span>
  <span class="code-tag">&lt;groupId&gt;</span>org.apache.camel<span
class="code-tag">&lt;/groupId&gt;</span>
  <span class="code-tag">&lt;artifactId&gt;</span>camel-maven-plugin<span
class="code-tag">&lt;/artifactId&gt;</span>
  <span class="code-tag">&lt;configuration&gt;</span>
    <span class="code-tag">&lt;applicationContextUri&gt;</span>META-INF/spring/*.xml;YOUR_FILE_NAME_IN_THE_CLASS_PATH.xml<span
class="code-tag">&lt;/applicationContextUri&gt;</span>
  <span class="code-tag">&lt;/configuration&gt;</span>
<span class="code-tag">&lt;/plugin&gt;</span>
</pre>
</div></div>

<p>You can also specify what Main class to use when running the plugin. By default this
is org.apache.camel.spring.Main.</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">
<span class="code-tag">&lt;plugin&gt;</span>
  <span class="code-tag">&lt;groupId&gt;</span>org.apache.camel<span
class="code-tag">&lt;/groupId&gt;</span>
  <span class="code-tag">&lt;artifactId&gt;</span>camel-maven-plugin<span
class="code-tag">&lt;/artifactId&gt;</span>
  <span class="code-tag"><span class="code-comment">&lt;!-- optional, default
value: org.apache.camel.spring.Main --&gt;</span></span>
  <span class="code-tag">&lt;configuration&gt;</span>
    <span class="code-tag">&lt;mainClass&gt;</span>mypackage.boot.camel.CamelStartup<span
class="code-tag">&lt;/mainClass&gt;</span>
  <span class="code-tag">&lt;/configuration&gt;</span>
<span class="code-tag">&lt;/plugin&gt;</span>
</pre>
</div></div>

<h3><a name="CamelMavenPlugin-Filebasedspringconfigurationfiles"></a>File
based spring configuration files</h3>
<p>From Camel 1.4 onwards loading Spring context files via a flie location is also supported.
You configure this with the <b>fileApplicationContextUri</b> option. Paths may
be split using a semi-colon &#40;;&#41;. This sort of file location is useful for
web application projects that store spring configuration files in WEB-INF. It can also be
used to replace configuration that requires an OSGi container with an equivalent non-OSGi
configuration. </p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">
<span class="code-tag">&lt;plugin&gt;</span>
  <span class="code-tag">&lt;groupId&gt;</span>org.apache.camel<span
class="code-tag">&lt;/groupId&gt;</span>
  <span class="code-tag">&lt;artifactId&gt;</span>camel-maven-plugin<span
class="code-tag">&lt;/artifactId&gt;</span>
  <span class="code-tag">&lt;configuration&gt;</span>
    <span class="code-tag">&lt;fileApplicationContextUri&gt;</span>
      src/main/webapp/WEB-INF/camel*.xml;
      src/test/spring/test-context.xml
    <span class="code-tag">&lt;/fileApplicationContextUri&gt;</span>
  <span class="code-tag">&lt;/configuration&gt;</span>
<span class="code-tag">&lt;/plugin&gt;</span>
</pre>
</div></div>

<h3><a name="CamelMavenPlugin-Classpath"></a>Classpath</h3>

<p>The plugin will construct a classpath of any Maven dependency with scope "compile".
 The classpath is output as an INFO log statement upon startup.</p>

<h3><a name="CamelMavenPlugin-RouteInformation"></a>Route Information</h3>

<p>Information about the generated routes is available through the GraphViz report,
and also through the log statements generated by the run goal.  If you would like to see this
information then add a log4j (or other commons-logging implementation) config file with the
following levels.</p>

<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader"
style="border-bottom-width: 1px;"><b>src/main/resources/log4.properties</b></div><div
class="codeContent panelContent">
<pre class="code-java">
log4j.rootLogger=INFO, stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n

log4j.logger.org.apache.camel.impl.DefaultCamelContext=DEBUG, stdout
log4j.additivity.org.apache.camel.impl.DefaultCamelContext=<span class="code-keyword">false</span>
</pre>
</div></div>

<p>This should produce a log statement similar to:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
670  [org.apache.camel.spring.Main.main()] DEBUG org.apache.camel.impl.DefaultCamelContext
 
  - Adding routes from: Routes: [Route[ [From[jms:queue:queueA]] -&gt; [To[jms:queue:queueB],
To[jms:queue:queueC]]]] routes: []
</pre>
</div></div>

<h3><a name="CamelMavenPlugin-IntegrationintoMavenReports"></a>Integration
into Maven Reports</h3>

<p>If you add the camel-maven-plugin to your &lt;reporting&gt; section of your
pom you will automatically get the <a href="/confluence/display/CAMEL/Visualisation" title="Visualisation">Visualisation</a>
reporting generated for your project as part of the regular maven site generation.</p>

<p>For example add the following into your pom</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">
<span class="code-tag">&lt;project&gt;</span>
  ...
  <span class="code-tag">&lt;reporting&gt;</span>
    <span class="code-tag">&lt;plugins&gt;</span>
      <span class="code-tag">&lt;plugin&gt;</span>
        <span class="code-tag">&lt;groupId&gt;</span>org.apache.camel<span
class="code-tag">&lt;/groupId&gt;</span>
        <span class="code-tag">&lt;artifactId&gt;</span>camel-maven-plugin<span
class="code-tag">&lt;/artifactId&gt;</span>
      <span class="code-tag">&lt;/plugin&gt;</span>
    <span class="code-tag">&lt;/plugins&gt;</span>
  <span class="code-tag">&lt;/reporting&gt;</span>  
<span class="code-tag">&lt;/project&gt;</span>
</pre>
</div></div>

<p>Then when you run</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
mvn site
</pre>
</div></div>

<p>Your context will be booted up via the <b>META-INF/spring/&#42;.xml</b>
files, the DOT file generated and a nice HTML report created. </p>

<div class='panelMacro'><table class='infoMacro'><colgroup><col width='24'><col></colgroup><tr><td
valign='top'><img src="/confluence/images/icons/emoticons/information.gif" width="16"
height="16" align="absmiddle" alt="" border="0"></td><td><b>GraphViz
DOT required</b><br />Note to get the nice HTML, PNG and SVG outputs from the
DOT files you will need to install the <a href="http://graphviz.org" class="external-link"
rel="nofollow">GraphViz</a> DOT executable and add it to your PATH so that the plugin
can invoke DOT to generate the PNG/SVG files. 

<p>For more details see the <a href="/confluence/display/CAMEL/Camel+Dot+Maven+Goal"
title="Camel Dot Maven Goal">camel:dot</a>.</p></td></tr></table></div>
    </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/Camel+Maven+Plugin">View
Online</a>
        |
        <a href="https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=60407&revisedVersion=25&originalVersion=24">View
Changes</a>
                |
        <a href="https://cwiki.apache.org/confluence/display/CAMEL/Camel+Maven+Plugin?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message