<?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>The OSGi Look &#187; tutorial</title>
	<atom:link href="http://www.osgilook.com/category/tutorial/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.osgilook.com</link>
	<description>There&#039;s life beyond J(2)EE</description>
	<lastBuildDate>Thu, 10 Dec 2009 21:20:23 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>GWT and OSGi in the Cloud</title>
		<link>http://www.osgilook.com/2009/12/10/gwt-and-osgi-in-the-cloud/</link>
		<comments>http://www.osgilook.com/2009/12/10/gwt-and-osgi-in-the-cloud/#comments</comments>
		<pubDate>Thu, 10 Dec 2009 21:20:23 +0000</pubDate>
		<dc:creator>fdiotalevi</dc:creator>
				<category><![CDATA[osgi]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.osgilook.com/2009/12/10/gwt-and-osgi-in-the-cloud/</guid>
		<description><![CDATA[I hear every day more talks about bringing OSGi applications to the Cloud, and I think that&#8217;s a very exciting opportunity (since I will talk about that at the upcoming JaxLondon/OSGi Devcon Europe).
In this article Scott Lewis go even further and showcase a Twitter user status service with GWT, OSGi and Amazon Web services:

  [...]]]></description>
			<content:encoded><![CDATA[<p>I hear every day more talks about bringing OSGi applications to the Cloud, and I think that&#8217;s a very exciting opportunity (since I will talk about that at the upcoming J<a href="http://www.jaxlondon.com/">axLondon/OSGi Devcon Europe</a>).</p>
<p>In <a href="http://eclipseecf.blogspot.com/2009/12/cloud-osgi-gwt-ecf-rest-twitter-api.html">this article Scott Lewis</a> go even further and showcase a Twitter user status service with GWT, OSGi and Amazon Web services:</p>
<blockquote><p>
  Using several technologies, I&#8217;ve recently created a Twitter user status service&#8230;i.e. a web service that retrieves the latest user status for a given user.
</p></blockquote>
<p>Read <a href="http://eclipseecf.blogspot.com/2009/12/cloud-osgi-gwt-ecf-rest-twitter-api.html">the complete article here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.osgilook.com/2009/12/10/gwt-and-osgi-in-the-cloud/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OSGi HTTP Service: Registering Servlets on-the-fly</title>
		<link>http://www.osgilook.com/2009/09/08/osgi-http-service-registering-servlets-on-the-fly/</link>
		<comments>http://www.osgilook.com/2009/09/08/osgi-http-service-registering-servlets-on-the-fly/#comments</comments>
		<pubDate>Tue, 08 Sep 2009 08:00:05 +0000</pubDate>
		<dc:creator>fdiotalevi</dc:creator>
				<category><![CDATA[osgi]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[ferlix]]></category>
		<category><![CDATA[http service]]></category>

		<guid isPermaLink="false">http://www.osgilook.com/?p=568</guid>
		<description><![CDATA[There&#8217;s a lot of talk lately about Web application development in OSGi, and there&#8217;s even an ongoing standardization effort (RFC 66) trying to define an OSGi web application model in the upcoming R4.2 release.
However, it is worth noting that the OSGi HTTP Service is one of the oldest compendium services; and that, while simplistic and [...]]]></description>
			<content:encoded><![CDATA[<p>There&#8217;s a lot of talk lately about Web application development in OSGi, and there&#8217;s even an <a href="http://blog.springsource.com/2009/05/27/introduction-to-the-osgi-web-container/">ongoing standardization effort (RFC 66)</a> trying to define an OSGi web application model in the upcoming R4.2 release.<br />
However, it is worth noting that the OSGi HTTP Service is one of the oldest compendium services; and that, while simplistic and limited, there are many applications using it (we already mentioned the <a href="http://www.osgilook.com/2009/07/31/monitor-your-osgi-container-with-the-apache-felix-web-console/">Apache Felix Web Console</a>).</p>
<p>The OSGi HTTP Service provides a simple OSGi service to deploy servlets and resources at runtime; in this article I&#8217;ll focus on the first part, implementing and deploying a simple Servlet.<span id="more-568"></span></p>
<p>First of all, you will need an OSGi HTTP Service implementation. As usual, <a href="http://felix.apache.org">Apache Felix</a> provides a framework-independent bundle; so, without further ado, you can <a href="http://apache.prosite.de/felix/org.apache.felix.http.jetty-1.0.1.jar">download it and install it in your OSGi container</a>, or simply type</p>
<pre class="brush: bash;">
$ pax-run.sh http://www.osgilook.com/static/samples/osgi-http-service.txt
</pre>
<p>(By the way: have a look at our <a href="http://www.osgilook.com/osgi-demos/">OSGi Demos</a> for other easy, pre-cooked, demos)</p>
<p>Let&#8217;s now develop a simple Servlet. You don&#8217;t need to make it OSGi dependent in any way, so the usual Hello World Servlet would work:</p>
<pre class="brush: java;">
public class DateServlet extends HttpServlet
{
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
	{
           resp.getWriter().write(&quot;Hi, today is &quot;+ new Date());
	}
}
</pre>
<p>Easy. Now let&#8217;s write the usual deployment descript&#8230; no way! We want to deploy it on the fly, and without any boring XML descriptor!<br />
What we need is to get access to the OSGi <b>HttpService</b>, and declare the new servlet. We can do that, as usual, in the bundle activator.</p>
<pre class="brush: java;">
public class Activator implements BundleActivator
{
   public void start(BundleContext context) throws Exception
   {
      ServiceReference sRef = context.getServiceReference(HttpService.class.getName());
      if (sRef != null)
      {
         HttpService service = (HttpService) context.getService(sRef);
         service.registerServlet(&quot;/date&quot;, new DateServlet(), null, null);
      }
   }

   public void stop(BundleContext context) throws Exception
   {
      ServiceReference sRef = context.getServiceReference(HttpService.class.getName());
      if (sRef != null)
      {
         HttpService service = (HttpService) context.getService(sRef);
         service.unregister(&quot;/date&quot;);
      }
   }
}
</pre>
<p>Now package your bundle (don&#8217;t forget to specify the <em>Bundle-Activator</em>) and deploy it in the running OSGi container. If everything works fine, you&#8217;ll be able to reach your servlet at <a href="http://localhost:8080/date">http://localhost:8080/date</a>.</p>
<p>There are a few things the OSGi HTTP Service can also do, like registering resources. I&#8217;ll talk about that in the next blog post. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.osgilook.com/2009/09/08/osgi-http-service-registering-servlets-on-the-fly/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Use your build directory as a bundle with Apache Felix</title>
		<link>http://www.osgilook.com/2009/09/07/use-your-build-directory-as-a-bundle-with-apache-felix/</link>
		<comments>http://www.osgilook.com/2009/09/07/use-your-build-directory-as-a-bundle-with-apache-felix/#comments</comments>
		<pubDate>Mon, 07 Sep 2009 12:39:33 +0000</pubDate>
		<dc:creator>fdiotalevi</dc:creator>
				<category><![CDATA[osgi]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[pax]]></category>

		<guid isPermaLink="false">http://www.osgilook.com/?p=564</guid>
		<description><![CDATA[Alin Dreghiciu has posted an interesting and easy tutorial to use a directory as a bundle; that&#8217;s of course very useful when developing new bundles. Alin used Pax-URL to do this little trick.
You can find more details on his &#8220;Pax My Framework&#8221; blog.
]]></description>
			<content:encoded><![CDATA[<p><a href="http://adreghiciu.wordpress.com">Alin Dreghiciu</a> has posted an <a href="http://adreghiciu.wordpress.com/2009/09/06/install-your-directory-as-a-bundle-in-apache-felix/">interesting and easy tutorial</a> to use a directory as a bundle; that&#8217;s of course very useful when developing new bundles. Alin used <a href="http://wiki.ops4j.org/display/paxurl/Download">Pax-URL</a> to do this little trick.</p>
<p>You can find <a href="http://wiki.ops4j.org/display/paxurl/Download">more details on his &#8220;Pax My Framework&#8221; blog</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.osgilook.com/2009/09/07/use-your-build-directory-as-a-bundle-with-apache-felix/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Test driving the Knopflerfish HTTP Console</title>
		<link>http://www.osgilook.com/2009/08/27/test-driving-the-knopflerfish-http-console/</link>
		<comments>http://www.osgilook.com/2009/08/27/test-driving-the-knopflerfish-http-console/#comments</comments>
		<pubDate>Thu, 27 Aug 2009 08:00:45 +0000</pubDate>
		<dc:creator>fdiotalevi</dc:creator>
				<category><![CDATA[osgi]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[console]]></category>
		<category><![CDATA[http]]></category>
		<category><![CDATA[knopflerfish]]></category>

		<guid isPermaLink="false">http://www.osgilook.com/?p=529</guid>
		<description><![CDATA[Some weeks ago in this blog we saw how to install the Apache Felix Web Console to manage your OSGi framework.
The Felix Web Console is a quite complex and customizable tool, but if you are more looking for a very lightweight alternative, you may want to have a look at the Knopflerfish HTTP Console.

Let&#8217;s take [...]]]></description>
			<content:encoded><![CDATA[<p>Some weeks ago in this blog we saw how to install the <a href="http://www.osgilook.com/2009/07/31/monitor-your-osgi-container-with-the-apache-felix-web-console/">Apache Felix Web Console</a> to manage your OSGi framework.<br />
The Felix Web Console is a quite complex and customizable tool, but if you are more looking for a very lightweight alternative, you may want to have a look at the Knopflerfish HTTP Console.</p>
<p><a href="http://www.osgilook.com/wp-content/uploads/2009/08/Picture-11.png"><img src="http://www.osgilook.com/wp-content/uploads/2009/08/Picture-11.png" alt="knopflerfish http console" title="knopflerfish http console" width="562" height="380" class="aligncenter size-full wp-image-530" /></a></p>
<p>Let&#8217;s take it for a test drive.<span id="more-529"></span></p>
<p>First of all, to install the Knopflerfish HTTP Console you will need:</p>
<ul>
<li>the OSGi Compendium Bundle: <a href="http://repository.ops4j.org/maven2/org/osgi/org.osgi.compendium/4.1.0/org.osgi.compendium-4.1.0.jar">http://repository.ops4j.org/maven2/org/osgi/org.osgi.compendium/4.1.0/org.osgi.compendium-4.1.0.jar</a></li>
<li>an OSGi HTTP Service Implementation: <a href="http://apache.prosite.de/felix/org.apache.felix.http.jetty-1.0.1.jar">http://apache.prosite.de/felix/org.apache.felix.http.jetty-1.0.1.jar</a></li>
<li>and of course the Knopflerfish HTTP Console jar: <a href="http://www.knopflerfish.org/repo/jars/httpconsole/httpconsole-2.0.1.jar">http://www.knopflerfish.org/repo/jars/httpconsole/httpconsole-2.0.1.jar</a></li>
</ul>
<p>The other important thing you need is to set the <b>org.osgi.service.http.port</b> property value; in fact, by default, the Http Service will try to start at port on port 80, causing an exception of Unix systems.</p>
<p>Feeling lazy (every developer is lazy..)? I&#8217;ve prepared a <a href="http://www.osgilook.com/2009/07/28/starting-with-osgi-try-pax-runner/">Pax-Runner</a> <a href="http://osgilook.com/static/samples/kf-http-console.txt">file</a> for you. Assuming you have Pax Runner installed, just type</p>
<pre class="brush: bash;">
$ pax-run.sh http://osgilook.com/static/samples/kf-http-console.txt
</pre>
<p>and you are ready to rock!</p>
<p>Now opening your browser at <a href="http://localhost:8080/servlet/console">http://localhost:8080/servlet/console</a> you have access to the Knopflerfish console in all its glory.</p>
<p>The functionalities offered by this tool are pretty basic. There&#8217;s the Bundle View, where you can see its headers and services exposed:<br />
<a href="http://www.osgilook.com/wp-content/uploads/2009/08/Picture-12.png"><img src="http://www.osgilook.com/wp-content/uploads/2009/08/Picture-12.png" alt="kf-bundle" title="kf-bundle" width="636" height="561" class="aligncenter size-full wp-image-538" /></a><br />
<br/></p>
<p>It is possible to select a single service to display all its properties:<br />
<br/><br />
<a href="http://www.osgilook.com/wp-content/uploads/2009/08/Picture-3.png"><img src="http://www.osgilook.com/wp-content/uploads/2009/08/Picture-3.png" alt="Picture 3" title="Picture 3" width="590" height="417" class="aligncenter size-full wp-image-539" /></a></p>
<p>And it&#8217;s of course possible to install a bundle directly from the web interface:<br />
<br/></p>
<p><a href="http://www.osgilook.com/wp-content/uploads/2009/08/Picture-2.png"><img src="http://www.osgilook.com/wp-content/uploads/2009/08/Picture-2.png" alt="kf-install" title="kf-install" width="593" height="330" class="aligncenter size-full wp-image-540" /></a><br />
<br/></p>
<p>In summary, the functionalities offered are just basic compared to the Apache Felix Web Console; however, being the user interface so simple (and usable also with small screens), it&#8217;s quite ideal if you want to check the status of your OSGi framework deployed on a mobile device.<br />
Want to know more? </p>
<pre class="brush: bash;">
$ pax-run.sh http://osgilook.com/static/samples/kf-http-console.txt
</pre>
<p>Cannot be simpler than that!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.osgilook.com/2009/08/27/test-driving-the-knopflerfish-http-console/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>OSGi Preferences Service by Example</title>
		<link>http://www.osgilook.com/2009/08/24/osgi-preferences-service-by-example/</link>
		<comments>http://www.osgilook.com/2009/08/24/osgi-preferences-service-by-example/#comments</comments>
		<pubDate>Mon, 24 Aug 2009 08:00:34 +0000</pubDate>
		<dc:creator>fdiotalevi</dc:creator>
				<category><![CDATA[osgi]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[preferences]]></category>
		<category><![CDATA[settings]]></category>
		<category><![CDATA[specification]]></category>

		<guid isPermaLink="false">http://www.osgilook.com/?p=508</guid>
		<description><![CDATA[A common question asked by new Java developers is what&#8217;s the best solution to store user-specific or application settings. Of course, it is always possible to designate a particular folder (for instance /etc/myapp) in the filesystem to that use, but that often represents a limit for the application portability (what happens if it doesn&#8217;t run [...]]]></description>
			<content:encoded><![CDATA[<p>A common question asked by new Java developers is what&#8217;s the best solution to store user-specific or application settings. Of course, it is always possible to designate a particular folder (for instance <em>/etc/myapp</em>) in the filesystem to that use, but that often represents a limit for the application portability (what happens if it doesn&#8217;t run on Windows?). That&#8217;s the reason the Java Preference API was designed.</p>
<p>OSGi of course is not immune to that problem; an OSGi bundle may run in any device supporting a R4 OSGi container, and therefore needs a well defined and portable mechanism to store application and user settings. That&#8217;s the business of the OSGi Preferences Service.</p>
<p>In this article I&#8217;m going to show how you can use the Preferences Service in your OSGi applications.<span id="more-508"></span></p>
<p>First of all, you need an implementation of the OSGi Preferences Service. Apache Felix provides, as usual, a portable implementation that you can download and use in any R4 container: you can <a href="http://apache.linux-mirror.org/felix/org.apache.felix.prefs-1.0.2.jar">download the jar here</a> and <a href="http://felix.apache.org/site/apache-felix-preferences-service.html">check the documentation here</a>.</p>
<p>After you have downloaded and installed the bundle in your OSGi container, accessing to the Preferences Service is as simple as using any other service in OSGi:</p>
<pre class="brush: java;">
ServiceReference serviceref = context.getServiceReference(PreferencesService.class.getName());
if (serviceref != null)
{
   PreferencesService preferences = (PreferencesService) context.getService(serviceref);
   //store and retrieve your preferences here
}
</pre>
<p>Preferences are organized in a tree structure, so you can define quite complex preference models; the only limitation is give by the fact that you can store on &#8220;simple&#8221; values (boolan, double, float, int, long and strings) and not any type of Java object.</p>
<p><a href="http://www.osgilook.com/wp-content/uploads/2009/08/preferences.png"><img src="http://www.osgilook.com/wp-content/uploads/2009/08/preferences.png" alt="preferences" title="preferences" width="540" height="216" class="aligncenter size-medium wp-image-513" /></a></p>
<p>As mentioned before, the Preferences Service can be used to store application and user settings. To store application settings, you will place your settings under the <b>system root</b>.<br />
Let&#8217;s see in the following example how an application can store the information gathered during the installation:</p>
<pre class="brush: java;">
ServiceReference serviceref = context.getServiceReference(PreferencesService.class.getName());
if (serviceref != null)
{
   PreferencesService preferences = (PreferencesService) context.getService(serviceref);	

   //create a node 'installation' under the system root
   Preferences installationPreferences = preferences.getSystemPreferences().node(&quot;installation&quot;);
   installationPreferences.put(&quot;path&quot;, &quot;/opt/myapp&quot;);   //path chosen by the user
   installationPreferences.put(&quot;license-key&quot;, &quot;687-6GH-9JU-35H&quot;);   //license key
   installationPreferences.put(&quot;license-email&quot;, &quot;hacker@hackerz.com&quot;);   //license owner...
}
</pre>
<p>Reading these settings is equally simple (<em>note that every getter method has a second argument that specifies a default property value if the one required is not found</em>):</p>
<pre class="brush: java;">
ServiceReference serviceref = context.getServiceReference(PreferencesService.class.getName());
if (serviceref != null)
{
   PreferencesService preferences = (PreferencesService) context.getService(serviceref);	

   //retrieve the  'installation' node under the system root
   Preferences installationPreferences = preferences.getSystemPreferences().node(&quot;installation&quot;);
   String key = installationPreferences.get(&quot;license-key&quot;, null);   //get the license key
   String ownder = installationPreferences.get(&quot;license-email&quot;, null);   //get the license owner
}
</pre>
<p>Using the same API you can store and read user settings. Instead of accessing the <b>System Root</b> just access the <b>User Root</b> writing:</p>
<pre class="brush: java;">
ServiceReference serviceref = context.getServiceReference(PreferencesService.class.getName());
if (serviceref != null)
{
   PreferencesService preferences = (PreferencesService) context.getService(serviceref);	

   //retrieve the  'installation' node under the system root
   Preferences installationPreferences = preferences.getUserPreferences(&quot;John&quot;);
}
</pre>
<p><em><b>Need more OSGi articles and tutorial? Check the <a href="http://www.osgilook.com/osgi-recipes/">OSGi Recipes</a> section</b></em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.osgilook.com/2009/08/24/osgi-preferences-service-by-example/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Apache Felix File Install part 2: Dynamic Configurations</title>
		<link>http://www.osgilook.com/2009/08/20/apache-felix-file-install-part-2-dynamic-configurations/</link>
		<comments>http://www.osgilook.com/2009/08/20/apache-felix-file-install-part-2-dynamic-configurations/#comments</comments>
		<pubDate>Thu, 20 Aug 2009 20:45:18 +0000</pubDate>
		<dc:creator>fdiotalevi</dc:creator>
				<category><![CDATA[osgi]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[apache felix file install]]></category>
		<category><![CDATA[configuration admin]]></category>
		<category><![CDATA[fileinstall]]></category>

		<guid isPermaLink="false">http://www.osgilook.com/?p=487</guid>
		<description><![CDATA[This article refers to the OSGi Configuration Admin Service. Look at the Configuration Admin Page for more informations.
In the previous article this week I described a simple project structure using the Apache Felix File Install bundle to allow hot deployment of new bundles.
Another interesting feature of the File Install bundle is its ability to load [...]]]></description>
			<content:encoded><![CDATA[<p><em><strong>This article refers to the OSGi Configuration Admin Service. Look at the <a href="http://www.osgilook.com/osgi-configuration-admin-service/">Configuration Admin Page</a> for more informations.</strong></em></p>
<p>In the <a href="http://www.osgilook.com/2009/08/17/manage-your-osgi-application-with-apache-felix-fileinstall/">previous article</a> this week I described a simple project structure using the <a href="http://www.osgilook.com/apache-felix-file-install/">Apache Felix File Install</a> bundle to allow hot deployment of new bundles.<br />
Another interesting feature of the File Install bundle is its ability to load property files and send them to the OSGi <a href="http://www.osgilook.com/osgi-configuration-admin-service/">ConfigurationAdmin service</a>; that&#8217;s very useful if you want to be able to configure your applications just creating/deleting and updating properties file at runtime. In this post I&#8217;ll enhance the project presented in the previous article to include this new functionality.<br />
<span id="more-487"></span><br />
The new project structure we want to build is represented in the picture.</p>
<p><img src="http://www.osgilook.com/wp-content/uploads/2009/08/felix-fi2.png"/></p>
<p>The difference here is the additional <strong>config/application</strong> folder, that will be monitored by another instance of File Install; we will be able to create there new property files whose contents will be passed to the OSGi Configuration Admin Service.</p>
<p>First of all, we need an implementation of the OSGi Configuration admin service. We could download and store it in the <em>bundle</em> folder, and than add its path in the felix.auto.start property in the <em>config.properties</em> like we did in the previous article; but it much easier just to download it in the <em>dropins</em> folder&#8230; that&#8217;s why we created it!</p>
<pre class="brush: bash;">
$ cd dropins
$ wget http://apache.mirroring.de/felix/org.apache.felix.configadmin-1.0.10.jar
</pre>
<p>Now that the Configuration Admin bundle is in the <em>dropins</em> folder, we know that it will be automatically installed when we start up Felix.</p>
<p>To create another instance of File Install we will use&#8230; File Install. Just create a file called <strong>org.apache.felix.fileinstall-config.cfg</strong> in the <em>dropins</em> folder containing a single property:</p>
<pre class="brush: bash;">
felix.fileinstall.dir=config/application
</pre>
<p>Now start Felix</p>
<pre class="brush: bash;">
Welcome to Felix.
=================

DEBUG: WIRE: 1.0 -&gt; org.osgi.service.startlevel -&gt; 0
DEBUG: WIRE: 1.0 -&gt; org.osgi.framework -&gt; 0
DEBUG: WIRE: 1.0 -&gt; org.osgi.service.packageadmin -&gt; 0
DEBUG: WIRE: 2.0 -&gt; org.apache.felix.shell -&gt; 1.0
DEBUG: WIRE: 2.0 -&gt; org.osgi.framework -&gt; 0
-&gt; DEBUG: WIRE: 3.0 -&gt; org.osgi.util.tracker -&gt; 0
DEBUG: WIRE: 3.0 -&gt; org.osgi.framework -&gt; 0
DEBUG: WIRE: 3.0 -&gt; org.osgi.service.packageadmin -&gt; 0
felix.fileinstall.poll  (ms)   2000
felix.fileinstall.dir            /opt/myprojects/felix-1.8.0/dropins
felix.fileinstall.debug          -1
felix.fileinstall.bundles.new.start          true
Installed /opt/myprojects/felix-1.8.0/dropins/org.apache.felix.configadmin-1.0.10.jar
DEBUG: WIRE: 4.0 -&gt; org.osgi.framework -&gt; 0
DEBUG: WIRE: 4.0 -&gt; org.osgi.service.cm -&gt; 3.0
Started bundle: /opt/myprojects/felix-1.8.0/dropins/org.apache.felix.configadmin-1.0.10.jar
felix.fileinstall.poll  (ms)   2000
felix.fileinstall.dir            /opt/myprojects/felix-1.8.0/config/application
felix.fileinstall.debug          -1
felix.fileinstall.bundles.new.start          true
</pre>
<p>and we&#8217;re done! The log<br />
<strong>felix.fileinstall.dir            /opt/myprojects/felix-1.8.0/config/application</strong><br />
confirms that another instance of File Install is watching <em>config/application</em></p>
<p>All happened too fast? Let&#8217;s summarize.</p>
<p>File Install looks for two types of files: <strong>.jar</strong> and <strong>.cfg</strong>. When it finds a jar file, tries to install it as a bundle in the OSGi container; when it finds a cfg files, it reads its content, and </p>
<ul>
<li>if the file name is something like <strong>[service-name]-[service-pid].cfg</strong>, it uses the ConfiguratioAdmin service to send the configuration to the ManagedServiceFactory whose <em>service.pid</em> is [service-name]</li>
<li>if the file name does not contain a &#8211; (dash),  it sends the configuration to the ManagedService whose <em>service.pid</em> is equal to the file name (without the .cfg extension)</li>
</ul>
<p>So the trick here is that File Install is started by a ManagedServiceFactory with <em>service.pid</em> equal to <strong>org.apache.felix.fileinstall</strong>. So when File Install finds the file <em>org.apache.felix.fileinstall-config.cfg</em> in the <em>dropins</em> folder, it reads the contents and send it to its own ManagedServiceFactory that creates another instance of File Install watching the <em>config/applications</em> folder.</p>
<p>Now you are ready to experiment with this new project structure. I&#8217;ll leave you with some ideas to try out:</p>
<p>* Read this <a href="http://www.osgilook.com/2009/08/10/a-command-line-client-for-the-configuration-admin-service/">article explaining how to configure the Apache Felix HTTP service with the Configuration Admin Service</a>; after that, download Felix HTTP servlet in the <em>dropins</em> folder and configure the HTTP port creating a file named <em>org.apache.felix.http</em> containing the property <em>org.osgi.service.http.port</em></p>
<p>* Also the <a href="http://www.osgilook.com/2009/07/31/monitor-your-osgi-container-with-the-apache-felix-web-console/">Felix Web Console</a> exposes a ManagedService under the service.pid <em>org.apache.felix.webconsole.internal.servlet.OsgiManager</em>. Look in the <a href="http://felix.apache.org/site/apache-felix-web-console.html#ApacheFelixWebConsole-Configuration">Web Console documentation</a> to find out the properties to change username and password, and create a configuration file in <em>config/application</em> to change the default hacker-friendly admin/admin credentials!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.osgilook.com/2009/08/20/apache-felix-file-install-part-2-dynamic-configurations/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Manage your OSGi application with Apache Felix File Install</title>
		<link>http://www.osgilook.com/2009/08/17/manage-your-osgi-application-with-apache-felix-fileinstall/</link>
		<comments>http://www.osgilook.com/2009/08/17/manage-your-osgi-application-with-apache-felix-fileinstall/#comments</comments>
		<pubDate>Mon, 17 Aug 2009 12:00:00 +0000</pubDate>
		<dc:creator>fdiotalevi</dc:creator>
				<category><![CDATA[osgi]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[fileinstall]]></category>

		<guid isPermaLink="false">http://www.osgilook.com/?p=472</guid>
		<description><![CDATA[Check also the second article on File Install: Dynamic Configurations
A while ago we introduced in this blog a little interesting bundle called Apache Felix File Install. This bundle has actually gone a long way since then, and now it&#8217;s even part of Sun Microsystem open source application server Glassfish.
The reason this simple bundle is quite [...]]]></description>
			<content:encoded><![CDATA[<p><strong><em>Check also the second article on <a href="http://www.osgilook.com/2009/08/20/apache-felix-file-install-part-2-dynamic-configurations/">File Install: Dynamic Configurations</a></em></strong></p>
<p>A while ago we introduced in this blog a little interesting bundle called <a href="http://www.osgilook.com/2009/04/18/apache-felix-fileinstall/">Apache Felix File Install</a>. This bundle has actually gone a long way since then, and now it&#8217;s even<a href="http://weblogs.java.net/blog/ss141213/archive/2009/05/using_filesyste.html"> part of Sun Microsystem open source application server Glassfish</a>.</p>
<p>The reason this simple bundle is quite interesting to OSGi developers is that it provides a simple mechanism to give your application an extensible and updatable structure. In fact, once installed, this bundle starts watching a specified folder; every time it detects new bundles there, it installs them. Likewise, when a bundle file is updated in the watched folder, the correspondent bundle in the OSGi container is updated.</p>
<p>Let&#8217;s see now how we can structure an OSGi application using the Apache Felix File Install.<br /><span id="more-472"></span><br />What we want to achieve is an application with the following structure:<br />&nbsp;<img style="max-width: 800px;" src="http://www.osgilook.com/wp-content/uploads/2009/08/felix-fi1.png" /></p>
<p>The main difference between the <em>bundles</em> and the <em>dropins</em> folder is that the first contains the fundamentals OSGi bundles of the application, the ones that defines the &#8220;platform&#8221; and that are only exceptionally updated; on the other side the <em>dropins</em> folder contains additional elements, like user-created plugins or application customizations. The application owner can deploy, undeploy and modify bundles in such folder at any time, and the modifications are installed at runtime without the need to restart the OSGi container.</p>
<p>Let&#8217;s create now this project structure with <a href="http://felix.apache.org">Apache Felix</a>. First of all we need the main Felix distribution: we can download it, for example, <a href="http://apache.mirroring.de/felix/felix-1.8.0.zip">following this link</a> (check the <a href="http://felix.apache.org/site/downloads.cgi">download page</a> if it doesn&#8217;t work). Once we have the distribution, simply unzip it and check its folder structure:</p>
<pre class="brush: bash;">
$ ls -la
-rw-r--r--  11358 26 Apr 23:20 LICENSE
-rw-r--r--  1095 26 Apr 23:20 LICENSE.kxml2
-rw-r--r--  932 11 Mag 01:08 NOTICE
drwxr-xr-x  102 26 Apr 23:20 bin
drwxr-xr-x  170 26 Apr 23:20 bundle
drwxr-xr-x  102 26 Apr 23:20 conf
drwxr-xr-x  578 26 Apr 23:20 doc
</pre>
<p>As you can see, it is very close to what we want to achieve. Let&#8217;s now create the <em>dropins</em> folder.</p>
<pre class="brush: bash;">
$  mkdir dropins
</pre>
<p>Now that all the folders are in place, let&#8217;s see the contents of the <em>bundle</em> folder.</p>
<pre class="brush: bash;">
$ cd bundle/
$ ls -al
-rw-r--r-- 146568 26 Apr 23:20 org.apache.felix.bundlerepository-1.4.0.jar
-rw-r--r-- 59114 26 Apr 23:20 org.apache.felix.shell-1.2.0.jar
-rw-r--r-- 12455 26 Apr 23:20 org.apache.felix.shell.tui-1.2.0.jar
</pre>
<p>This folder already contains the basic bundles distributed with Felix; let&#8217;s donwload the Apache File Install Bundle here.</p>
<pre class="brush: bash;">
$ wget http://www.mirrorservice.org/sites/ftp.apache.org/felix/org.apache.felix.fileinstall-1.2.0.jar
$ ls -al
-rw-r--r-- 146568 26 Apr 23:20 org.apache.felix.bundlerepository-1.4.0.jar
-rw-r--r-- 59114 26 Apr 23:20 org.apache.felix.shell-1.2.0.jar
-rw-r--r-- 12455 26 Apr 23:20 org.apache.felix.shell.tui-1.2.0.jar
-rw-r--r-- 33138 17 Ago 12:12 org.apache.felix.fileinstall-1.2.0.jar
</pre>
<p>The final step is to configure Felix to start File Install and watch the <em>dropins</em> folder. To do that let&#8217;s open the <em>config/config.properties</em> file.</p>
<p>First of all we need to add the <em>org.apache.felix.fileinstall-1.2.0.jar</em> bundle in the <strong>felix.auto.start</strong> list. That will tell Felix to automatically install and startup the bundle.</p>
<pre class="brush: bash;">
felix.auto.start.1=
 file:bundle/org.apache.felix.shell-1.2.0.jar \
 file:bundle/org.apache.felix.shell.tui-1.2.0.jar \
 file:bundle/org.apache.felix.bundlerepository-1.4.0.jar \
 file:bundle/org.apache.felix.fileinstall-1.2.0.jar
</pre>
<p>The second step is to set the <em>felix.fileinstall.dir</em> property to tell File Install the directory to watch. Simply add the following line at the end of the <em>config/config.properties</em> file.</p>
<pre class="brush: bash;">
felix.fileinstall.dir=dropins
</pre>
<p>That&#8217;s it!</p>
<p>Now go back to the main folder, and launch felix with the usual command:</p>
<pre class="brush: bash;">
$ java -jar bin/felix.jar

Welcome to Felix.
=================
-&gt; felix.fileinstall.poll  (ms)   2000
 felix.fileinstall.dir            /private/tmp/felix-1.8.0/dropins
 felix.fileinstall.debug          -1
 felix.fileinstall.bundles.new.start          true
-&gt;
</pre>
<p>As you can see from the logs, Apache Felix File Install has been started and it is watching the dropins folder. Let&#8217;s try it now simply copying a bundle in the <em>dropins</em> folder.<br />
While Felix is running, open another terminal window and copy a bundle in the <em>dropins</em> folder, for instance:</p>
<pre class="brush: bash;">
$ cd dropins/
$ wget http://www.mirrorservice.org/sites/ftp.apache.org/felix/org.apache.felix.configadmin-1.0.10.jar
</pre>
<p>Going back to the Felix console you will see something like:</p>
<pre class="brush: bash;">
 -&gt; Installed /private/tmp/felix-1.8.0/dropins/org.apache.felix.configadmin-1.0.10.jar
 -&gt; Started bundle: /private/tmp/felix-1.8.0/dropins/org.apache.felix.configadmin-1.0.10.jar
 -&gt;
</pre>
<p>Well done! You can experiment a bit with this simple project; you can update (a simple Unix <em>touch</em> would work) or delete the bundle, and Felix will update or uninstall the bundle in the OSGi container.</p>
<p>Final note: Apache Felix File Install works in every OSGi compliant container; if you are an Equinox user, you can very easily create the same project structure with your favorite OSGi framework.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.osgilook.com/2009/08/17/manage-your-osgi-application-with-apache-felix-fileinstall/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Four articles to get started with OSGi tests</title>
		<link>http://www.osgilook.com/2009/08/12/four-articles-to-get-started-with-osgi-tests/</link>
		<comments>http://www.osgilook.com/2009/08/12/four-articles-to-get-started-with-osgi-tests/#comments</comments>
		<pubDate>Wed, 12 Aug 2009 13:51:03 +0000</pubDate>
		<dc:creator>fdiotalevi</dc:creator>
				<category><![CDATA[osgi]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[junit]]></category>
		<category><![CDATA[test]]></category>
		<category><![CDATA[testng]]></category>

		<guid isPermaLink="false">http://www.osgilook.com/?p=428</guid>
		<description><![CDATA[We haven&#8217;t had many chance to talk about OSGi testing in this website, but that&#8217;s definitely an hot topic, and something we will come back soon with some new tutorials.
In the meantime, here&#8217;s a list of four resources on the Web to kick the tires on OSGi testing:

Putting OSGi to the Test with Pax Exam, [...]]]></description>
			<content:encoded><![CDATA[<p>We haven&#8217;t had many chance to talk about OSGi testing in this website, but that&#8217;s definitely an hot topic, and something we will come back soon with some new tutorials.<br />
In the meantime, here&#8217;s a list of four resources on the Web to kick the tires on OSGi testing:</p>
<ul>
<li><a href="http://java.dzone.com/articles/putting-osgi-test-pax-exam">Putting OSGi to the Test with Pax Exam</a>, introductory tutorial on <a href="http://wiki.ops4j.org/display/paxexam/Pax+Exam;jsessionid=496069F15048381AF7E09ACAE844BFE6">Pax-Exam</a> by <a href="http://www.jroller.com/habuma/">Craig Walls</a></li>
<li><a href="http://java.dzone.com/articles/testing-osgispring-style">Testing OSGi&#8230;Spring Style</a> another Craig Walls article on <a href="http://static.springsource.org/osgi/docs/1.2.0/reference/html/testing.html">Spring-DM&#8217;s testing support</a></li>
<li><a href="https://opensource.luminis.net/wiki/display/OSGITEST/OSGi+testing+framework">Lumins OSGi testing framework</a>, documentation of the open source OSGi testing framework developed by <a href="http://www.luminis.nl">Luminis</a></li>
<li><a href="http://felix.apache.org/site/apache-felix-ipojo-junit4osgi-tutorial.html">junit4osgi quick start</a>, tutorial to get started with Apache Felix Junit4osgi</li>
</ul>
<p>&nbsp;&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.osgilook.com/2009/08/12/four-articles-to-get-started-with-osgi-tests/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A command line client for the Configuration Admin Service</title>
		<link>http://www.osgilook.com/2009/08/10/a-command-line-client-for-the-configuration-admin-service/</link>
		<comments>http://www.osgilook.com/2009/08/10/a-command-line-client-for-the-configuration-admin-service/#comments</comments>
		<pubDate>Mon, 10 Aug 2009 12:39:34 +0000</pubDate>
		<dc:creator>fdiotalevi</dc:creator>
				<category><![CDATA[osgi]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[configuration]]></category>
		<category><![CDATA[configuration admin]]></category>

		<guid isPermaLink="false">http://www.osgilook.com/?p=413</guid>
		<description><![CDATA[You can find some introductory articles on the OSGi Configuration Admin Service here and here
In our introductory articles on the OSGi Configuration Admin Service, we explained how to programmatically access to the OSGi ConfigurationAdmin interface to send configuration dictionaries to bundles installed in your OSGi framework.
Of course that&#8217;s just one possible usage scenario of the [...]]]></description>
			<content:encoded><![CDATA[<p><strong><em>You can find some introductory articles on the OSGi Configuration Admin Service <a href="http://www.osgilook.com/2009/03/22/configuration-admin-service-explained-the-managedservice-interface/">here</a> and <a href="http://www.osgilook.com/2009/08/04/factory-pattern-on-steroids-the-managedservicefactory/">here</a></em></strong></p>
<p>In our introductory articles on the OSGi Configuration Admin Service, we explained how to programmatically access to the OSGi ConfigurationAdmin interface to send configuration dictionaries to bundles installed in your OSGi framework.<br />
Of course that&#8217;s just one possible usage scenario of the Configuration Admin Service. In many cases, however, you want to give your customer (or the deployment team) the opportunity to configure your system directly, and writing some Java code is not the most practical solution. In these cases, there are some tools that make it easy to use the Configuration Admin Service.</p>
<p>The one we are talking about today is an<a href="https://opensource.luminis.net/wiki/display/SITE/OSGi+Configuration+Admin+command+line+client"> handy extension of the Apache Felix (or Equinox) console</a> developed by <a href="http://www.luminis.nl/">Luminis</a>. Let&#8217;s see how we can use it to configure the Apache Felix HTTP service.<span id="more-413"></span></p>
<p>First of all we need to start up Apache Felix. If you have <a href="http://felix.apache.org/site/downloads.cgi">downloaded the main Felix distribution</a>, you need to type</p>
<pre class="brush: bash;">
java -jar bin/felix.jar
</pre>
<p>to start the OSGi container.</p>
<p>If you prefer using Pax-Runner, you&#8217;ll just type</p>
<pre class="brush: bash;">
pax-run.sh
</pre>
<p>In both cases, the usual Apache Felix console will be displayed</p>
<pre class="brush: bash;">
Welcome to Felix.
=================

-&gt;
</pre>
<p>Now you need to install two bundles </p>
<ul>
<li> the <a href="http://felix.apache.org/site/apache-felix-configuration-admin-service.html">Apache Felix Configuration Admin Service</a></li>
<li> the <a href="https://opensource.luminis.net/wiki/display/SITE/OSGi+Configuration+Admin+command+line+client">Lumins OSGi Configuration Admin command line client</a></li>
</ul>
<p>Installing them is straightforward, just type the following commands in the console:</p>
<pre class="brush: bash;">
-&gt; install http://mirrors.dedipower.com/ftp.apache.org/felix/org.apache.felix.configadmin-1.0.10.jar
Bundle ID: 4
-&gt; install https://opensource.luminis.net/wiki/download/attachments/2031635/net.luminis.cmc-0.2.3.jar?version=1&amp;modificationDate=1240778068150
Bundle ID: 5
-&gt; start 4 5
-&gt; ps
START LEVEL 6
   ID   State         Level  Name
[   0] [Active     ] [    0] System Bundle (1.8.1)
[   1] [Active     ] [    1] osgi.compendium (4.1.0.build-200702212030)
[   2] [Active     ] [    1] Apache Felix Shell Service (1.2.0)
[   3] [Active     ] [    1] Apache Felix Shell TUI (1.2.0)
[   4] [Active     ] [    5] Apache Felix Configuration Admin Service (1.0.10)
[   5] [Active     ] [    5] luminis Configuration Admin command line client (0.2.3)
</pre>
<p>With the two additional bundles installed, we have added several new commands to the Apache Felix shell. Let&#8217;s see them typing <strong>cm help</strong></p>
<pre class="brush: bash;">
-&gt; cm help
Usage:
 cm help                  print this help message
 cm list                  list all known configurations
 cm get &lt;pid&gt;             show configuration for service &lt;pid&gt;
 cm getv &lt;pid&gt;            verbose get (shows value types also)
 cm put &lt;pid&gt; key value   set string value for service &lt;pid&gt;
 cm puts &lt;pid&gt; key value  set &quot;simple&quot; value for service &lt;pid&gt;: value is &quot;true&quot;, &quot;false&quot;,
                          a char in single quotes, an int, or a number, with appended:
                          i (Integer), l (Long), f (Float), d (Double), b (Byte), s (Short)
 cm del &lt;pid&gt;             deletes configuration for service &lt;pid&gt;
</pre>
<p>The help is pretty self-explaining, but let&#8217;s proceed with a simple example installing the <a href="http://felix.apache.org/site/apache-felix-http-service.html">Apache Felix HTTP service</a>. This Felix subproject implements the OSGi HTTP Service specification, and embeds a Jetty servlet container. This internal Jetty server can be configured using the OSGi Configuration Admin Service.</p>
<p>Let&#8217;s start by installing the Apache Felix HTTP service.</p>
<pre class="brush: bash;">
-&gt; install http://mirror.lividpenguin.com/pub/apache/felix/org.apache.felix.http.jetty-1.0.1.jar
Bundle ID: 6
</pre>
<p>The web page of this bundle <a href="http://felix.apache.org/site/apache-felix-http-service.html">lists all the configurations that you can set</a>; for instance, you can use the <strong>org.osgi.service.http.port</strong> property to set the HTTP port Jetty is listening to.</p>
<p>To do that, first of all you need to create a configuration instance for the Apache Felix HTTP bundle, set the property and then start the Jetty bundle (in our case it&#8217;s bundle ID 6)</p>
<pre class="brush: bash;">
-&gt; cm create org.apache.felix.http
-&gt; cm put org.apache.felix.http org.osgi.service.http.port 8888
-&gt; start 6
</pre>
<p>If everything is ok, you should see the Jetty bundle starting; now try to connect to http://localhost:8888 and see the nice 404 page! If you see that, you have successfully configured your bundle; the 404 error is normal, since you haven&#8217;t  installed any web application yet.</p>
<p>Of course you can now set additional properties, or even change the one just set. New configurations will be read on the fly, and the Jetty instance updated accordingly.<br />
In every moment, you can see the list of the existing configurations typing <strong>cm list</strong></p>
<pre class="brush: bash;">
-&gt; cm list
Configuration list:
org.apache.felix.http     http://mirror.lividpenguin.com/pub/apache/felix/org.apache.felix.http.jetty-1.0.1.jar
</pre>
<p>or display the list of properties for a given configuration typing <strong>cm get [service pid]</strong></p>
<pre class="brush: bash;">
-&gt; cm get org.apache.felix.http

Configuration for service (pid) &quot;org.apache.felix.http&quot;
(bundle location = http://mirror.lividpenguin.com/pub/apache/felix/org.apache.felix.http.jetty-1.0.1.jar)

key                          value
------                       ------
service.pid                  org.apache.felix.http
org.osgi.service.http.port   8888
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.osgilook.com/2009/08/10/a-command-line-client-for-the-configuration-admin-service/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Easy OSGi provisioning with Pax-Runner provisioning files</title>
		<link>http://www.osgilook.com/2009/08/07/easy-osgi-provisioning-with-pax-runner-provisioning-files/</link>
		<comments>http://www.osgilook.com/2009/08/07/easy-osgi-provisioning-with-pax-runner-provisioning-files/#comments</comments>
		<pubDate>Fri, 07 Aug 2009 11:04:05 +0000</pubDate>
		<dc:creator>fdiotalevi</dc:creator>
				<category><![CDATA[osgi]]></category>
		<category><![CDATA[pax]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[ops4j]]></category>
		<category><![CDATA[pax runner]]></category>
		<category><![CDATA[pax-run]]></category>
		<category><![CDATA[provisioning]]></category>

		<guid isPermaLink="false">http://www.osgilook.com/?p=382</guid>
		<description><![CDATA[


As Craig reminded me in a comment some days ago, the best way to provision non-trivial OSGi applications with Pax Runner is to write a custom profile or a provisioning file.

In this tutorial we will go through all the steps you need to do in order to write your own provisioning file. First of all, [...]]]></description>
			<content:encoded><![CDATA[<table>
<tr>
<td>
As <a href="http://www.jroller.com/habuma/">Craig</a> reminded me in a <a href="http://www.osgilook.com/2009/07/31/monitor-your-osgi-container-with-the-apache-felix-web-console/comment-page-1/#comment-52">comment</a> some days ago, the best way to provision non-trivial OSGi applications with <a href="http://www.osgilook.com/2009/07/28/starting-with-osgi-try-pax-runner/">Pax Runner</a> is to write a custom profile or a provisioning file.<br />
<br/><br />
In this tutorial we will go through all the steps you need to do in order to write your own provisioning file. First of all, why do you need provisioning files?<br />
The main advantage is that the combination of Pax-Runner, <a href="http://paxrunner.ops4j.org/display/paxrunner/Pax+Runner+profiles+list">basic profiles</a> and provisioning files allows to completely automate the deployment of your OSGi-based application. For example, you can deploy your OSGi based web application in your server farm just launching a simple command like</p>
<pre class="brush: java;">
pax-run.sh --profiles=web http://myrepository/web.txt
</pre>
<p>in all the nodes of your cluster.
</td>
<td>
&nbsp;&nbsp;&nbsp;&nbsp;
</td>
<td align="center">
<img src="http://paxrunner.ops4j.org/download/attachments/3833859/pax-runner.png" width="240" height="134"/><br />
<br/><br />
Want to learn more on Pax-Runner?<br />
Read<br />
<a href="http://www.osgilook.com/2009/07/28/starting-with-osgi-try-pax-runner/">Starting with OSGi? Try Pax-Runner!</a>
</td>
</tr>
</table>
<p><span id="more-382"></span><br />
Let&#8217;s start by saying that a provisioning file can be as simple as a list of bundles. Let&#8217;s make a useful example building a provisioning file to install the <a href="http://felix.apache.org/site/apache-felix-application-demonstration.html">Apache Felix Application Demo</a>. These bundles are not available for download in the <a href="http://felix.apache.org">Felix website</a>, so I uploaded a copy of them in the OSGi Look server.<br />
Now just open any text file and type:</p>
<pre class="brush: plain;">
http://www.osgilook.com/static/samples/servicebased.circle-1.0.0.jar
http://www.osgilook.com/static/samples/servicebased.host-1.0.0.jar
http://www.osgilook.com/static/samples/servicebased.square-1.0.0.jar
http://www.osgilook.com/static/samples/servicebased.trapezoid-1.0.0.jar
http://www.osgilook.com/static/samples/servicebased.triangle-1.0.0.jar
</pre>
<p>Save the file as felix-demo.txt.</p>
<p>Now go back to your console, and type <b>pax-run.sh file:///path/to/felix-demo.txt</b>.</p>
<pre class="brush: bash;">
pax-run.sh file:////tmp/demo.txt
    ______  ________  __  __
   / __  / /  __   / / / / /
  /  ___/ /  __   / _\ \ _/
 /  /    /  / /  / / _\ \
/__/    /__/ /__/ /_/ /_/

Pax Runner (1.1.1) from OPS4J - http://www.ops4j.org
----------------------------------------------------

 -&gt; Using config [classpath:META-INF/runner.properties]
 -&gt; Using only arguments from command line
 -&gt; Scan bundles from [file:////tmp/demo.txt]
 -&gt; Scan bundles from [scan-file:file:////tmp/demo.txt]
 -&gt; Provision bundle [http://www.osgilook.com/static/samples/servicebased.circle-1.0.0.jar, at default start level, bundle will be started, bundle will be loaded from the cache]
 -&gt; Provision bundle [http://www.osgilook.com/static/samples/servicebased.host-1.0.0.jar, at default start level, bundle will be started, bundle will be loaded from the cache]
 -&gt; Provision bundle [http://www.osgilook.com/static/samples/servicebased.square-1.0.0.jar, at default start level, bundle will be started, bundle will be loaded from the cache]
 -&gt; Provision bundle [http://www.osgilook.com/static/samples/servicebased.trapezoid-1.0.0.jar, at default start level, bundle will be started, bundle will be loaded from the cache]
 -&gt; Provision bundle [http://www.osgilook.com/static/samples/servicebased.triangle-1.0.0.jar, at default start level, bundle will be started, bundle will be loaded from the cache]
 -&gt; Preparing framework [Felix 1.8.1]
 -&gt; Downloading bundles...
 -&gt; http://www.osgilook.com/static/samples/servicebased.circle-1.0.0.jar : 12051 bytes @ [ 45kBps ]
 -&gt; http://www.osgilook.com/static/samples/servicebased.host-1.0.0.jar : 386419 bytes @ [ 51kBps ]
 -&gt; http://www.osgilook.com/static/samples/servicebased.square-1.0.0.jar : 10705 bytes @ [ 40kBps ]
 -&gt; http://www.osgilook.com/static/samples/servicebased.trapezoid-1.0.0.jar : 12018 bytes @ [ 89kBps ]
 -&gt; http://www.osgilook.com/static/samples/servicebased.triangle-1.0.0.jar : 11993 bytes @ [ 65kBps ]
 -&gt; Using execution environment [J2SE-1.6]
 -&gt; Runner has successfully finished his job!

Welcome to Felix.
=================
-&gt;
</pre>
<p>The logs show that all the bundles listed in the provisioning file are installed and started in your Felix container. And after a few seconds, you will be able to play with the Apache Felix Demo application!</p>
<p><img src="http://www.osgilook.com/wp-content/uploads/2009/08/Picture-1.png" alt="felix-demo" title="felix-demo" width="495" height="457" class="alignnone size-full wp-image-399" /></p>
<h2>Provisioning from a URL</h2>
<p>If you want to use your provisioning file to startup multiple instances of an application, the best thing you can do is to upload it in a HTTP server. For instance, you can find the provisioning file we have just written at <a href="http://www.osgilook.com/static/samples/felix-demo.txt">http://www.osgilook.com/static/samples/felix-demo.txt</a>.</p>
<p>You can try now to type <b>pax-run.sh http://www.osgilook.com/static/samples/felix-demo.txt</b>: as a result, you will create a Felix container and automatically download all the bundles defined at that URL.</p>
<h2>Advanced features</h2>
<p>Pax-Runner provides many advanced features; you can for instance set start levels, use different protocols (Maven) and set system properties. Please refer to the <a href="http://paxrunner.ops4j.org/display/paxrunner/Provision+bundles+from+a+text+file">documentation for a complete overview</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.osgilook.com/2009/08/07/easy-osgi-provisioning-with-pax-runner-provisioning-files/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
