camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject svn commit: r930484 - in /websites/production/camel/content: cache/main.pageCache camel-and-scr.html
Date Tue, 25 Nov 2014 20:19:25 GMT
Author: buildbot
Date: Tue Nov 25 20:19:25 2014
New Revision: 930484

Production update by buildbot for camel


Modified: websites/production/camel/content/cache/main.pageCache
Binary files - no diff available.

Added: websites/production/camel/content/camel-and-scr.html
--- websites/production/camel/content/camel-and-scr.html (added)
+++ websites/production/camel/content/camel-and-scr.html Tue Nov 25 20:19:25 2014
@@ -0,0 +1,170 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+    <link href="//" rel="stylesheet" type="text/css">
+    <link href="//" rel="stylesheet" type="text/css">
+    <script src="//" type="text/javascript"></script>
+    <script src="//" type="text/javascript"></script>
+    <script src="//" type="text/javascript"></script>
+    <meta http-equiv="Content-type" content="text/html;charset=UTF-8">
+    <style type="text/css">
+      .maincontent { overflow:hidden; }
+    </style>
+    <!--[if IE]>
+    <style type="text/css">
+      .maincontent { width:100%; }
+    </style>
+    <![endif]-->
+  <link href='//' rel='stylesheet'
type='text/css' />
+  <link href='//' rel='stylesheet'
type='text/css' />
+  <script src='//' type='text/javascript'></script>
+  <script src='//' type='text/javascript'></script>
+  <script type="text/javascript">
+  SyntaxHighlighter.defaults['toolbar'] = false;
+  SyntaxHighlighter.all();
+  </script>
+    <title>
+    Apache Camel: Camel and SCR
+    </title>
+<div class="white_box">
+<div class="header">
+  <div class="header_l">
+    <div class="header_r">
+    </div>
+  </div>
+<div class="content">
+  <div class="content_l">
+    <div class="content_r">
+      <div>
+          <!-- Banner -->
+<div id="banner-content"><div id="asf_logo">
+	<div id="activemq_logo" style="height:108px; background:transparent url(
no-repeat scroll left top;">
+            <a shape="rect" style="float:left; width:310px;display:block;text-indent:-5000px;text-decoration:none;line-height:140px;
margin-top:20px; margin-left:18px;" href="">Camel</a>
+            <a shape="rect" style="float:right; width:180px;display:block;text-indent:-5000px;text-decoration:none;line-height:80px;
margin-top:45px; margin-right:10px;" href="">Apache</a>
+	</div>
+          <!-- Banner -->
+        <div class="top_red_bar">
+          <div id="site-breadcrumbs">
+                <!-- Breadcrumbs -->
+<a href="index.html">Apache Camel</a>&nbsp;&gt;&nbsp;<a href="documentation.html">Documentation</a>&nbsp;&gt;&nbsp;<a
href="user-guide.html">User Guide</a>&nbsp;&gt;&nbsp;<a href="camel-and-scr.html">Camel
and SCR</a>
+          </div>
+          <!-- Quicklinks -->
+<div id="site-quicklinks"><p><a shape="rect" href="download.html">Download</a>
| <a shape="rect" href="javadoc.html">JavaDoc</a> | <a shape="rect" href="source.html">Source</a>
| <a shape="rect" href="discussion-forums.html">Forums</a> | <a shape="rect"
+          <!-- Quicklinks -->
+        </div>
+	<table border="0">
+	<tbody>
+        <tr>
+        <td valign="top" width="100%">
+<div class="wiki-content maincontent"><h2 id="CamelandSCR-WorkingwithCamelusingSCR">Working
with Camel using SCR</h2><p><span style="font-size: 14.0px;line-height: 1.4285715;">SCR
stands for Service Component Runtime and is an implementation of OSGi Declarative Services
specification (TODO: add a link to spec here). SCR enables any plain old Java object to expose
and use OSGi services with no boilerplate code.</span></p><p>OSGi framework
knows your object by looking at SCR descriptor files in your bundle which are typically generated
from annotations in your code by a plugin such as org.apache.felix:maven-scr-plugin (<a
shape="rect" class="external-link" href=""></a>).</p><p>Running
Camel in an SCR bundle is a great alternative for Spring DM and Blueprint based solutions
having significantly fewer lines of code betw
 een you and the OSGi framework. Using SCR your bundle can remain completely in Java world;
there is no need to edit XML or properties files. This offers you full control over everything
and means your IDE of choice knows exactly what is going on in your project.</p><h3
id="CamelandSCR-CamelSCRsupport">Camel SCR support</h3><p><strong>Available
as of Camel 2.15.0</strong></p><p><span style="line-height: 1.4285715;"><code>org.apache.camel/camel-scr</code>
bundle provides a base class, <code>AbstractCamelRunner</code>, which manages
a Camel context for you and a helper class, <code>ScrHelper</code>, for using
your SCR properties in unit tests. Camel-scr feature for Apache Karaf&#160;</span><span
style="line-height: 1.4285715;">defines all features and bundles required for running Camel
in SCR bundles.</span></p><p><code>AbstractCamelRunner</code>&#160;class
ties CamelContext's lifecycle to Service Component's lifecycle and handles configuration with
help of Camel's PropertiesComponent.
  All you have to do to make a Service Component out of your java class is to extend it from
<code>AbstractCamelRunner</code>&#160;and add the following <code>org.apache.felix.scr.annotations</code>
on class level:</p><div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
+<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[@Component
+    @Reference(name = &quot;camelComponent&quot;,referenceInterface = ComponentResolver.class,
+        cardinality = ReferenceCardinality.MANDATORY_MULTIPLE, policy = ReferencePolicy.DYNAMIC,
+        policyOption = ReferencePolicyOption.GREEDY, bind = &quot;gotCamelComponent&quot;,
unbind = &quot;lostCamelComponent&quot;)
+</div></div><p>Then implement <code>getRouteBuilders()</code>
method which returns the Camel routes you want to run. And finally provide the default configuration
with:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
+<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[@Properties({
+   @Property(name = &quot;camelContextId&quot;, value = &quot;my-test&quot;),
+   @Property(name = &quot;active&quot;, value = &quot;true&quot;),
+   @Property(name = &quot;...&quot;, value = &quot;...&quot;),
+   ...
+</div></div><p>That's all. And if you used <code>camel-archetype-scr</code>
to generate a project all this is already taken care of.</p><p><code>CamelContextId</code>&#160;and
<code>active</code>&#160;properties control the CamelContext's name (defaults
to "camel-runner-default") and whether it will be started or not (defaults to "false"), respectively.
In addition to these you can add and use as many properties as you like. Camel's PropertiesComponent
handles recursive properties and prefixing with fallback without problem.</p><p><code>AbstractCamelRunner</code>&#160;will
make these properties available to your RouteBuilders through Camel's PropertiesComponent
and it will also inject these values into your Service Component's and RouteBuilder's fields
when their names match. The fields can be declared with any visibility level, and many types
are supported (String, int, boolean, URL, ...).</p><h4 id="CamelandSCR-AbstractCamelRunner'slifecycleinSCR">AbstractCamelRunner's
lifecycle i
 n SCR</h4><ol><li>When component's configuration policy and mandatory references
are satisfied SCR calls <code>activate()</code>. This creates and sets up a CamelContext
through the following call chain: <code>activate()</code>&#160;&#8594;&#160;<code><em>prepare</em>()</code>&#160;&#8594;&#160;<code>createCamelContext()</code>
&#8594;&#160;<code>setupPropertiesComponent()</code> &#8594;&#160;<code>configure()</code>
&#8594;&#160;<code>setupCamelContext()</code>. Finally, the context is
scheduled to start after a delay defined in <code>AbstractCamelRunner.START_DELAY</code>&#160;with
<code>runWithDelay()</code>.</li><li><span style="line-height:
1.4285715;">When Camel components (<code>ComponentResolver</code> services,
to be exact) are registered in OSGi, SCR calls </span><code>gotCamelComponent</code><span
style="line-height: 1.4285715;"><code>()</code> which reschedules/delays the
CamelContext start further by the same </span><code>AbstractCamelRunner.START_DELAY</code><span
 e="line-height: 1.4285715;">. This in effect makes CamelContext wait until all Camel components
are loaded or there is a sufficient gap between them. The same logic will tell a failed-to-start
CamelContext to try again whenever we add more Camel components.</span></li><li><span
style="line-height: 1.4285715;">When Camel components are unregistered SCR calls </span><code>lostCamelComponent</code><span
style="line-height: 1.4285715;"><code>()</code>. This call does nothing.</span></li><li><span
style="line-height: 1.4285715;">When one of the requirements that caused the call to </span><code>activate</code><span
style="line-height: 1.4285715;"><code>()</code> is lost SCR will call </span><code>deactivate</code><span
style="line-height: 1.4285715;"><code>()</code>. This will shutdown the CamelContext.</span></li></ol><p>In
(non-OSGi) unit tests you should use <code>prepare()</code> &#8594;&#160;<code>run()</code>
&#8594;&#160;<code>stop()</code> instead of <code>activate()</code>
 ;&#160;<code>deactivate()</code> for more fine-grained control. Also, this
allows us to avoid possible SCR specific operations in tests.</p><h4 id="CamelandSCR-ExampleCamelSCRbundle">Example
Camel SCR bundle</h4><p>The easiest way to create an Camel SCR bundle is to use
camel-archetype-scr Maven archetype.</p><p><code>mvn archetype:generate
archetype:<br clear="none">1: local -&gt; org.apache.camel.archetypes:camel-archetype-scr
(Creates a new Camel SCR bundle project for Karaf)<br clear="none">Choose a number or
apply filter (format: [groupId:]artifactId, case sensitive contains): : 1<br clear="none">Define
value for property 'groupId': : my.example<br clear="none">[INFO] Using property: groupId
= my.example<br clear="none">Define value for property 'artifactId': : my-test<br
clear="none">Define value for property 'version': 1.0-SNAPSHOT: :<br clear="none">Define
value for property 'package': my.example: :
 <br clear="none">[INFO] Using property: archetypeArtifactId = camel-archetype-scr<br
clear="none">[INFO] Using property: archetypeGroupId = org.apache.camel.archetypes<br
clear="none">[INFO] Using property: archetypeVersion = 2.15-SNAPSHOT<br clear="none">Define
value for property 'className': : MyTest<br clear="none">Confirm properties configuration:<br
clear="none">groupId: my.example<br clear="none">artifactId: my-test<br clear="none">version:
1.0-SNAPSHOT<br clear="none">package: my.example<br clear="none">archetypeArtifactId:
camel-archetype-scr<br clear="none">archetypeGroupId: org.apache.camel.archetypes<br
clear="none">archetypeVersion: 2.15-SNAPSHOT<br clear="none">className: MyTest<br
clear="none"> Y: :</p><p>All done! Check ReadMe.txt in the generated project
folder for the next steps.</p><p>To deploy a Camel SCR bundle project in Apache
Karaf:</p><p>On Karaf command line:</p><p># Add Camel feature repository<br
clear="none">features:chooseurl camel 2.15-SNAPSHOT</p><p># 
 Install camel-scr feature<br clear="none">features:install camel-scr</p><p>#
Install commons-lang, used in the example route to validate parameters<br clear="none">
osgi:install mvn:commons-lang/commons-lang/2.6</p><p># Install and start your
bundle<br clear="none"> osgi:install -s</p><p>#
See how it's running<br clear="none">log:tail -n 10</p><p>Press ctrl-c to
stop watching the log.</p></div>
+        </td>
+        <td valign="top">
+          <div class="navigation">
+            <div class="navigation_top">
+                <!-- NavigationBar -->
+<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="">
+  <div>
+    <input type="hidden" name="cx" value="007878419884033443453:m5nhvy4hmyq">
+    <input type="hidden" name="ie" value="UTF-8">
+    <input type="text" name="q" size="21">
+    <input type="submit" name="sa" value="Search">
+  </div>
+<script type="text/javascript" src=";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="" 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="">License</a></li><li><a shape="rect"
class="external-link" href="">Sponsorship</a></li><li><a
shape="rect" class="external-link" href="">Thanks</a></li><li><a
shape="rect" class="external-link" href="">Security</a></li></ul></div>
+                <!-- NavigationBar -->
+            </div>
+          </div>
+        </td>
+        </tr>
+	</tbody>
+        </table>
+        <div class="bottom_red_bar"></div>
+      </div>
+    </div>
+  </div>
+<div class="black_box">
+<div class="footer">
+  <div class="footer_l">
+    <div class="footer_r">
+      <div>
+        <a href="$base/privacy-policy.html">Privacy Policy</a> -
+        (<a href="">edit
+   	 (<a href=";showComments=true&amp;showCommentArea=true#addcomment">add
+      </div>
+    </div>
+  </div>
+<div class="design_attribution">
+&copy; 2004-2014 The Apache Software Foundation.
+Apache Camel, Camel, Apache, the Apache feather logo, and the Apache Camel project logo are
trademarks of The Apache Software Foundation.  All other marks mentioned may be trademarks
or registered trademarks of their respective owners.
+<a href="">Graphic Design By Hiram</a>
+<!-- Camel committers that would like access to the Analytics, send a note to
+<script type="text/javascript">
+  var _gaq = _gaq || [];
+  _gaq.push(['_setAccount', 'UA-25976253-1']);
+  _gaq.push(['_trackPageview']);
+  (function() {
+    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '';
+    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+  })();

View raw message