<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Jean-Baptiste Onofré&#039;s Blog</title>
	<atom:link href="http://blog.nanthrax.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.nanthrax.net</link>
	<description></description>
	<lastBuildDate>Wed, 29 Feb 2012 06:34:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Apache Karaf Cellar and central management</title>
		<link>http://blog.nanthrax.net/2012/02/apache-karaf-cellar-and-central-management/</link>
		<comments>http://blog.nanthrax.net/2012/02/apache-karaf-cellar-and-central-management/#comments</comments>
		<pubDate>Wed, 29 Feb 2012 06:34:17 +0000</pubDate>
		<dc:creator>jbonofre</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Apache Karaf]]></category>
		<category><![CDATA[cellar]]></category>
		<category><![CDATA[karaf]]></category>
		<category><![CDATA[servicemix]]></category>

		<guid isPermaLink="false">http://blog.nanthrax.net/?p=246</guid>
		<description><![CDATA[Introduction One of the first purpose of Apache Karaf Cellar is to synchronize the state of each Karaf instances in the Cellar cluster. It means that any change performed on one node (install a feature, start a bundle, add a config, etc) generates a &#8220;cluster event&#8221; which is broadcasted by Cellar to all others nodes. [...]]]></description>
			<content:encoded><![CDATA[<h4>Introduction</h4>
<p>One of the first purpose of Apache Karaf Cellar is to synchronize the state of each Karaf instances in the Cellar cluster.</p>
<p>It means that any change performed on one node (install a feature, start a bundle, add a config, etc) generates a &#8220;cluster event&#8221; which is broadcasted by Cellar to all others nodes. The target node handles the &#8220;cluster event&#8221; and performed the corresponding action (install a feature, start a bundle, add a config, etc).</p>
<p>By default, the nodes have the same role. It means that you can perform actions on any node.</p>
<p>But, you may prefer to have one node dedicated to the management. It&#8217;s what we name &#8220;central management&#8221;.</p>
<h4>Central management</h4>
<p>With central management, one node is identified by the manager. It means that cluster actions will be performed only on this node. The manager is the only one which is able to produce cluster event. The managed nodes are only able to receive and handle events, not to produce.</p>
<p>With this approach, you can give access (for instance grant ssh or JMX access) to the manager node to an operator and manage the cluster (and all cluster groups) from this manager node.</p>
<p>We will see now how to implement central management.</p>
<p>We assume that we have three nodes:</p>
<ul>
<li>manager</li>
<li>node1</li>
<li>node2</li>
</ul>
<p>First, we install Cellar on the three nodes:</p>
<p><code><br />
karaf@manager> features:addurl mvn:org.apache.karaf.cellar/apache-karaf-cellar/2.2.4-SNAPSHOT/xml/features<br />
karaf@manager> features:install cellar<br />
</code></p>
<p><code><br />
karaf@node1> features:addurl mvn:org.apache.karaf.cellar/apache-karaf-cellar/2.2.4-SNAPSHOT/xml/features<br />
karaf@node1> features:install cellar<br />
</code></p>
<p><code><br />
karaf@node2> features:addurl mvn:org.apache.karaf.cellar/apache-karaf-cellar/2.2.3/xml/features<br />
karaf@node2> features:install cellar<br />
</code></p>
<p>It&#8217;s a default installation, nothing special here.</p>
<p>Now, we disable the event producing on node1 and node2.</p>
<p>To do that, from the manager:</p>
<p><code><br />
karaf@manager> cluster:producer-stop node1:5702<br />
Node                 Status<br />
node1:5702           false<br />
karaf@manager> cluster:producer-stop node2:5703<br />
Node                 Status<br />
node2:5703           false<br />
</code></p>
<p>We can check that the producer are really stopped:</p>
<p><code><br />
karaf@manager> cluster:producer-status node1:5702<br />
Node                 Status<br />
node1:5702           false<br />
karaf@manager> cluster:producer-status node2:5703<br />
Node                 Status<br />
node2:5703           false<br />
</code></p>
<p>Whereas the manager is always able to produce event:</p>
<p><code><br />
karaf@manager> cluster:producer-status<br />
Node                 Status<br />
manager:5701         true<br />
</code></p>
<p>Now, for instance, we can install eventadmin feature from the manager:</p>
<p><code><br />
karaf@manager> cluster:features-install default eventadmin<br />
</code></p>
<p>We can see that this feature has been installed on node1:</p>
<p><code><br />
karaf@node1> features:list|grep -i eventadmin<br />
[installed  ] [2.2.5          ] eventadmin                            karaf-2.2.5<br />
</code></p>
<p>and node2:</p>
<p><code><br />
karaf@node2> features:list|grep -i eventadmin<br />
[installed  ] [2.2.5          ] eventadmin                            karaf-2.2.5<br />
</code></p>
<p>Now, we uninstall this feature from the manager:</p>
<p><code><br />
karaf@manager> cluster:features-uninstall default eventadmin<br />
</code></p>
<p>We can see that the feature has been uninstall from node1:</p>
<p><code><br />
karaf@node1> features:list|grep -i eventadmin<br />
[uninstalled] [2.2.5          ] eventadmin                            karaf-2.2.5<br />
</code></p>
<p>And now, we try to install the eventadmin feature on the cluster from the node1:</p>
<p><code><br />
karaf@node1> cluster:features-install default eventadmin<br />
</code></p>
<p>The event is not generated and the others nodes are not updated.</p>
<p>However, two kind of events are always produced (even if the producer is stopped):</p>
<ul>
<li>the events with the &#8220;force&#8221; flag. When you create an event (programmatically), you can use setForce(true) to force the event producing.</li>
<li>the &#8220;admin&#8221; events, like the events produced to stop/start a producer, consumer, handler in the cluster.</li>
</ul>
<p>NB: the event produce handling has been largely improved for Cellar 2.2.4.</p>
<h4>Coming in next Cellar release</h4>
<p>Currently, the cellar feature install the cellar core bundles, but also the cellar shell commands, and the MBeans.</p>
<p>If it makes sense for the manager, the managed nodes should not &#8220;display&#8221; the cluster:* commands as they are managed by the manager.</p>
<p>I will make a little refactoring of the Cellar features to split in two parts:</p>
<ul>
<li>the cellar-core feature will install hazelcast, and Cellar core bundles</li>
<li>the cellar-manager feature will install the cluster:* shell commands and the MBeans</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.nanthrax.net/2012/02/apache-karaf-cellar-and-central-management/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Communication between two remote Camel routes using Karaf Cellar</title>
		<link>http://blog.nanthrax.net/2012/02/communication-between-two-remote-camel-routes-using-karaf-cellar/</link>
		<comments>http://blog.nanthrax.net/2012/02/communication-between-two-remote-camel-routes-using-karaf-cellar/#comments</comments>
		<pubDate>Thu, 02 Feb 2012 21:14:42 +0000</pubDate>
		<dc:creator>jbonofre</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Apache Camel]]></category>
		<category><![CDATA[Apache Karaf]]></category>

		<guid isPermaLink="false">http://blog.nanthrax.net/?p=238</guid>
		<description><![CDATA[Apache Karaf Cellar 2.2.3 Around one week ago, we released Karaf Cellar 2.2.3. In addition of the first Distributed OSGi support (DOSGi, I already wrote blog), an interesting feature of Cellar 2.2.3 is to give access the whole Hazelcast configuration. The etc/hazelcast.xml is the core configuration of the Hazelcast instance, started by the Cellar feature. [...]]]></description>
			<content:encoded><![CDATA[<h3>Apache Karaf Cellar 2.2.3</h3>
<p>Around one week ago, we released Karaf Cellar 2.2.3.</p>
<p>In addition of the first Distributed OSGi support (DOSGi, I already wrote <a href="http://blog.nanthrax.net/2011/11/apache-karaf-cellar-and-dosgi/">blog</a>), an interesting feature of Cellar 2.2.3 is to give access the whole Hazelcast configuration.</p>
<p>The <code>etc/hazelcast.xml</code> is the core configuration of the Hazelcast instance, started by the Cellar feature. Cellar registers the Hazelcast instance as an OSGi service.</p>
<p>It means that we can use the Hazelcast instance just using a reference to the corresponding OSGi service. We are going to use the Hazelcast OSGi service in a Camel route defined using blueprint DSL (it works using Spring DSL as well).</p>
<h3>Apache Camel 2.9.0 and the Hazelcast component</h3>
<p>Camel 2.9.0 provides a new component: camel-hazelcast.</p>
<p>This component allows to send (as a producer/to) or receive (as a consumer/from) a Camel exchange through a Hazelcast distributed queue.</p>
<p>The first route <code>timerToQueue</code> fires a message every 5 seconds, and send to a Hazelcast distributed queue.</p>
<p>This distributed queue will be in the Hazelcast instance registered as an OSGi service by Cellar.</p>
<p><code><br />
&lt;?xml version="1.0" encoding="UTF-8"?&gt;<br />
&lt;blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"<br />
&nbsp; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"<br />
&nbsp; xmlns:camel="http://camel.apache.org/schema/blueprint"<br />
&nbsp; xsi:schemaLocation="<br />
&nbsp; &nbsp; http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd<br />
&nbsp; &nbsp; http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd"&gt;</p>
<p>&nbsp; &lt;camelContext id="blueprintContext" trace="false" xmlns="http://camel.apache.org/schema/blueprint"&gt;<br />
&nbsp; &nbsp; &lt;route id="timerToQueue"&gt;<br />
&nbsp; &nbsp; &nbsp; &lt;from uri="timer:foo?period=5000"/&gt;<br />
&nbsp; &nbsp; &nbsp; &lt;setBody&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;constant&gt;Hello Remote&lt;/constant&gt;<br />
&nbsp; &nbsp; &nbsp; &lt;/setBody&gt;<br />
&nbsp; &nbsp; &nbsp; &lt;to uri="hazelcast:seda:yet.another.queue"/&gt;<br />
&nbsp; &nbsp; &lt;/route&gt;<br />
&nbsp; &lt;/camelContext&gt;</p>
<p>&nbsp; &lt;bean id="hazelcast" class="org.apache.camel.component.hazelcast.HazelcastComponent"&gt;<br />
&nbsp; &nbsp; &lt;property name="hazelcastInstance" ref="hazelcastInstance"/&gt;<br />
&nbsp; &lt;/bean&gt;</p>
<p>&nbsp; &lt;reference id="hazelcastInstance" availability="optional" interface="com.hazelcast.core.HazelcastInstance"/&gt;</p>
<p>&lt;/blueprint&gt;<br />
</code></p>
<p>On the other hand, the <code>queueToFile</code> route get the exchange from the distributed queue and send to a file.</p>
<p><code><br />
&lt;?xml version="1.0" encoding="UTF-8"?&gt;<br />
&lt;blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"<br />
&nbsp; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"<br />
&nbsp; xmlns:camel="http://camel.apache.org/schema/blueprint"<br />
&nbsp; xsi:schemaLocation="<br />
&nbsp; &nbsp; http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd<br />
&nbsp; &nbsp; http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd"&gt;</p>
<p>&nbsp; &lt;camelContext id="blueprintContext" trace="false" xmlns="http://camel.apache.org/schema/blueprint"&gt;<br />
&nbsp; &nbsp; &lt;route id="queueToFile"&gt;<br />
&nbsp; &nbsp; &nbsp; &lt;from uri="hazelcast:seda:yet.another.queue"/&gt;<br />
&nbsp; &nbsp; &nbsp; &lt;to uri="file:/my/folder"/&gt;<br />
&nbsp;&nbsp; &lt;/route&gt;<br />
&nbsp; &lt;/camelContext&gt;</p>
<p>&nbsp; &lt;bean id="hazelcast" class="org.apache.camel.component.hazelcast.HazelcastComponent"&gt;<br />
&nbsp; &nbsp; &lt;property name="hazelcastInstance" ref="hazelcastInstance"/&gt;<br />
&nbsp; &lt;/bean&gt;</p>
<p>&nbsp; &lt;reference id="hazelcastInstance" availability="optional" interface="com.hazelcast.core.HazelcastInstance"/&gt;</p>
<p>&lt;/blueprint&gt;<br />
</code></p>
<p>The two routes are on different Cellar nodes, the communication uses a queue distributed on all Hazelcast instances (handle by Karaf Cellar).</p>
<h3>Conclusion</h3>
<p>Lot of Camel users mostly use a JMS queue to &#8220;connect&#8221; two remote Camel routes. It requires a MQ broker, with a network connector if you want failover/cluster, etc. So it&#8217;s required special configuration, etc.</p>
<p>Now, we have an alternative using Cellar, which is just a feature to install, without point of failure (a Hazelcast instance is present on each Cellar node).</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.nanthrax.net/2012/02/communication-between-two-remote-camel-routes-using-karaf-cellar/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ubuntu boot hang up with kernel 3.0.0-15 and lvm2</title>
		<link>http://blog.nanthrax.net/2012/01/ubuntu-boot-hang-up-with-kernel-3-0-0-15-and-lvm2/</link>
		<comments>http://blog.nanthrax.net/2012/01/ubuntu-boot-hang-up-with-kernel-3-0-0-15-and-lvm2/#comments</comments>
		<pubDate>Sun, 22 Jan 2012 20:15:57 +0000</pubDate>
		<dc:creator>jbonofre</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Unix/Linux]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://blog.nanthrax.net/?p=233</guid>
		<description><![CDATA[Today, I updated my Ubuntu box and a new kernel has been installed (3.0.0-15 x86_64). At boot, my system hangs up just after the /scripts/init-bottom phase. I tried with kernel 3.0.0-14, the behavior is the same. The latest working kernel was 3.0.0-13. After digging, it&#8217;s when the init-bottom performs vgchange -a y. The problem is [...]]]></description>
			<content:encoded><![CDATA[<p>Today, I updated my Ubuntu box and a new kernel has been installed (3.0.0-15 x86_64).</p>
<p>At boot, my system hangs up just after the <code>/scripts/init-bottom</code> phase.</p>
<p>I tried with kernel 3.0.0-14, the behavior is the same. The latest working kernel was 3.0.0-13.</p>
<p>After digging, it&#8217;s when the init-bottom performs <code>vgchange -a y</code>.</p>
<p>The problem is that the script is waiting for the udev device, and starting from kernel 3.0.0-14, it doesn&#8217;t work and we raise the timeout.<br />
So it means that the startup is not totally stuck, it just takes long long long time <img src='http://blog.nanthrax.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>The workaround is to disable the udev support during LVM2 vgchange.</p>
<p>To do that, edit the <code>/lib/udev/rules.d/85-lvm2.rules</code> and add the <code>--noudevsync</code> option to vgchange:</p>
<p><code><br />
SUBSYSTEM=="block", ACTION=="add|change", ENV{ID_FS_TYPE}=="lvm*|LVM*", \<br />
        RUN+="watershed sh -c '/sbin/lvm vgscan; /sbin/lvm vgchange --noudevsync -a y'"<br />
</code></p>
<p>We have to update the initramfs:</p>
<p><code><br />
update-initramfs -u -k all<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.nanthrax.net/2012/01/ubuntu-boot-hang-up-with-kernel-3-0-0-15-and-lvm2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Apache Karaf 2011 Millesime</title>
		<link>http://blog.nanthrax.net/2012/01/apache-karaf-2011-millesime/</link>
		<comments>http://blog.nanthrax.net/2012/01/apache-karaf-2011-millesime/#comments</comments>
		<pubDate>Mon, 02 Jan 2012 13:01:43 +0000</pubDate>
		<dc:creator>jbonofre</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Apache Karaf]]></category>
		<category><![CDATA[karaf]]></category>

		<guid isPermaLink="false">http://blog.nanthrax.net/?p=228</guid>
		<description><![CDATA[We are preparing the new Karaf &#8220;Cuvée&#8221; 2012, with the main new release Karaf 3.0. Karaf 2011 is a good millésime with the following activity: New sub-projects: 3 (Cellar, Cave, WebConsole) Number of commits: 1,851 Number of releases: 11 Number of messages on the forums/mailing lists: 3119 Number of direct downloads: 44,829 Number of tickets [...]]]></description>
			<content:encoded><![CDATA[<p>We are preparing the new Karaf &#8220;Cuvée&#8221; 2012, with the main new release Karaf 3.0.</p>
<p>Karaf 2011 is a good millésime with the following activity:</p>
<ul>
<li>New sub-projects: 3 (Cellar, Cave, WebConsole)</li>
<li>Number of commits: 1,851</li>
<li>Number of releases: 11</li>
<li>Number of messages on the forums/mailing lists: 3119</li>
<li>Number of direct downloads: 44,829 </li>
<li>Number of tickets open/resolved: 782/577</li>
<li>Karaf active team: 12</li>
</ul>
<p>A good millésime for sure.</p>
<p>Now, it&#8217;s time to focus on the 2012 vendange <img src='http://blog.nanthrax.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Thanks for the Karaf users and the wonderful Karaf team <img src='http://blog.nanthrax.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.nanthrax.net/2012/01/apache-karaf-2011-millesime/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Coming in Karaf 3.0: new KAR service, command, management</title>
		<link>http://blog.nanthrax.net/2011/12/coming-in-karaf-3-0-new-kar-service-command-management/</link>
		<comments>http://blog.nanthrax.net/2011/12/coming-in-karaf-3-0-new-kar-service-command-management/#comments</comments>
		<pubDate>Tue, 27 Dec 2011 17:33:27 +0000</pubDate>
		<dc:creator>jbonofre</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Apache Karaf]]></category>
		<category><![CDATA[kar]]></category>
		<category><![CDATA[karaf]]></category>

		<guid isPermaLink="false">http://blog.nanthrax.net/?p=220</guid>
		<description><![CDATA[We are working hard on Karaf 3.0. This major new version of Karaf will bring a lot of new features and enhancements. KAR in Karaf 2.2.4 As you may know, Karaf 2.2.x already provides &#8220;basic&#8221; KAR support. A KAR (KARaf archive) is a zip file which gathers a features XML and all bundles and configuration [...]]]></description>
			<content:encoded><![CDATA[<p>We are working hard on Karaf 3.0. This major new version of Karaf will bring a lot of new features and enhancements.</p>
<h3>KAR in Karaf 2.2.4</h3>
<p>As you may know, Karaf 2.2.x already provides &#8220;basic&#8221; KAR support.</p>
<p>A KAR (KARaf archive) is a zip file which gathers a features XML and all bundles and configuration files dependencies. It means that a KAR is an atomic artifact which can be deployed without an Internet connection (as all is shipped in the KAR file itself).</p>
<p>In Karaf 2.2.x, the KAR support was:</p>
<ul>
<li>a KAR deployer: you can copy a KAR file into the deploy folder, and KARAF will uncompress the KAR file, and install all features containing in the shipped features XML.</li>
<li>a create-kar goal in the features-maven-plugin: this goal reads a features XML and creates a KAR file, ready to be deployed.
</ul>
<p>So, all KAR logics were in the KAR deployer.</p>
<p>It means that you are not able to deploy a KAR from a remote URL, etc.</p>
<h3>What&#8217;s coming in Karaf 3.0</h3>
<h4>The KAR service</h4>
<p>In Karaf 3.0, the KAR core bundle provides a <code>org.apache.karaf.kar.KarService</code> OSGi service.</p>
<p>This service allows you to list the installed KAR files, deploy a KAR file from an URL, uninstall a KAR file.</p>
<p>Now the KAR service use a <code>data/kar</code> directory to store the KAR file and uncompress the KAR directly in the <code>system</code> repository (the <code>local-repo</code> directory is no more needed and created).</p>
<h4>The KAR shell commands</h4>
<p>Now, you have a complete control on the KAR files (including remotely using a SSH connection).</p>
<p>You can list, install, and uninstall KAR files using the <code>kar:*</code> commands:</p>
<ul>
<li><code>kar:list</code> displays the installed KAR files</li>
<li><code>kar:install</code> installs a KAR file from a given URL. The URL could be a &#8220;classic&#8221; file: or http:, but, as for all stuff in Karaf, mvn: (for instance mvn:net.nanthrax/test/1.0-SNAPSHOT/kar)</li>
<li><code>kar:uninstall</code> uninstalls a KAR file (identified by the name as displayed by <code>kar:list</code>). This command doesn&#8217;t alter the system repository by default, but you have an option -c (&#8211;cleanup) to cleanup the system repository.</li>
</ul>
<h4>The KAR MBean</h4>
<p>You can also manipulate KAR files using JMX via a new MBean: org.apache.karaf:type=kar,name=root.</p>
<p>This MBean provides quite the same actions that you can do using the commands:</p>
<ul>
<li>getKars()</li>
<li>install(url)</li>
<li>uninstall(name)</li>
<li>uninstall(name, clean)</li>
</ul>
<h3>In progress</h3>
<p>It&#8217;s still a work in progress. I will add a bunch of unit tests and new features around the KAR files.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.nanthrax.net/2011/12/coming-in-karaf-3-0-new-kar-service-command-management/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Overview on Apache Karaf, Pax Web, and Camel archetypes</title>
		<link>http://blog.nanthrax.net/2011/12/overview-on-apache-karaf-pax-web-and-camel-archetypes/</link>
		<comments>http://blog.nanthrax.net/2011/12/overview-on-apache-karaf-pax-web-and-camel-archetypes/#comments</comments>
		<pubDate>Mon, 19 Dec 2011 07:02:34 +0000</pubDate>
		<dc:creator>jbonofre</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Apache Camel]]></category>
		<category><![CDATA[Apache Karaf]]></category>
		<category><![CDATA[camel]]></category>
		<category><![CDATA[karaf]]></category>
		<category><![CDATA[pax-web]]></category>

		<guid isPermaLink="false">http://blog.nanthrax.net/?p=211</guid>
		<description><![CDATA[In my previous blog post, I introduced the Karaf Maven plugins. The Karaf Maven plugins are really helpful, starting from an existing POM. If you can write this POM by hand (it&#8217;s my favorite way ), we also provide several archetypes which create and pre-configure a Maven project for you. Karaf Archetypes The next Karaf [...]]]></description>
			<content:encoded><![CDATA[<p>In my previous blog post, I introduced the Karaf Maven plugins.<br />
The Karaf Maven plugins are really helpful, starting from an existing POM.</p>
<p>If you can write this POM by hand (it&#8217;s my favorite way <img src='http://blog.nanthrax.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> ), we also provide several archetypes which create and pre-configure a Maven project for you.</p>
<h2>Karaf Archetypes</h2>
<p>The next Karaf release (2.2.5) provides a set of new archetypes:</p>
<h4>Assembly Archetype</h4>
<p>The karaf-assembly-archetype create a Maven project which create a custom Karaf distribution.</p>
<p>It allows you to create your own Karaf distribution. The project downloads a Karaf standard distribution (in tar.gz and zip formats), unpack it, and create a new distribution.</p>
<p>The easiest way to use it is to use the interactive mode:</p>
<p><code><br />
mvn archetype:generate -DarchetypeGroupId=org.apache.karaf.archetypes -DarchetypeArtifactId=karaf-assembly-archetype -DarchetypeVersion=2.2.5-SNAPSHOT<br />
</code></p>
<h4>Bundle Archetype</h4>
<p>If basically a bundle is a jar file with some special statement in the MANIFEST, the easiest way to create a bundle is to use the Felix maven-bundle-plugin.</p>
<p>Karaf provides an archetype which prepare a Maven project and provide a bundle Activator (a special callback class when the bundle start/stop).</p>
<p>To generate this project, simply type:</p>
<p><code><br />
mvn archetype:generate -DarchetypeGroupId=org.apache.karaf.archetypes -DarchetypeArtifactId=karaf-bundle-archetype -DarchetypeVersion=2.2.5-SNAPSHOT<br />
</code></p>
<p>NB: I think that this archetype should be in Felix (as the same level as maven-bundle-plugin), I will propose a donation to the Felix community.</p>
<h4>Blueprint Archetype</h4>
<p>Blueprint is IoC approach applied to OSGi (it comes from Spring DM in fact). It allows you to avoid to write bundle Activator, ServiceTracker, etc.</p>
<p>Karaf provides a karaf-blueprint-archetype which prepare a Maven project including the maven-bundle-plugin, and a blueprint descriptor with a sample of OSGi service definition:</p>
<p><code><br />
mvn archetype:generate -DarchetypeGroupId=org.apache.karaf.archetypes -DarchetypeArtifactId=karaf-blueprint-archetype -DarchetypeVersion=2.2.5-SNAPSHOT<br />
</code></p>
<p>NB: I think that this archetype should be in Aries (as it&#8217;s the blueprint implementation used in Karaf), I will propose a donation to the Aries community.</p>
<h4>Feature Archetype</h4>
<p>In Karaf, a feature is an application descriptor, defining all bundles, configurations/configuration files, others features. This features descriptor could be generated by hand (it&#8217;s my favorite way, and I guess the recommended one), we also provide a archetype which prepare a project to generate features file regarding the POM dependencies:</p>
<p><code><br />
mvn archetype:generate -DarchetypeGroupId=org.apache.karaf.archetypes -DarchetypeArtifactId=karaf-feature-archetype -DarchetypeVersion=2.2.5-SNAPSHOT<br />
</code></p>
<h4>Kar Archetype</h4>
<p>We saw in my previous post a new goal of the features-maven-plugin to create a kar file starting from a features XML. A KAR file is a zip file containing the features XML and all its dependencies.</p>
<p>We also provide an archetype to prepare a Maven project containing a features XML and generate a KAR file:</p>
<p><code><br />
mvn archetype:generate -DarchetypeGroupId=org.apache.karaf.archetypes -DarchetypeArtifactId=karaf-kar-archetype -DarchetypeVersion=2.2.5-SNAPSHOT<br />
</code></p>
<h2>Pax-Web Archetypes</h2>
<p>We also add several archetypes in Pax Web to deal with the web bundle. Charles talk about wab-gwt archetype in his last blog entry (<a href="http://cmoulliard.blogspot.com/2011/12/run-google-web-toolkit-2-project-on.html">http://cmoulliard.blogspot.com/2011/12/run-google-web-toolkit-2-project-on.html</a>), but I added also two others.</p>
<h4>Web Bundle Archetype</h4>
<p>The Web Bundle Archetype create a &#8220;special&#8221; bundle containing web resources and statements. It creates a Maven project with webapp resources and WebApp Context in the POM:</p>
<p><code><br />
mvn archetype:generate -DarchetypeGroupId=org.ops4j.pax.web.archetypes -DarchetypeArtifactId=wab-archetype -DarchetypeVersion=1.1.2-SNAPSHOT<br />
</code></p>
<h4>War Archetype</h4>
<p>We also provide an archetype to create a Maven project which generate a standard war (that you can deploy &#8220;outside&#8221; of OSGi) but including OSGi statements in the MANIFEST (which allows you to use OSGi values):</p>
<p><code><br />
mvn archetype:generate -DarchetypeGroupId=org.ops4j.pax.web.archetypes -DarchetypeArtifactId=war-archetype -DarchetypeVersion=1.1.2-SNAPSHOT<br />
</code></p>
<h2>Camel Archetypes</h2>
<p>Camel also provides a set of very useful archetypes, especially:</p>
<ul>
<li><code>camel-archetype-blueprint</code> to generate a Maven project with a blueprint XML in which you can define your routes</li>
<li><code>camel-archetype-component</code> providing a template to create your own Camel component</li>
<li><code>camel-archetype-dataformat</code> providing a template to create your own Camel data format</li>
<li><code>camel-archetype-java</code> providing a template with a class in which you can define your routes</li>
<li><code>camel-archetype-spring</code> to generate a Maven project with a Spring XML in which you can define your routes</li>
</ul>
<p>For instance, to create a Camel blueprint Maven project, simply type:</p>
<p><code><br />
mvn archetype:generate -DarchetypeGroupId=org.apache.camel.archetypes -DarchetypeArtifactId=camel-archetype-blueprint -DarchetypeVersion=2.9-SNAPSHOT<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.nanthrax.net/2011/12/overview-on-apache-karaf-pax-web-and-camel-archetypes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Do you know the Apache Karaf Maven plugins ?</title>
		<link>http://blog.nanthrax.net/2011/12/do-you-know-the-apache-karaf-maven-plugins/</link>
		<comments>http://blog.nanthrax.net/2011/12/do-you-know-the-apache-karaf-maven-plugins/#comments</comments>
		<pubDate>Mon, 12 Dec 2011 10:57:00 +0000</pubDate>
		<dc:creator>jbonofre</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Apache Karaf]]></category>
		<category><![CDATA[karaf]]></category>

		<guid isPermaLink="false">http://blog.nanthrax.net/?p=196</guid>
		<description><![CDATA[Apache Karaf is not only an OSGi container, it also provides a set of Maven plugins for tooling. In the next Apache Karaf 2.2.5 release, you will find two Maven plugins: cmdhelp-maven-plugin generates documentation (in DocBook or Scalate format) for Karaf commands features-maven-plugin provides a set of goals to manipulate Karaf features In this blog [...]]]></description>
			<content:encoded><![CDATA[<p>Apache Karaf is not only an OSGi container, it also provides a set of Maven plugins for tooling.</p>
<p>In the next Apache Karaf 2.2.5 release, you will find two Maven plugins:</p>
<ul>
<li><code>cmdhelp-maven-plugin</code> generates documentation (in DocBook or Scalate format) for Karaf commands</li>
<li><code>features-maven-plugin</code> provides a set of goals to manipulate Karaf features</li>
</ul>
<p>In this blog post, I will cover the <code>features-maven-plugin</code> as I think it&#8217;s the most interesting for your life with Karaf.</p>
<h4>Generate a features XML</h4>
<p>If I prefer to handle and create the features XML by hand, the <code>features:generate-features-file</code> goal could do it for you.</p>
<p>It takes the dependencies of your project (described in the POM), and create the features XML.</p>
<p>For instance, in the following example, a features XML file will be generated containing the commons-lang bundle:</p>
<p><code><br />
&lt;xml version="1.0" encoding="UTF-8"?&gt;<br />
&lt;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/xsd/maven-4.0.0.xsd"&gt;</p>
<p>&nbsp; &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;</p>
<p>&nbsp; &lt;groupId&gt;net.nanthrax&lt;/groupId&gt;<br />
&nbsp; &lt;artifactId&gt;test-features&lt;/artifactId&gt;<br />
&nbsp; &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;<br />
&nbsp; &lt;packaging&gt;pom&lt;/packaging&gt;</p>
<p>&nbsp; &lt;dependencies&gt;<br />
&nbsp; &nbsp; &lt;dependency&gt;<br />
&nbsp; &nbsp; &nbsp; &lt;groupId&gt;org.apache.servicemix.bundles&lt;/groupId&gt;<br />
&nbsp; &nbsp; &nbsp; &lt;artifactId&gt;org.apache.servicemix.bundles.commons-lang&lt;/artifactId&gt;<br />
&nbsp; &nbsp; &nbsp; &lt;version&gt;2.4_4&lt;/version&gt;<br />
&nbsp; &nbsp; &lt;/dependency&gt;<br />
&nbsp; &lt;/dependencies&gt;</p>
<p>&nbsp; &lt;build&gt;<br />
&nbsp; &nbsp; &lt;plugins&gt;<br />
&nbsp; &nbsp; &nbsp; &lt;plugin&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;groupId&gt;org.apache.karaf.tooling&lt;/groupId&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;artifactId&gt;features-maven-plugin&lt;/artifactId&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;version&gt;2.2.5-SNAPSHOT&lt;/version&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;executions&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;execution&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;id&gt;generate-features-filelt;/id&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;goals&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;goal&gt;generate-features-file&lt;/goal&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/goals&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;configuration&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;karafVersion&gt;2.2.4&lt;/karafVersion&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/configuration&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/execution&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;/executions&gt;<br />
&nbsp; &nbsp; &nbsp; &lt;/plugin&gt;<br />
&nbsp; &nbsp; &lt;/plugins&gt;<br />
&nbsp; &lt;/build&gt;<br />
&lt;/project&gt;<br />
</code></p>
<p>You can find the features XML in the target directory.</p>
<h4>Copy features resources in a local directory</h4>
<p>The <code>features:add-features-to-repo</code> goal reads a set of features and copy features resources into a target folder. Especially, it allows you to prepare a custom distribution, allowing this distribution to avoid Internet connection to resolve features resources.</p>
<p>The following example will read a features XML and populate the <code>target/system</code> directory with the feature A, B, and C resources (bundles and configuration files):</p>
<p><code><br />
&lt;xml version="1.0" encoding="UTF-8"?&gt;<br />
&lt;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/xsd/maven-4.0.0.xsd"&gt;</p>
<p>&nbsp; &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;</p>
<p>&nbsp; &lt;groupId&gt;net.nanthrax&lt;/groupId&gt;<br />
&nbsp; &lt;artifactId&gt;test-features&lt;/artifactId&gt;<br />
&nbsp; &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;<br />
&nbsp; &lt;packaging&gt;pom&lt;/packaging&gt;</p>
<p>&nbsp; &lt;build&gt;<br />
&nbsp; &nbsp; &lt;plugins&gt;<br />
&nbsp; &nbsp; &nbsp; &lt;plugin&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;groupId&gt;org.apache.karaf.tooling&lt;/groupId&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;artifactId&gt;features-maven-plugin&lt;/artifactId&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;version&gt;2.2.5-SNAPSHOT&lt;/version&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;executions&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;execution&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;id&gt;add-features-to-repo&lt;/id&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;goals&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;goal&gt;features-add-to-repo&lt;/goal&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/goals&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;configuration&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;descriptors&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;descriptor&gt;file:${project.basedir}/src/main/resources/features.xml&lt;/descriptor&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/descriptors&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;features&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;feature&gt;A&lt;/feature&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;feature&gt;B/2.0-SNAPSHOT&lt;/feature&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/features&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;repository&gt;target/system&lt;/repository&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/configuration&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/execution&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;/executions&gt;<br />
&nbsp; &nbsp; &nbsp; &lt;/plugin&gt;<br />
&nbsp; &nbsp; &lt;/plugins&gt;<br />
&nbsp; &lt;/build&gt;<br />
&lt;/project&gt;<br />
</code></p>
<p>NB: with Karaf 2.2.5, you can define a feature with just its name, or with name/version. It allows to target explicitly with which feature populate the target repository directory.</p>
<h4>Create a KAR file</h4>
<p>A KAR file (Karaf ARchive) is a zip file which package a features XML with all dependencies (bundles and configuration files).</p>
<p>It allows you to deploy (just by copying the kar file in the Karaf deploy folder) an atomic archive shipping all required resources (so no Internet connection is required).</p>
<p>The <code>features:create-kar</code> goal create a kar file starting from a given features XML.</p>
<p>The following example create a kar file (in the target folder) starting from a <code>src/main/resources/features.xml</code>:</p>
<p><code><br />
&lt;xml version="1.0" encoding="UTF-8"?&gt;<br />
&lt;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/xsd/maven-4.0.0.xsd"&gt;</p>
<p>&nbsp; &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;</p>
<p>&nbsp; &lt;groupId&gt;net.nanthrax&lt;/groupId&gt;<br />
&nbsp; &lt;artifactId&gt;test-features&lt;/artifactId&gt;<br />
&nbsp; &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;<br />
&nbsp; &lt;packaging&gt;pom&lt;/packaging&gt;</p>
<p>&nbsp; &lt;build&gt;<br />
&nbsp; &nbsp; &lt;plugins&gt;<br />
&nbsp; &nbsp; &nbsp; &lt;plugin&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;groupId&gt;org.apache.karaf.tooling&lt;/groupId&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;artifactId&gt;features-maven-plugin&lt;/artifactId&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;version&gt;2.2.5-SNAPSHOT&lt;/version&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;executions&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;execution&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;id&gt;create-kar&lt;/id&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;goals&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;goal&gt;create-kar&lt;/goal&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/goals&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;configuration&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;featuresFile&gt;${project.basedir}/src/main/resources/features.xml&lt;/featuresFile&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/configuration&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/execution&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;/executions&gt;<br />
&nbsp; &nbsp; &nbsp; &lt;/plugin&gt;<br />
&nbsp; &nbsp; &lt;/plugins&gt;<br />
&nbsp; &lt;/build&gt;<br />
&lt;/project&gt;<br />
</code></p>
<h4>Karaf 3.0 changes</h4>
<p>In Karaf 3.0.0, you will find only one Maven plugin: <code>karaf-maven-plugin</code>, gathering the two &#8220;old&#8221; one.</p>
<p>The KAR support is also extended and give more place to KAR archives (used to construct distributions now).</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.nanthrax.net/2011/12/do-you-know-the-apache-karaf-maven-plugins/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Apache Karaf Cellar and DOSGi</title>
		<link>http://blog.nanthrax.net/2011/11/apache-karaf-cellar-and-dosgi/</link>
		<comments>http://blog.nanthrax.net/2011/11/apache-karaf-cellar-and-dosgi/#comments</comments>
		<pubDate>Tue, 29 Nov 2011 09:38:35 +0000</pubDate>
		<dc:creator>jbonofre</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Apache Karaf]]></category>
		<category><![CDATA[Apache ServiceMix]]></category>
		<category><![CDATA[karaf]]></category>
		<category><![CDATA[servicemix]]></category>

		<guid isPermaLink="false">http://blog.nanthrax.net/?p=190</guid>
		<description><![CDATA[Next version of Apache Karaf Cellar will include a DOSGi (Distributed OSGi) implementation. There are several existing DOSGi implementations: in Apache CXF (powered by the CXF stack), in Fuse Fabric, etc. The purpose of the Cellar one is to leverage the Cellar existing (Hazelcast instance, distributed map, etc), and to be very easy to use. [...]]]></description>
			<content:encoded><![CDATA[<p>Next version of Apache Karaf Cellar will include a DOSGi (Distributed OSGi) implementation.</p>
<p>There are several existing DOSGi implementations: in Apache CXF (powered by the CXF stack), in Fuse Fabric, etc.</p>
<p>The purpose of the Cellar one is to leverage the Cellar existing (Hazelcast instance, distributed map, etc), and to be very easy to use.</p>
<h3>Karaf Cellar DOSGi installation</h3>
<p>Cellar DOSGi is part of the main cellar feature. To install it:</p>
<p><code><br />
karaf@root&gt; features:addurl mvn:org.apache.karaf.cellar/apache-karaf-cellar/3.0.0-SNAPSHOT/xml/features<br />
karaf@root&gt; features:install cellar<br />
</code></p>
<h3>Distributed services</h3>
<p>You can note a new command available in Cellar:</p>
<p><code><br />
karaf@root&gt; cluster:list-services<br />
</code></p>
<p>It displays the list of services &#8220;cluster aware&#8221;. It means a service that could be used remotely from another node.</p>
<h3>Code sample</h3>
<p>To illustrate the Cellar DOSGi usage, we will use two bundles:</p>
<ul>
<li>the provider bundle is installed on node A and &#8220;expose&#8221; a distributed service</li>
<li>the client bundle is installed on node B and will use the provider service
</ul>
<h4>Provider bundle</h4>
<p>The provider bundle expose an OSGi service, flagged as a distributed service.</p>
<p>The service is very simple, it&#8217;s just an echo service.</p>
<p>Here&#8217;s the interface describing the service:</p>
<p><code><br />
package org.apache.karaf.cellar.sample;</p>
<p>public interface EchoService {</p>
<p>&nbsp; String process(String message);</p>
<p>}<br />
</code></p>
<p>and the corresponding implementation:</p>
<p><code><br />
package org.apache.karaf.cellar.sample;</p>
<p>public class EchoServiceImpl implements EchoService {</p>
<p>&nbps; public String process(String message) {<br />
&nbsp; &nbsp; return "Processed by distributed service: " + message;<br />
&nbsp; }</p>
<p>}<br />
</code></p>
<p>Up to now, nothing special, nothing related to DOSGi or Cellar.</p>
<p>To expose the service in Karaf, we create a blueprint descriptor:</p>
<p><code><br />
&lt;?xml version="1.0" encoding="UTF-8"?&gt;<br />
&lt;blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"&gt;</p>
<p>&nbsp; &lt;bean id="echoService" class="org.apache.karaf.cellar.sample.EchoServiceImpl"/&gt;</p>
<p>&nbsp; &lt;service ref="echoService" interface="org.apache.karaf.cellar.sample.EchoService"&gt;<br />
&nbsp; &nbsp; &lt;service-properties&gt;<br />
&nbsp; &nbsp; &nbsp; &lt;entry key="service.exported.interfaces" value="*"/&gt;<br />
&nbsp; &nbsp; &lt;/service-properties&gt;<br />
&nbsp; &lt;/service&gt;</p>
<p>&lt;/blueprint&gt;<br />
</code></p>
<p>We can note that the only &#8220;special&#8221; part is that we added the <code>service.exported.interfaces</code> property to the <code>echoService</code>.</p>
<p>It&#8217;s just a flag to define the interface/service to define as distributed (it means accessible from remote node).</p>
<p>We didn&#8217;t change the code of the service itself, just added this property. It means that it&#8217;s really easy to turn an existing service as a distributed service.</p>
<h4>Client bundle</h4>
<p>The client bundle will get a reference to the <code>echoService</code>. In fact, the reference will be a kind of proxy to the service implementation located remotely, on another node.</p>
<p>The client is really simple, it indefinitely iterates to use the clusterService:</p>
<p><code><br />
package org.apache.karaf.cellar.sample.client;</p>
<p>public class ServiceClient {</p>
<p>&nbsp; private EchoService echoService;</p>
<p>&nbsp; public void setEchoService(EchoService echoService) {<br />
&nbsp; &nbsp; this.echoService = echoService;<br />
&nbsp; }</p>
<p>&nbsp; public EchoService getEchoService() {<br />
&nbsp; &nbsp; return this.echoService;<br />
&nbsp; }</p>
<p>&nbsp; public void process() throws Exception {<br />
&nbsp; &nbsp; int count = 0;<br />
&nbsp; &nbsp; while (true) {<br />
&nbsp; &nbsp; &nbsp; System.out.println(echoService.process("Call " + count));<br />
&nbsp; &nbsp; &nbsp; Thread.sleep(5000);<br />
&nbsp; &nbsp; &nbsp; count++;<br />
&nbsp; &nbsp; }<br />
&nbsp; }</p>
<p>}<br />
</code></p>
<p>We inject the <code>echoService</code> using Blueprint:</p>
<p><code><br />
&#038;lt?xml version="1.0" encoding="UTF-8"?&gt;<br />
&lt;blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"&gt;</p>
<p>&nbsp; &lt;reference id="echoService" interface="org.apache.karaf.cellar.sample.EchoService"/&gt;</p>
<p>&nbsp; &lt;bean id="serviceClient" class="org.apache.karaf.cellar.sample.client.ServiceClient" init-method="process"&gt;<br />
&nbps; &nbsp; &lt;property name="echoService" ref="echoService"/&gt;<br />
&nbsp; &lt;/bean&gt;</p>
<p>&lt;/blueprint&gt;<br />
</code></p>
<p>It&#8217;s done. The <code>serviceClient</code> will use the <code>echoService</code>. If a &#8220;local&#8221; <code>echoService</code> exists, the OSGi framework will bind the reference to this service, else Cellar will look for a distributed service (on all node) exporting the <code>EchoService</code> interface and bind a proxy to the distributed service.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.nanthrax.net/2011/11/apache-karaf-cellar-and-dosgi/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ApacheCon NA11 2011: so great</title>
		<link>http://blog.nanthrax.net/2011/11/apachecon-na11-2011-so-great/</link>
		<comments>http://blog.nanthrax.net/2011/11/apachecon-na11-2011-so-great/#comments</comments>
		<pubDate>Sat, 12 Nov 2011 13:08:17 +0000</pubDate>
		<dc:creator>jbonofre</dc:creator>
				<category><![CDATA[Apache]]></category>

		<guid isPermaLink="false">http://blog.nanthrax.net/?p=184</guid>
		<description><![CDATA[Sad, too early . You know this feeling when something great is ended. I was at the ApacheCon NA11, Vancouver this week, and it was simply awesome. I gave two talks: Apache ServiceMix future (http://people.apache.org/~jbonofre/smx_future.ppt) Deployment with Apache Karaf and ACE (http://people.apache.org/~jbonofre/deploy_karaf_ace.ppt) On the other hand, I attended to the following session: Business and Open [...]]]></description>
			<content:encoded><![CDATA[<p>Sad, too early <img src='http://blog.nanthrax.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> . You know this feeling when something great is ended.</p>
<p>I was at the ApacheCon NA11, Vancouver this week, and it was simply awesome.</p>
<p>I gave two talks:</p>
<ul>
<li>Apache ServiceMix future (<a href="http://people.apache.org/~jbonofre/smx_future.ppt">http://people.apache.org/~jbonofre/smx_future.ppt</a>)</li>
<li>Deployment with Apache Karaf and ACE (<a href="http://people.apache.org/~jbonofre/deploy_karaf_ace.ppt">http://people.apache.org/~jbonofre/deploy_karaf_ace.ppt</a>)</li>
</ul>
<p>On the other hand, I attended to the following session:</p>
<ul>
<li>Business and Open Source, open discussion with especially Bertrand (Delacretaz), Debbie (Moynihan), Ross (Turk)</li>
<li>Apache, Branding and Trademark, with Shane (Curcuru)</li>
<li>Archiva by Brett (Porter)</li>
<li>Whirr by Tom (White)</li>
<li>DOSGi and cloud by Guillaume (Nodet)</li>
</ul>
<p>I discussed with a lot of people:</p>
<ul>
<li>Of course Dan (Kulp), Hadrian (Zbarcea), Ross (Turk)</li>
<li>Guillaume (Nodet), it was really great to work together, discussed about our roadmap for Karaf and ServiceMix, etc. Thanks a bunch Guillaume <img src='http://blog.nanthrax.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </li>
<li>Christian (Muller) and Jon (Anstey), we talked about Camel. These guys are so cool <img src='http://blog.nanthrax.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </li>
<li>Mohammad (Nour El-Din) about projects in the incubator, proposals, etc</li>
<li>Brett (Porter) and Carlos (Sanchez) about Archiva</li>
<li>Marcel (Offermans), Alex, Bram, about ACE and OSGi</li>
<li>lot of others (Bertrand, Shane, etc, etc) that I would like to thank too</li>
</ul>
<p>Once again, thank you all.</p>
<p>See you in November 2012 for the ApacheCon Europe, Germany <img src='http://blog.nanthrax.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.nanthrax.net/2011/11/apachecon-na11-2011-so-great/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Apache Karaf moved to OSGi r4.3</title>
		<link>http://blog.nanthrax.net/2011/11/apache-karaf-moved-to-osgi-r4-3/</link>
		<comments>http://blog.nanthrax.net/2011/11/apache-karaf-moved-to-osgi-r4-3/#comments</comments>
		<pubDate>Thu, 03 Nov 2011 13:35:29 +0000</pubDate>
		<dc:creator>jbonofre</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Apache Karaf]]></category>
		<category><![CDATA[karaf]]></category>
		<category><![CDATA[osgi]]></category>

		<guid isPermaLink="false">http://blog.nanthrax.net/?p=172</guid>
		<description><![CDATA[Apache Karaf trunk (future 3.0 release) now fully supports OSGi 4.3 release by running Apache Felix framework 4.0.1 and Eclipse Equinox 3.7.1. If this update is just a support update, it gives us the opportunity to see what we can leverage from the OSGi r4 early draft. What&#8217;s in preparation in OSGi r4 ? I [...]]]></description>
			<content:encoded><![CDATA[<p>Apache Karaf trunk (future 3.0 release) now fully supports OSGi 4.3 release by running Apache Felix framework 4.0.1 and Eclipse Equinox 3.7.1.</p>
<p>If this update is just a support update, it gives us the opportunity to see what we can leverage from the OSGi r4 early draft.</p>
<h3>What&#8217;s in preparation in OSGi r4 ?</h3>
<p>I will not cover the whole OSGi 4 specification. I will just spot some features that will be &#8220;key&#8221; features in Karaf.</p>
<h4>New OBR specification (RFC-0112)</h4>
<p>Currently, there are a number of available solutions to downloading and installing bundles:</p>
<ul>
<li>current OBR stores the bundles and allows users to discover bundles</li>
<li>P2 provisioning platform used in Eclipse</li>
<li>Maven repositories as used in Karaf</li>
<li>Nimble Repositories which are an extension of OBR to deal with active state dependencies</li>
</ul>
<p>The idea is to gather all these concepts into a new OBR specification.</p>
<p>The new OBR will be able to:</p>
<ul>
<li>handle bundle fragments dependencies, provide management tooling</li>
<li>can use a resolver strategy allowing to work with Felix OBR, Sigil or Nimble</li>
<li>a normalized and new OBR XML schema, supporting bundle execution environment, etc.</li>
</ul>
<p>Karaf Cave will be the perfect place to leverage new OBR specification implementation. It will allow Karaf to deploy bundles provided by P2, OBR, Nimble, etc.</p>
<p>Karaf Cave will also extend the OBR specification in order to directly handle Karaf features.</p>
<p>ACE will also use this new OBR specification for the ACE repository implementation.</p>
<h4>Subsystems (RFC-0152)</h4>
<p>Most of container defines a concept to gather bundles together and provide complete applications.</p>
<p>Depending of the container, we have different wording:</p>
<ul>
<li>in Karaf, we name it features</li>
<li>in Spring DM, the name is applications</li>
<li>in Aries, it&#8217;s applications too</li>
<li>in Eclipse, it&#8217;s features or installable units</li>
</ul>
<p>If the core concept is the same, the implementations are very different.</p>
<p>The Subsystems specification aim to use an unique way to define the concept of applications.</p>
<p>Subsystems leverages others OSGi technologies:</p>
<ul>
<li>OBR, we already discussed about that in the first section. It&#8217;s the repository used to store all bundles required to be deploy to form an application.</li>
<li>framework hooks (RFC-0138) to isolate or group subsystems within a single OSGi framework.</li>
<li>deployment admin defines a file format to ship and deploy applications.</li>
<li>application admin provides the concept of an application in OSGi.</li>
</ul>
<p>Subsystems could become a key feature in Karaf 3.0, as it could handle Karaf features and KAR.</p>
<p>We implemented in features concepts defined in this specification. For instance, in a Karaf features, we can use an OBR resolver.</p>
<p>More over, subsystems provides new features missing in the current Karaf features, especially a complete lifecycle, better subsystems dependencies.</p>
<p>Regarding the new OBR and subsystems specifications, we can have a consistent way to deploy applications and bundles.</p>
<h4>OSGi for Enterprise (RFC-0164 and RFC-0146)</h4>
<p>RFC-0146 covers Java EE JCA for OSGi. It will provides support for resource adapters, packaged as a RAR. The resources can be integrate with OSGi services.</p>
<p>On the other hand, RFC-0164 deals with Blueprint Declarative Transaction. It means that we can define the transaction on a bean methods by declaration in the blueprint descriptor:</p>
<p><code><br />
&lt;bean ...&gt;<br />
 &lt;tx:transaction method="count*" value="Required"/&gt;<br />
 &lt;tx:transaction method="count*Row" value="RequiresNew"/&gt;<br />
&lt;/bean&gt;<br />
</code></p>
<p>These two specifications are a step forward to a Karaf EE distribution, by including such features and providing others.</p>
<h4>OSGi JMX (RFC-0169)</h4>
<p>Lot of comments and bugs have been raised regarding the OSGi-JMX specification.</p>
<p>This specification aim to implement most of suggestions and fix bugs.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.nanthrax.net/2011/11/apache-karaf-moved-to-osgi-r4-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

