<?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>Luminis Software Development &#187; OSGi</title>
	<atom:link href="http://lsd.luminis.nl/tag/osgi/feed/" rel="self" type="application/rss+xml" />
	<link>http://lsd.luminis.nl</link>
	<description></description>
	<lastBuildDate>Mon, 19 Jul 2010 06:45:31 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>nl</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>FitNesse and OSGi</title>
		<link>http://lsd.luminis.nl/fitnesse-and-osgi/</link>
		<comments>http://lsd.luminis.nl/fitnesse-and-osgi/#comments</comments>
		<pubDate>Tue, 25 May 2010 19:59:38 +0000</pubDate>
		<dc:creator>Angelo van der Sijpt</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[technical]]></category>
		<category><![CDATA[acceptance testing]]></category>
		<category><![CDATA[fitnesse]]></category>
		<category><![CDATA[modularity]]></category>
		<category><![CDATA[OSGi]]></category>

		<guid isPermaLink="false">http://lsd.luminis.nl/?p=901</guid>
		<description><![CDATA[Recently, I built a demonstrator project connecting FitNesse and OSGi. We show how that can help your project, and how we did it.]]></description>
			<content:encoded><![CDATA[<p>As a demonstrator for a customer, I recently built a set of fixtures that allow <a href="http://www.fitnesse.org">FitNesse</a> acceptance tests to talk to an OSGi framework. <strong>This code is by no means production quality, but merely intended to show the concept and explain the challenges.</strong></p>
<p>I will not explain the details of the acceptance tests here, however, if there&#8217;s one point I would like to get across, it&#8217;s <em>your fixtures should be as narrow as possible</em> to easily accommodate for implementation changes. Study the different <code>UserAdmin</code> fixtures for more details. Also, I assume some familiarity with OSGi.</p>
<h2>FitNesse and OSGi. Why?</h2>
<p>Of course its fun, there is some real benefit to be gained here. While the industry well understands the need for unit- and integration testing, also in a modular context, it becomes more complex to create the necessary link between business and code. Yes, using a modular architecture we can behave in a more agile fashion, but all that agility is no good if the business doesn&#8217;t hop on the train, and explain well what it needs. FitNesse allows the business to explain its goals in business-lingo, while forcing the specification to be precise enough to be executable: if a concept cannot be explained by simple scenarios, something is wrong, but that&#8217;s a different story.</p>
<p>The modular nature of OSGi means that behavior of an application is more emergent than deterministic, making it harder to reason about its correctness: we can prove that our code and bundles are correct (unit tests), that everything works together as it should (integration tests), and that it looks right (user interface tests). However, proving that the business rules (which may well be one of those emergent properties) are handled correctly in a given setting, is another can of worms: we need to connect our acceptance tests to the OSGi framework.</p>
<h2>The big picture</h2>
<p><a href="http://lsd.luminis.nl/wp-content/uploads/2010/05/Screen-shot-2010-05-25-at-9.27.41-PM.png"><img src="http://lsd.luminis.nl/wp-content/uploads/2010/05/Screen-shot-2010-05-25-at-9.27.41-PM-300x146.png" alt="FitNesse and OSGi - overview" title="FitNesse and OSGi - overview" width="300" height="146" class="alignnone size-medium wp-image-903" /></a></p>
<p>The solution presented below uses a special &#8216;fixtures&#8217; bundle, which can be deployed along side other bundles in your framework. This bundles exposes an interface (in our case, through an <code>HTTPServlet</code>), which is used by a set of connectors, which in turn are used by FitNesse.</p>
<h2>The details</h2>
<p><a href="http://lsd.luminis.nl/wp-content/uploads/2010/05/2010_05_25_21_38_03.png"><img src="http://lsd.luminis.nl/wp-content/uploads/2010/05/2010_05_25_21_38_03-300x212.png" alt="FitNesse and OSGi - detailed" title="FitNesse and OSGi - detailed" width="300" height="212" class="alignnone size-medium wp-image-905" /></a></p>
<p>The ingredients are two parts connector code, one part boiler plate, and one part genuine OSGi-aware fixtures.</p>
<h3>The connectors</h3>
<p>Starting at the level closest to FitNesse, we find a set of fixtures that FitNesse can use. For us, these contain merely boiler plate code.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> removeUser<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> name<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">Exception</span> <span style="color: #009900;">&#123;</span>
    doRemoteCall<span style="color: #009900;">&#40;</span>buildRemoteCall<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;UserAdmin&quot;</span>, name<span style="color: #009900;">&#41;</span>, <span style="color: #003399;">Void</span>.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>This code instructs our <code>RemoteInvoker</code> to do some call to the outside world. For more details, see <code>RemoteInvoker.java</code> in the <code>UserAdminRemoteFixtures</code> project.</p>
<h3>The fixture bundle</h3>
<p>Moving one step closer to our service, and into the OSGi framework, we find a <code>FixtureServlet</code>, whose task it is to receive calls from the <code>RemoteInvoker</code>, and turn them into actual method calls on the fixtures.</p>
<p>The fixtures, then, are almost regular OSGi aware objects. I chose to use the <a href="http://felix.apache.org/site/apache-felix-dependency-manager.html">Apache Felix Dependency Manager</a> for the dependency management of the fixtures. So, for our UserAdmin fixture, the dependencies are</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">manager.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>createService<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    .<span style="color: #006633;">setInterface</span><span style="color: #009900;">&#40;</span>UserAdminListener.<span style="color: #000000; font-weight: bold;">class</span>.<span style="color: #006633;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span>
    .<span style="color: #006633;">setImplementation</span><span style="color: #009900;">&#40;</span>userAdmin<span style="color: #009900;">&#41;</span>
    .<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>createServiceDependency<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
        .<span style="color: #006633;">setService</span><span style="color: #009900;">&#40;</span>UserAdmin.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span>
        .<span style="color: #006633;">setRequired</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Here, we state that we have some instance of a fixture <code>userAdmin</code> that registers itself as a <code>UserAdminListener</code> and needs a <code>UserAdmin</code>. How straightforward is that?
</p>
<p>The final step takes us to the actual fixture,</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> UserAdminFixture <span style="color: #000000; font-weight: bold;">implements</span> UserAdminListener <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">volatile</span> UserAdmin m_userAdmin<span style="color: #339933;">;</span>
...
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> addUser<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> name<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		m_usersCreatedInLastCall <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
		m_userAdmin.<span style="color: #006633;">createRole</span><span style="color: #009900;">&#40;</span>name, Role.<span style="color: #006633;">USER</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
...
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>which is just another component using a the <code>UserAdmin</code> service.
</p>
<h2>Putting it all together</h2>
<p>All we now need to do is deploy the fixture bundle in our project, and instruct FitNesse to use the remote connector. The zip file at the bottom of this post contains two shell scripts to do exactly that.</p>
<h2>Future work</h2>
<p>As I stated at the top of this story, this is by no means production quality code, but the concepts stand as they are. Given the way FitNesse works, the connectors do not need much extra work, perhaps support for collections. However, we could use</p>
<ul>
<li>a way to reduce the boiler plate code,</li>
<li>a way to ensure that that both side of the fixtures use the same function naming, and</li>
<li>better integration, for instance by only firing up a framework once a FitNesse suite is started.</li>
</ul>
<h2>Let&#8217;s play with it!</h2>
<p>I have built a <a href='http://lsd.luminis.nl/wp-content/uploads/2010/05/FitnesseAndOSGi.zip'>zip file</a> containing everything you need to get started, including a set of scenarios that can run with both a homebrew implementation of a User Admin, and the actual <a href="http://felix.apache.org">Apache Felix User Admin</a>. A Readme gives you more information on getting it all up and running.</p>
]]></content:encoded>
			<wfw:commentRss>http://lsd.luminis.nl/fitnesse-and-osgi/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Online video: Beyond OSGi software architecture</title>
		<link>http://lsd.luminis.nl/online-video-beyond-osgi-software-architecture/</link>
		<comments>http://lsd.luminis.nl/online-video-beyond-osgi-software-architecture/#comments</comments>
		<pubDate>Fri, 22 Jan 2010 15:11:53 +0000</pubDate>
		<dc:creator>Richard van der Laan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[agile]]></category>
		<category><![CDATA[Apache Felix]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[lean]]></category>
		<category><![CDATA[nljug]]></category>
		<category><![CDATA[OSGi]]></category>
		<category><![CDATA[Software architecture]]></category>

		<guid isPermaLink="false">http://lsd.luminis.nl/?p=601</guid>
		<description><![CDATA[Op 11 november 2009 gaf Marcel Offermans samen met Jeroen van Grondelle (Be Informed) een duo presentatie over "Beyond OSGi software architecture". De video van deze presentatie is inmiddels online beschikbaar.]]></description>
			<content:encoded><![CDATA[<p>Op 11 november 2009 gaf Marcel Offermans samen met Jeroen van Grondelle (Be Informed) een duo presentatie over &#8220;Beyond OSGi software architecture&#8221;. De video van deze presentatie is inmiddels online beschikbaar. De gehele presentatie van 50 minuten kan je <a href="http://lsd.luminis.nl/wp-content/uploads/videos/Beyond%20OSGi%20software%20architecture.mp4">hier</a> downloaden. Maar de eerste tien minuten zijn hieronder gelijk online te bekijken.</p>
<p><!-- Smart Youtube --><span class="youtube"><object width="560" height="340"><param name="movie" value="http://www.youtube.com/v/vwJD0mhgnmU&amp;rel=1&amp;color1=e1600f&amp;color2=febd01&amp;border=0&amp;fs=1&amp;hl=en&amp;autoplay=0&amp;showinfo=0&amp;iv_load_policy=3&amp;showsearch=0&amp;ap=%2526fmt%3D18" /><param name="allowFullScreen" value="true" /><embed wmode="transparent" src="http://www.youtube.com/v/vwJD0mhgnmU&amp;rel=1&amp;color1=e1600f&amp;color2=febd01&amp;border=0&amp;fs=1&amp;hl=en&amp;autoplay=0&amp;showinfo=0&amp;iv_load_policy=3&amp;showsearch=0&amp;ap=%2526fmt%3D18" type="application/x-shockwave-flash" allowfullscreen="true" width="560" height="340" ></embed><param name="wmode" value="transparent" /></object></span></p>
<p>OSGi is niet meer weg te denken uit het Enterprise Java domein. Dit lightweight framework krijgt al een aantal jaren flinke aandacht en is met name bekend om z’n modulaire applicaties op basis van bundles. Minder bekend is het services model, waarbij applicaties worden ontwikkeld op basis van service interfaces en van elkaar ontkoppelde implementaties (POJO&#8217;s) van die interfaces. Krachtige eigenschappen van dit model zijn:</p>
<ul>
<li>complexiteitsreductie door stricte scheiding van services;</li>
<li>declaratieve services en dependency management (IoC);</li>
<li>aspect oriëntatie op basis van stub services;</li>
<li>security model.</li>
</ul>
<p>Lean software is een nieuwe manier om enterprise applicaties te bouwen op basis van OSGi, die ook goed aansluit bij Agile methoden, waarbij non-functional requirements ingevuld kunnen worden in een compact gebleven framework. In die context kijken we naar:</p>
<ul>
<li>applicaties deployen op allerlei platformen en omgevingen;</li>
<li>applicaties automatisch installeren en updaten;</li>
<li>applicaties voorzien van management interfaces;</li>
<li>product software uitbreidbaar maken middels een SDK;</li>
<li>product software verkopen als combinatie van standaard onderdelen en optionele uitbreidingen;</li>
<li>modulaire User Interfaces.</li>
</ul>
<p>De slides van de presentatie zijn te vinden op de <a href="http://www.nljug.org/pages/events/content/jfall_2009/sessions/00018/">NLJUG website</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://lsd.luminis.nl/online-video-beyond-osgi-software-architecture/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Swing &amp; OSGi &#8212; please play nice!</title>
		<link>http://lsd.luminis.nl/swing-and-osgi/</link>
		<comments>http://lsd.luminis.nl/swing-and-osgi/#comments</comments>
		<pubDate>Wed, 18 Nov 2009 07:00:35 +0000</pubDate>
		<dc:creator>Angelo van der Sijpt</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[OSGi]]></category>
		<category><![CDATA[swing]]></category>

		<guid isPermaLink="false">http://lsd.luminis.nl/?p=421</guid>
		<description><![CDATA[OSGi is dynamic, Swing is static; these properties tend to bite each other. We will show some of the pitfalls you will encounter in a nontrivial OSGi-Swing application, and show how to give up a little bit of flexibility to get around them.]]></description>
			<content:encoded><![CDATA[<p>In a recent <a href="http://java.dzone.com/articles/plugable-swing-%E2%80%93-hello-world" target="_blank">blog</a> by Peter Karich, he showed how to create a pluggable Swing application using OSGi. While this works fine for smaller examples, you might run into more serious issues once you application starts to grow.</p>
<h2>Plugging Swing: it leaks?</h2>
<p>Let&#8217;s start with an application not unlike the one from aforementioned blog; it uses a window as host, and has a pluggable menu, and a pluggable table.</p>
<p><a href="http://lsd.luminis.nl/wp-content/uploads/2009/10/SWING_OSGI_Pluggable-components600.jpg"><img class="size-full wp-image-435 alignnone" title="SWING_OSGI_Pluggable components600" src="http://lsd.luminis.nl/wp-content/uploads/2009/10/SWING_OSGI_Pluggable-components600.jpg" alt="SWING_OSGI_Pluggable components600" width="350" height="150" /></a></p>
<p>You can find the code we used at the end of this entry (or, for the impatient, <a href="http://lsd.luminis.nl/wp-content/uploads/2009/10/swing_osgi.zip">here</a>).</p>
<p>Using this pluggable system, we could end up with several curious situations. For instance, you might have a mixed look and feel in you application.</p>
<p><a href="http://lsd.luminis.nl/wp-content/uploads/2009/10/SWING_OSGI_wrong_menus.png"><img class="size-full wp-image-444 alignnone" title="SWING_OSGI_wrong_menus" src="http://lsd.luminis.nl/wp-content/uploads/2009/10/SWING_OSGI_wrong_menus.png" alt="SWING_OSGI_wrong_menus" width="250" height="350" /></a></p>
<p>Or worse, you might end up with a UI that (sometimes) fails to start, and spits a stacktrace your way.</p>
<p><a href="http://lsd.luminis.nl/wp-content/uploads/2009/10/swing_osgi_NPE.png"><img class="alignnone size-full wp-image-528" title="swing_osgi_NPE" src="http://lsd.luminis.nl/wp-content/uploads/2009/10/swing_osgi_NPE.png" alt="swing_osgi_NPE" width="350" height="170" /></a></p>
<h2>It leaks, but why?</h2>
<p>Our host, and all components have been stored in separate bundles, meaning we don&#8217;t have full control about the order in which actions are performed (more about that later). However, we do know there are orders of execution that are less than ideal; let&#8217;s force one of those.</p>
<p>The <a href="http://lsd.luminis.nl/wp-content/uploads/2009/10/swing_osgi.zip">project</a> contains an Ant script to make things easier. From the root of the extracted project, run</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #000000; font-weight: bold;">&amp;</span>gt; ant run1</pre></div></div>

<p>This starts the framework, installing the necessary bundles, but does not start them (note that this step uses <a href="http://paxrunner.ops4j.org">Pax Runner</a>, and therefore needs internet access). We can now start our bundles in the order we like.</p>
<h3>A tale of two look-and-feels</h3>
<p>After starting the framework, wait for the &#8220;Welcome to Felix&#8221; message, and run</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">     <span style="color: #7a0874; font-weight: bold;">&#91;</span>java<span style="color: #7a0874; font-weight: bold;">&#93;</span> Welcome to Felix
     <span style="color: #7a0874; font-weight: bold;">&#91;</span>java<span style="color: #7a0874; font-weight: bold;">&#93;</span> ================
     <span style="color: #7a0874; font-weight: bold;">&#91;</span>java<span style="color: #7a0874; font-weight: bold;">&#93;</span>
start <span style="color: #000000;">2</span>
start <span style="color: #000000;">1</span></pre></div></div>

<p>The situation arises because the look and feel is a static concept in Swing. The menu bundle creates its <code>JMenu</code> <em>before</em> (see Menu.java, ln 30) the host sets its look and feel (Host.java, ln 51), and keep that look and feel, even when the host bundle changes it later.</p>
<h3>Tables, ScrollPanes and NPEs</h3>
<p>The NullPointerException above is a different story, but it goes back to the same staticness of Swing too. To force this situation, start only bundle 4.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">     <span style="color: #7a0874; font-weight: bold;">&#91;</span>java<span style="color: #7a0874; font-weight: bold;">&#93;</span> Welcome to Felix
     <span style="color: #7a0874; font-weight: bold;">&#91;</span>java<span style="color: #7a0874; font-weight: bold;">&#93;</span> ================
     <span style="color: #7a0874; font-weight: bold;">&#91;</span>java<span style="color: #7a0874; font-weight: bold;">&#93;</span>
start <span style="color: #000000;">4</span>
     <span style="color: #7a0874; font-weight: bold;">&#91;</span>java<span style="color: #7a0874; font-weight: bold;">&#93;</span> Exception <span style="color: #000000; font-weight: bold;">in</span> thread <span style="color: #ff0000;">&quot;AWT-EventQueue-0&quot;</span> java.lang.NullPointerException
     <span style="color: #7a0874; font-weight: bold;">&#91;</span>java<span style="color: #7a0874; font-weight: bold;">&#93;</span>      at net.luminis.swingosgi.part1.scrolltable.impl.TableComponent$1.run<span style="color: #7a0874; font-weight: bold;">&#40;</span>TableComponent.java:<span style="color: #000000;">31</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
     <span style="color: #7a0874; font-weight: bold;">&#91;</span>java<span style="color: #7a0874; font-weight: bold;">&#93;</span>      at java.awt.event.InvocationEvent.dispatch<span style="color: #7a0874; font-weight: bold;">&#40;</span>InvocationEvent.java:<span style="color: #000000;">209</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
     <span style="color: #7a0874; font-weight: bold;">&#91;</span>java<span style="color: #7a0874; font-weight: bold;">&#93;</span>      at java.awt.EventQueue.dispatchEvent<span style="color: #7a0874; font-weight: bold;">&#40;</span>EventQueue.java:<span style="color: #000000;">633</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
     <span style="color: #7a0874; font-weight: bold;">&#91;</span>java<span style="color: #7a0874; font-weight: bold;">&#93;</span>      at java.awt.EventDispatchThread.pumpOneEventForFilters<span style="color: #7a0874; font-weight: bold;">&#40;</span>EventDispatchThread.java:<span style="color: #000000;">296</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
     <span style="color: #7a0874; font-weight: bold;">&#91;</span>java<span style="color: #7a0874; font-weight: bold;">&#93;</span>      at java.awt.EventDispatchThread.pumpEventsForFilter<span style="color: #7a0874; font-weight: bold;">&#40;</span>EventDispatchThread.java:<span style="color: #000000;">211</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
     <span style="color: #7a0874; font-weight: bold;">&#91;</span>java<span style="color: #7a0874; font-weight: bold;">&#93;</span>      at java.awt.EventDispatchThread.pumpEventsForHierarchy<span style="color: #7a0874; font-weight: bold;">&#40;</span>EventDispatchThread.java:<span style="color: #000000;">201</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
     <span style="color: #7a0874; font-weight: bold;">&#91;</span>java<span style="color: #7a0874; font-weight: bold;">&#93;</span>      at java.awt.EventDispatchThread.pumpEvents<span style="color: #7a0874; font-weight: bold;">&#40;</span>EventDispatchThread.java:<span style="color: #000000;">196</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
     <span style="color: #7a0874; font-weight: bold;">&#91;</span>java<span style="color: #7a0874; font-weight: bold;">&#93;</span>      at java.awt.EventDispatchThread.pumpEvents<span style="color: #7a0874; font-weight: bold;">&#40;</span>EventDispatchThread.java:<span style="color: #000000;">188</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
     <span style="color: #7a0874; font-weight: bold;">&#91;</span>java<span style="color: #7a0874; font-weight: bold;">&#93;</span>      at java.awt.EventDispatchThread.run<span style="color: #7a0874; font-weight: bold;">&#40;</span>EventDispatchThread.java:<span style="color: #000000;">122</span><span style="color: #7a0874; font-weight: bold;">&#41;</span></pre></div></div>

<p>Let&#8217;s take a look at the line where this NPE happens:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #003399;">JScrollPane</span> scrollPane <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">JScrollPane</span><span style="color: #009900;">&#40;</span>table<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
scrollPane.<span style="color: #006633;">getColumnHeader</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">setBackground</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">Color</span>.<span style="color: #006633;">blue</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
m_panel.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>scrollPane<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>We know that the <code>ColumnHeader</code> is null. This is because its <code>JTable</code>&#8217;s responsibility to create the header, but this is only done once the table knows it is part of an AWT hierarchy. The following lines come from the 1.5 JDK on a Mac; <code>configureEnclosingScrollPane()</code> creates the column header. This <code>addNotify</code> method comes from <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/awt/Component.html#addNotify%28%29">Component</a>, and notifies of, exactly, the event of being added to an AWT container.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> addNotify<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">addNotify</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  configureEnclosingScrollPane<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<h2>Order, order!</h2>
<p>So, the static nature of Swing and the dynamic nature of OSGi seem to hurt each other seriously here.</p>
<p>One way to get the application right is by fixing the order in which Swing components can be created. By starting bundle 1 first in our application, we at least fix the look and feel. Getting the scrolling table to run correctly is an entirely different story.</p>
<p>Regarding order, a few possible solutions spring to mind immediately,</p>
<ol>
<li>Put all UI stuff in one bundle</li>
<li>Use OSGi bundle start levels</li>
</ol>
<p>Sure, all UI in a single bundle will give you the control necessary, but it also defeats the purpose. OSGi start levels can at least solve the ordering issues, but will not get you out of the NullPointerException and might have more impact than you desire.</p>
<h3>What order?</h3>
<p>As we have seen, absolute order does not solve our problem. How about separating creation and initialization? Still, we need to impose some order, or at least some hierarchy.</p>
<p><img class="alignnone size-full wp-image-446" title="SWING_OSGI_Application composition600" src="http://lsd.luminis.nl/wp-content/uploads/2009/10/SWING_OSGI_Application-composition600.jpg" alt="SWING_OSGI_Application composition600" width="446" height="210" /></p>
<p>We represent each Swing component by an OSGi service, and leverage the OSGi service dependency resolution to build up our hierarchy; this way, we know the host service will be started last.</p>
<ol>
<li><strong>Resolve services</strong> Once the host bundle starts, we know all components are locked and loaded; the host can now start setting up Swing&#8217;s static elements like the look and feel.</li>
<li><strong>Create components</strong> Component creation ripples downward: the host gets its direct children, adding them to its container, and in the process triggering the children to get their child components.</li>
<li><strong>Initialize components</strong> Once the component creation is done, the host instructs each component to initialize; we can now be certain that all components are part of the AWT hierarchy.</li>
</ol>
<p>To reach this situation, we introduce a new OSGi service that wraps the component.</p>
<p><img class="alignnone size-full wp-image-447" title="SWING_OSGI_Using component provider600" src="http://lsd.luminis.nl/wp-content/uploads/2009/10/SWING_OSGI_Using-component-provider600.jpg" alt="SWING_OSGI_Using component provider600" width="447" height="219" /></p>
<p>All components are handled by a service implementing <code>ComponentProvider</code>; notice how methods are required to be called on the EventDispatchThread, making sure that all components are created on the EDT, while retaining the order necessary.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">interface</span> ComponentProvider <span style="color: #009900;">&#123;</span>
 <span style="color: #008000; font-style: italic; font-weight: bold;">/**
 * Constant to identify ComponentProvider services.
 */</span>
 <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">String</span> COMPONENT_ID_KEY <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;component.id&quot;</span><span style="color: #339933;">;</span>
&nbsp;
 <span style="color: #008000; font-style: italic; font-weight: bold;">/**
 * This function should always be called from the EDT. The implementor
 * may assume that this function is called once and before {@link #addedToContainer()}
 *
 * @return the implementors (Swing) component which it provides.
 */</span>
 <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">JComponent</span> getComponent<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
 <span style="color: #008000; font-style: italic; font-weight: bold;">/**
 * Triggered when the component is added to a container. The implementation
 * can validate some stuff. This function must be called on the EDT.
 * Implementors may assume this function is called after {@link #getComponent()}.
 */</span>
 <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> addedToContainer<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>The <code>getComponent</code> function is analogous to the <em>create</em> step above; the <code>addedToContainer</code> triggers the <em>initialize</em>.</p>
<h3>Let&#8217;s try that out!</h3>
<p>To check that this actually works OK, run</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #000000; font-weight: bold;">&amp;</span>gt; ant run2</pre></div></div>

<p>from the root of the project, and start the bundles in any order you like. The UI will only show up once <em>all required</em> components are available; notice that the <code>Table</code> and the <code>ScrollPane</code> component can be used interchangeably.</p>
<h2>Is it all good?</h2>
<p>For the most part, yes. You do give up some flexibility: the UI is assembled at runtime, but it is no longer possible to (easily) plug components into a running system without special provisions. Then again, how often do you deploy new Swing-based functionality to a <em>running</em> application?</p>
<p>In the example application, we use ServiceTrackers to keep track of the components needed by the host. In a real system, you should consider using some dependency management mechanism; we have used the <a href="http://felix.apache.org/site/apache-felix-dependency-manager.html">Apache Felix Dependency Manager</a> in the past.</p>
<h2>The project and the story</h2>
<p>The project mentioned above is available as a zipped <a href="http://lsd.luminis.nl/wp-content/uploads/2009/10/swing_osgi.zip">Eclipse project</a>. You can directly import this into Eclipse, or just unzip it and run the Ant build file.</p>
<p>To run the examples, you will need <a href="http://ant.apache.org/">Apache Ant</a>. Also, since we use <a href="http://paxrunner.ops4j.org/space/Pax+Runner">Pax Runner</a>, you will need an internet connection.</p>
<p>The presentation we gave about this at Devoxx 09 is at SlideShare.</p>
<div style="width:425px;text-align:left" id="__ss_2527491"><a style="font:14px Helvetica,Arial,Sans-serif;display:block;margin:12px 0 3px 0;text-decoration:underline;" href="http://www.slideshare.net/angelovds/swing-osgi-devoxx-09" title="Swing &amp; OSGi - Devoxx 09">Swing &amp; OSGi &#8211; Devoxx 09</a><object style="margin:0px" width="425" height="355"><param name="movie" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=swingandosgi-devoxx09-091118073831-phpapp01&#038;rel=0&#038;stripped_title=swing-osgi-devoxx-09" /><param name="allowFullScreen" value="true"/><param name="allowScriptAccess" value="always"/><embed src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=swingandosgi-devoxx09-091118073831-phpapp01&#038;rel=0&#038;stripped_title=swing-osgi-devoxx-09" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="355"></embed></object>
<div style="font-size:11px;font-family:tahoma,arial;height:26px;padding-top:2px;">View more <a style="text-decoration:underline;" href="http://www.slideshare.net/">presentations</a> from <a style="text-decoration:underline;" href="http://www.slideshare.net/angelovds">Angelo van der Sijpt</a>.</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://lsd.luminis.nl/swing-and-osgi/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>ApacheCon US 2009 &#8211; Celebrating a decade of open source leadership</title>
		<link>http://lsd.luminis.nl/apachecon-us-2009-celebrating-a-decade-of-open-source-leadership/</link>
		<comments>http://lsd.luminis.nl/apachecon-us-2009-celebrating-a-decade-of-open-source-leadership/#comments</comments>
		<pubDate>Tue, 10 Nov 2009 08:18:29 +0000</pubDate>
		<dc:creator>Marcel Offermans</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[Apache ACE]]></category>
		<category><![CDATA[Apache Felix]]></category>
		<category><![CDATA[Apache Sling]]></category>
		<category><![CDATA[Apache Tuscany]]></category>
		<category><![CDATA[ApacheCon]]></category>
		<category><![CDATA[meritocracy]]></category>
		<category><![CDATA[News Item]]></category>
		<category><![CDATA[OSGi]]></category>
		<category><![CDATA[Subversion]]></category>

		<guid isPermaLink="false">http://lsd.luminis.nl/?p=520</guid>
		<description><![CDATA[The Apache Software Foundation celebrated its 10th anniversary last week at the ApacheCon US in Oakland, California. The event, which lasted from November 2nd to 6th, consisted of many different types of events, ranging from full-day trainings to lightning talks, from a hackathon to technical and marketing sessions. On friday, the event featured a full-day [...]]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://www.apache.org/">Apache Software Foundation</a> celebrated its 10th anniversary last week at the ApacheCon US in Oakland, California. The event, which lasted from November 2nd to 6th, consisted of many different types of events, ranging from full-day trainings to lightning talks, from a hackathon to technical and marketing sessions. On friday, the event featured a full-day track about OSGi, where all OSGi related Apache projects like <a href="http://felix.apache.org/">Felix</a>, <a href="http://incubator.apache.org/ace/">ACE</a>, <a href="http://sling.apache.org/">Sling</a> and <a href="http://tuscany.apache.org/">Tuscany</a> where present. The big announcement of the conference was the fact that <a href="http://www.linuxpromagazine.com/Online/News/Subversion-Goes-to-Apache">Subversion wanted to join Apache</a>. In fact, during the event, just like with any other project, there was a vote to accept Subversion into the incubator. As with many projects, this triggered some discussion, debating the merits of doing a release during incubation, even though this is a project with many seasoned Apache committers on board.</p>
<h2>A conference like no other</h2>
<p>Apache probably is the strongest brand in the open source space, but the conference itself focusses strongly on content. Here you will see no sponsored talks by commercial vendors, no sales people trying to sell you anything, it&#8217;s all about the code, the community and collaborating with each other. In that sense it&#8217;s quite different from most other conferences and if you like meeting and discussing fellow developers, this is a great place to visit. Many events facilitate discussion, and power and internet connectivity are available everywhere.</p>
<h2>What open source is all about</h2>
<p>Brian Behlendorf summarized the three main cultural elements of Apache quite well:</p>
<ul>
<li>write good code and debate it to the bone</li>
<li>be humble</li>
<li>collaborate</li>
</ul>
<p>In essence, Apache is a meritocracy, of which only individuals can become a member. It&#8217;s sometimes also described as a do-ocracy as projects are driven by contributions: if you want something done, just do it. Another important aspect is that everything that is done on the Apache projects is discussed and archived on the mailing list. All discussions, code diffs and decisions must be recorded there.</p>
<h2>Presenting Apache ACE</h2>
<p>Tuesday evenings &#8220;birds of a feather&#8221; session featured a discussion about Apache ACE, where questions mostly centered around the use cases for ACE and possible integrations with other OSGi components. One of the conclusions is that there are probably three different phases of deployment:</p>
<ol>
<li>Using Apache Felix File Installer, which allows you to drop components in a local folder to have them installed.</li>
<li>Using Apache Felix Karaf&#8217;s provisioning components, which allow you to define features which basically group components and allow you to define dependencies on other features.</li>
<li>Using Apache ACE, which allows you to group components and automatically deploy them to many remote systems.</li>
</ol>
<p>Friday&#8217;s OSGi track started with an introduction to OSGi and moved into more advanced topics during the day. The Apache ACE talk was received well, with several people expressing an interest in wanting to use it and contribute to it.</p>
<h2>Final thoughts</h2>
<p>Summarizing the week, Floris and I had a great time talking to many interesting people and learning about various projects. ApacheCon is a great conference, and I&#8217;m already looking forward to the next one.</p>
]]></content:encoded>
			<wfw:commentRss>http://lsd.luminis.nl/apachecon-us-2009-celebrating-a-decade-of-open-source-leadership/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Oredev 2009</title>
		<link>http://lsd.luminis.nl/oredev-2009/</link>
		<comments>http://lsd.luminis.nl/oredev-2009/#comments</comments>
		<pubDate>Fri, 06 Nov 2009 22:44:59 +0000</pubDate>
		<dc:creator>Angelo van der Sijpt</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[conference]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[News Item]]></category>
		<category><![CDATA[OSGi]]></category>
		<category><![CDATA[Øredev]]></category>

		<guid isPermaLink="false">http://lsd.luminis.nl/?p=486</guid>
		<description><![CDATA[4 - 6 November I went to Øredev, probably the largest developer conference in Scandinavia. Time for some highlights...]]></description>
			<content:encoded><![CDATA[<p><b>Update 2010-05-08</b><br />
The video of my session is up! Check it out at <a href="http://oredev.com/videos/dynamic-deployment-with-osgi">http://oredev.com/videos/dynamic-deployment-with-osgi</a>.</p>
<p>This past week (4 &#8211; 6 November), I went to <a href="http://www.oredev.com">Øredev</a>, probably the largest developer conference in Scandinavia. I had been invited as a speaker, thanks for having me!</p>
<h3>Great food, nice ambiance</h3>
<p>The first thing that strikes me about this conference is how well it has been prepared. The food is great, there is a good evening program, and overall both your inner geek and inner person are well looked after.</p>
<h3>Highlights</h3>
<p><strong>Interactive Visualizations from Microsoft research &#8211; Eric Stollnitz (User Experience track)<br />
<span style="font-weight: normal;">One of the rare talks I actually did not like. Having not read the session description properly, I had totally wrong expectations; the session demoed visual tools like <a href="http://livelabs.com/photosynth/">Photosynth</a>, which are cool, but not something we haven&#8217;t seen before. And besides, running Vista on a Mac, and having to kill Internet Explorer&#8230;?</span></strong></p>
<p><strong><span style="font-weight: normal;"><strong>Open source Java: ten things you didn&#8217;t know you could do &#8211; Terrence Barr (Java track) </strong><br />
Early in the talk it felt like a plug for the greatness of Sun, making Java open source. Later, however, it mentions some <em>seriously</em> cool technology that has become possible now! Some honorable mentions,</span></strong></p>
<ul>
<li>The <a href="http://research.sun.com/projects/maxine/">Maxine guest VM</a> is an effort to run a Java VM directly on a HyperVisor, skipping the entire OS!</li>
<li><a href="http://www.ikvm.net/">IKVM.NET</a> is a project aiming to run Java code on a .NET VM. Somehow, it turns out that Java bytecode and .NET assembly language are so similar, that an effort has been started to create automatic translation tools between compiled Java and compiled .NET (and vice versa). I would like to add that this is allows not only Java to run on a .NET VM, but likely any language that runs on the Java VM! Interesting&#8230;</li>
<li><a href="http://icedtea.classpath.org/wiki/ZeroSharkFaq#What_is_Zero.3F">Zero</a> writes a Java VM in plain C without using assembler code, making it easier to port it to new platforms.</li>
</ul>
<p><strong>The Manager&#8217;s Guide to Agile Adoption &#8211; Mike Cottmeyer (PM In Practice track)</strong><br />
A great talk showing the issues that might hamper agile adoption, especially in larger organizations. Some snippets,</p>
<ul>
<li>&#8220;Agile adoption at the team level is not the issue, it&#8217;s adopting agile <em>across</em> teams.&#8221;</li>
<li>Don&#8217;t speak of features of a system, speak of capabilities (think about that one!)</li>
<li>Depending on the amount of dependencies between teams, we could use a Scrum of Scrums (resource dependency), Product Owner team (requirements dependency), or a Product Owner team with Architects (technical dependencies). Whatever method is used, this higher level should build a <em>normalized</em> backlog, intended to create some alignment along the teams. The team&#8217;s backlogs are based on this normalized backlog.</li>
<li>Feature teams will break down at some level; at a certain system size, it&#8217;s no longer possible to create a top-to-bottom slice of the system which is small enough for a single team to manage.</li>
</ul>
<p>In short, I really enjoyed this talk, and I feel there might be some applications for these ideas somewhere near me&#8230;</p>
<p><strong>How Exactly Can Developers Create a Compelling User Experience? &#8211; Ben Galbraith (User Experience track)</strong><br />
Exactly the way I would expect a user experience talk to look (and feel!) like: polished imagery, a well-oiled story line, and lots of inspiration. Besides, I have two new books to add to my reading list: <a href="http://www.bol.com/nl/p/boeken-engels/about-face-3/1001004004709687/index.html">About Face</a> by Alan Cooper, which seems to be the standard volume on interaction design, and <a href="http://www.bol.com/nl/p/boeken-engels/the-humane-interface/1001004001047367/index.html">The humane interface</a> by Jeff Raskin.</p>
<p><strong>Reconsidering cherished design dogmas &#8211; Johannes Brodwall &amp; Finn-Robert Kristensen (Architecture track)</strong><br />
I actually had a beer with these guys a few days earlier, and they told me about their ideas. In short, there are a number of dogmas in software design we came to hold true, but are they actually true? For instance, is generic code really more reusable than specific code?</p>
<p>It&#8217;s a shame the talk didn&#8217;t really come across, and I could not put my finger on the problem; it might have something to do with the over-abstracted example they chose.</p>
<p><strong>Dynamic Deployment with OSGi &#8211; Angelo van der Sijpt (Java track)</strong><br />
Well, let the crowds decide on this one. Have you visited my talk, and have an opinion about it? Let me know in the comments?</p>
<p><strong>Modeling in the Age of Agility &#8211; Kevlin Henney (Agile Architecture track)</strong><br />
&#8220;Working software over comprehensive documentation&#8221; sounds good, but how about modeling? Are all models potential waste? Of course not, but when applying modeling because it is modeling, is sure to create models no one will ever look at, and the few good ones in there are buried. Some snippets,</p>
<ul>
<li>&#8220;Agile is all about doing.&#8221; Actually, I did not know the word &#8216;Agile&#8217; comes from the Latin verb for &#8216;to do&#8217;.</li>
<li>&#8220;The most important aspect of modeling is the -ing.&#8221;</li>
</ul>
<h3>So?</h3>
<p>Like I said, a great conference, and I&#8217;m sorry I missed the test track. I will leave you with a quote I picked up on Twitter (I don&#8217;t know which session it&#8217;s from),</p>
<p>&#8220;Don&#8217;t build frameworks, extract them&#8221;</p>
]]></content:encoded>
			<wfw:commentRss>http://lsd.luminis.nl/oredev-2009/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using GWT to create an OSGi-aware web application</title>
		<link>http://lsd.luminis.nl/using-gwt-to-create-an-osgi-aware-web-application/</link>
		<comments>http://lsd.luminis.nl/using-gwt-to-create-an-osgi-aware-web-application/#comments</comments>
		<pubDate>Thu, 09 Jul 2009 20:14:29 +0000</pubDate>
		<dc:creator>Angelo van der Sijpt</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Apache ACE]]></category>
		<category><![CDATA[Apache Felix]]></category>
		<category><![CDATA[extender]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[gwt]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[OSGi]]></category>
		<category><![CDATA[pax]]></category>
		<category><![CDATA[service]]></category>
		<category><![CDATA[smartservices]]></category>
		<category><![CDATA[toolkit]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://lsd.luminis.net/?p=217</guid>
		<description><![CDATA[<p><a href="http://code.google.com/webtoolkit/">Google Web Toolkit</a> is cool, and so is OSGi. However, creating a web application that can use OSGi services is not that easy. By the end of this tutorial, you will have created a GWT project that delivers a usable jar. If you're impatient, skip to the end for the downloadable Eclipse project.</p>]]></description>
			<content:encoded><![CDATA[<p><strong>Update 2010-02-20</strong> <em>Both Pax Runner 1.3.0 and GWT 2.0 have caused quite some changes to this post. I have tried to stay up to date as well as I could (the zipped project now uses GWT 2.0), but you might find some inconsistencies when following the tutorial.</em></p>
<p><a href="http://code.google.com/webtoolkit/">Google Web Toolkit</a> is cool, and so is OSGi. However, when building a web UI for <a href="http://cwiki.apache.org/confluence/display/ACE/Index">Apache ACE</a>, I found out that creating a web application that can use OSGi services is not that easy. By the end of this tutorial, you will have created a GWT project that delivers a usable jar. If you&#8217;re impatient, skip to the end for the downloadable Eclipse project.</p>
<h3>Step 1: Create a GWT project</h3>
<p>Create a regular GWT project using the regular webAppCreator; this will give you a project that includes an <a href="http://ant.apache.org">Ant</a> buildfile, we will need that later on.</p>

<div class="wp_syntax"><div class="code"><pre class="language" style="font-family:monospace;">angelos:workspace angelos$ ./gwt-mac-1.6.4/webAppCreator -out GwtDemo net.luminis.gwt.gwtdemo
Created directory GwtDemo/src
Created directory GwtDemo/war
Created directory GwtDemo/war/WEB-INF
Created directory GwtDemo/war/WEB-INF/lib
Created directory GwtDemo/src/net/luminis/gwt
Created directory GwtDemo/src/net/luminis/gwt/client
Created directory GwtDemo/src/net/luminis/gwt/server
Created file GwtDemo/src/net/luminis/gwt/gwtdemo.gwt.xml
Created file GwtDemo/war/gwtdemo.html
Created file GwtDemo/war/gwtdemo.css
Created file GwtDemo/war/WEB-INF/web.xml
Created file GwtDemo/src/net/luminis/gwt/client/gwtdemo.java
Created file GwtDemo/src/net/luminis/gwt/client/GreetingService.java
Created file GwtDemo/src/net/luminis/gwt/client/GreetingServiceAsync.java
Created file GwtDemo/src/net/luminis/gwt/server/GreetingServiceImpl.java
Created file GwtDemo/build.xml
Created file GwtDemo/README.txt
Created file GwtDemo/.project
Created file GwtDemo/.classpath
Created file GwtDemo/gwtdemo.launch
Created file GwtDemo/war/WEB-INF/lib/gwt-servlet.jar</pre></div></div>

<p>If you want to, you can import this project directly into your Eclipse. If you check the mark &#8220;use Google Web Toolkit&#8221; in the project properties, you can use all the same goodies that creating the project in Eclipse would have given you. Remember to replace the buildpath entries for gwt-user.jar and gwt-dev-*.jar by a Library import for GWT.</p>
<h3>Step 2: Include the necessary OSGi references</h3>
<p>Create an &#8216;ext&#8217; directory, and add org.osgi.core.jar to that. In Eclipse, add this jar to your build path.</p>
<h3>Step 3: Use OSGi services from your web applicaiton</h3>
<p>We will first add a simple Activator on the server side.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">net.luminis.gwt.server</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.osgi.framework.BundleActivator</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.osgi.framework.BundleContext</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> <span style="color: #003399;">Activator</span> <span style="color: #000000; font-weight: bold;">implements</span> BundleActivator <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> BundleContext m_context<span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> BundleContext getContext<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">return</span> m_context<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> start<span style="color: #009900;">&#40;</span>BundleContext context<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">Exception</span> <span style="color: #009900;">&#123;</span>
        m_context <span style="color: #339933;">=</span> context<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> stop<span style="color: #009900;">&#40;</span>BundleContext context<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">Exception</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Then, we up the GreetingServiceImpl to actually use this <a href="http://www.osgi.org/javadoc/r4v41/org/osgi/framework/BundleContext.html">BundleContext</a> (note that we use it directly here, but you could use it to get other services, create a <a href="http://www.osgi.org/javadoc/r4v41/org/osgi/util/tracker/ServiceTracker.html">ServiceTracker</a>, etc.)</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> greetServer<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> input<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #003399;">String</span> serverInfo <span style="color: #339933;">=</span> getServletContext<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getServerInfo</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #003399;">String</span> userAgent <span style="color: #339933;">=</span> getThreadLocalRequest<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getHeader</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;User-Agent&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #0000ff;">&quot;Hello, &quot;</span> <span style="color: #339933;">+</span> input <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;!
&nbsp;
I am running &quot;</span> <span style="color: #339933;">+</span> serverInfo
    <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;.
&nbsp;
It looks like you are using:&quot;</span> <span style="color: #339933;">+</span> userAgent <span style="color: #339933;">+</span>
    <span style="color: #0000ff;">&quot;The framework we run from has &quot;</span> <span style="color: #339933;">+</span> <span style="color: #003399;">Activator</span>.<span style="color: #006633;">getContext</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getBundles</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">length</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot; bundles in it.&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<h3>Step 4: Add OSGi dependencies for the compiler</h3>
<p>Add our OSGi dependencies to the classpath, so the compiler can find all of it.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">    <span style="color: #808080; font-style: italic;">&lt;!-- Add any additional non-server libs (such as JUnit) --&gt;</span></pre></div></div>

<p>Right, let&#8217;s give it a try!</p>

<div class="wp_syntax"><div class="code"><pre class="language" style="font-family:monospace;">angelos:GwtDemo angelos$ ant war
Buildfile: build.xml
&nbsp;
...some output removed...
&nbsp;
war:
[zip] Building zip: /Users/angelos/workspace/workspace/GwtDemo/gwtdemo.war
&nbsp;
BUILD SUCCESSFUL
Total time: 36 seconds</pre></div></div>

<p>You will find a war in your project directory now. There still is one ingredient we need. We need to make this into a proper bundle. We can use <a href="http://www.aqute.biz/Code/Bnd">bnd</a> to help us with that.</p>
<h3>Step 5: use bnd to create a proper war</h3>
<p>Download bnd, and put into a lib directory, and add it to your buildfile.</p>
<p>We create a new target that transforms our war into a jar.</p>

<div class="wp_syntax"><div class="code"><pre class="ant" style="font-family:monospace;">&lt;target name=&quot;jar&quot;&gt;
    &lt;copy file=&quot;gwtdemo.war&quot; tofile=&quot;gwtdemo.jar&quot;/&gt;
    &lt;echo file=&quot;gwtdemo.bnd&quot;&gt;Import-Package: junit.framework;resolution:=optional, com.google.gwt.*;resolution:=optional, org.w3c.*;resolution:=optional, sun.misc;resolution:=optional, javax.imageio;resolution:=optional, javax.servlet.*;resolution:=optional, *
Bundle-Name: GWT Demo
Bundle-ClassPath: WEB-INF/classes, WEB-INF/lib/gwt-servlet.jar
Bundle-SymbolicName: net.luminis.gwt.gwtdemo
Webapp-Context: gwtdemo
Bundle-Activator: net.luminis.gwt.server.Activator
    &lt;/echo&gt;
    &lt;bndwrap jars=&quot;gwtdemo.jar&quot; output=&quot;gwtdemo.jar&quot;/&gt;
    &lt;jar file=&quot;gwtdemo.jar&quot; update=&quot;true&quot;&gt;
    &lt;manifest&gt;
        &lt;attribute name=&quot;Bundle-ClassPath&quot; value=&quot;WEB-INF/classes, WEB-INF/lib/gwt-servlet.jar, .&quot;/&gt;
     &lt;/manifest&gt;
    &lt;/jar&gt;
    &lt;delete file=&quot;gwtdemo.bnd&quot;/&gt;
&lt;/target&gt;</pre></div></div>

<p>What&#8217;s happening here?</p>
<ul>
<li>we copy our war to the same file, but with a jar extension,</li>
<li>we create a file for bnd to use, stating that we
<ul>
<li>want optional imports for junit and the gwt benchmarks, and non-optional imports for everything else (that what the * is for),</li>
<li>have some classes that we want bnd to scan for finding dependencies,</li>
<li>want to use a given Webapp-Context (this is a <a href="http://paxrunner.ops4j.org/display/paxweb/WAR+Extender">Pax war extender</a> specific entry),</li>
</ul>
</li>
<li>let bnd do its magic,</li>
<li>update our manifest: we put the . back on the classpath. This is important for the web application to find all resources, but if we would tell bnd to do it like this, it would treat . as the root of the classpath.</li>
<li>Finally, we delete that temporary bnd file.</li>
</ul>
<p>What does that give us?</p>

<div class="wp_syntax"><div class="code"><pre class="language" style="font-family:monospace;">angelos:GwtDemo angelos$ ant jar
Buildfile: build.xml
&nbsp;
...some output removed...
&nbsp;
jar:
[copy] Copying 1 file to /Users/angelos/workspace/workspace/GwtDemo
[bndwrap] gwtdemo 41 910305
[bndwrap] Warnings
[bndwrap] Superfluous export-package instructions: [WEB-INF.classes.net, gwtdemo.gwt.standard.images, WEB-INF, gwtdemo, WEB-INF.classes.net.luminis.gwt, gwtdemo.gwt.standard, WEB-INF.classes.net.luminis, WEB-INF.lib, WEB-INF.classes, gwtdemo.gwt.standard.images.ie6, WEB-INF.classes.net.luminis.gwt.client, WEB-INF.classes.net.luminis.gwt.server, gwtdemo.gwt]
[jar] Updating jar: /Users/angelos/workspace/workspace/GwtDemo/gwtdemo.jar
[delete] Deleting: /Users/angelos/workspace/workspace/GwtDemo/gwtdemo.bnd
&nbsp;
BUILD SUCCESSFUL
Total time: 23 seconds</pre></div></div>

<p>That&#8217;s it! You can now deploy this jar into a framework that uses the pax web tools. Right, let&#8217;s give that a try.</p>
<p>Download <a href="http://paxrunner.ops4j.org/space/Pax+Runner">pax-runner</a>, and unzip that somewhere. Copy in your new jar, an try the following command</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">angelos:pax-runner angelos$ <span style="color: #c20cb9; font-weight: bold;">sh</span> bin<span style="color: #000000; font-weight: bold;">/</span>pax-run.sh <span style="color: #660033;">--profiles</span>=war,compendium gwtdemo.jar</pre></div></div>

<p>Now visit <a href="http://localhost:8080/gwtdemo">http://localhost:8080/gwtdemo</a>:</p>
<p><img class="alignnone size-full wp-image-450" title="gwtdemo" src="http://lsd.luminis.nl/wp-content/uploads/2009/07/gwtdemo.png" alt="gwtdemo" width="500" height="432" /></p>
<h3>Summary</h3>
<p>So, what did we need?</p>
<ul>
<li>A fairly regular GWT project, create with an Ant file,</li>
<li>some code that tries to use OSGi services,</li>
<li>some bnd magic to make the war into a jar,</li>
<li>Pax tools to get it all running quickly.</li>
</ul>
<p>If you don&#8217;t want to use pax runner, you can need to deploy <a href="http://paxrunner.ops4j.org/display/paxweb/WAR+Extender">pax-web-extender-war</a>(<a href="http://repository.ops4j.org/mvn-snapshots/org/ops4j/pax/web/pax-web-extender-war/0.7.0-SNAPSHOT/pax-web-extender-war-0.7.0-20090623.160836-13.jar">jar</a>, snapshot 23 June) and an http server, preferably <a href="http://paxrunner.ops4j.org/display/paxweb/Pax+Web">pax-web-service</a>(<a href="http://repository.ops4j.org/maven2/org/ops4j/pax/web/pax-web-service/0.6.0/pax-web-service-0.6.0.jar">jar</a>), into your framework.</p>
<p>You can download the <a href='http://lsd.luminis.nl/wp-content/uploads/2009/07/gwtdemo.zip'>gwtdemo</a> Eclipse project to play around with it. I have not provided the GWT runtime in this download; you should edit line 4 of the build.xml to point to your installation of GWT.</p>
]]></content:encoded>
			<wfw:commentRss>http://lsd.luminis.nl/using-gwt-to-create-an-osgi-aware-web-application/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>EZdroid launched</title>
		<link>http://lsd.luminis.nl/ezdroid-launched/</link>
		<comments>http://lsd.luminis.nl/ezdroid-launched/#comments</comments>
		<pubDate>Fri, 29 May 2009 09:25:43 +0000</pubDate>
		<dc:creator>Arjan Schaaf</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Apache ACE]]></category>
		<category><![CDATA[Apache Felix]]></category>
		<category><![CDATA[appstore]]></category>
		<category><![CDATA[EZDroid]]></category>
		<category><![CDATA[Google Android]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[OSGi]]></category>
		<category><![CDATA[provisioning]]></category>

		<guid isPermaLink="false">http://lsd.luminis.net/?p=198</guid>
		<description><![CDATA[<p><img class="nieuws_post_image" src="http://blog.luminis.nl/roller/luminis/resource/arjan/EZdroid.png"/></p>
<p>The EZdroid initiative is launched: http://www.ezdroid.com
EZdroid is a platform where developers of component-based software for provisioning the Android platform collaborate and initiate business ideas.</p>
]]></description>
			<content:encoded><![CDATA[<p>
<img ALIGN=MIDDLE src="http://blog.luminis.nl/roller/luminis/resource/arjan/EZdroid_small.png"/><br />
The EZdroid initiative is launched: <a href="http://www.ezdroid.com/">www.ezdroid.com</a>
</p>
<p>
We are pleased to announce the launch of EZdroid, the world’s first open-source, collaborative platform for the safe deployment of component-based software applications and content across Android, and other Linux-based mobile devices.<br />
EZdroid was founded by two of Europe’s leading companies in the field of OSS technology; the platform consists of Android, Apache Felix and a number of their own enhancements (e.g. software license-, device- and integrated software-management). EZdroid supports the secure deployment of software applications and content (known as Provisioning) to Android phones and in the future, other Linux-based operating systems. It is available to any organization or individual wishing to make software and content available to Android users world-wide. Further information and a demonstration of the platform is now available and downloadable to Android phones at: http://www.ezdroid.com.
</p>
<p>
EZdroid’s founders: Luminis BV (www.luminis.nl/en) of The Netherlands and Akquinet GmbH (www.akquinet.com/en) of Germany are now inviting partners and collaborators to become part of the EZdroid community – whether these are developers, wishing to show-case their applications, business partners interested in co-development or an OEM relationship, or organizations which are interested in owning and controlling their own application repository/App Store.
</p>
<p>
The launch of EZdroid is very significant; it is the world’s first platform, built from open source components, which will allow the mass deployment of applications without proprietary licensing issues. The founders intend to supplement the platform with a validation and quality assurance system – to ensure that applications are safe and do not interfere with Android’s normal operations.</p>
]]></content:encoded>
			<wfw:commentRss>http://lsd.luminis.nl/ezdroid-launched/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>J-Spring 2009</title>
		<link>http://lsd.luminis.nl/j-spring-2009/</link>
		<comments>http://lsd.luminis.nl/j-spring-2009/#comments</comments>
		<pubDate>Thu, 16 Apr 2009 18:17:24 +0000</pubDate>
		<dc:creator>Peter Doornbosch</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[buglabs]]></category>
		<category><![CDATA[conference]]></category>
		<category><![CDATA[jspring]]></category>
		<category><![CDATA[lwuit]]></category>
		<category><![CDATA[mda]]></category>
		<category><![CDATA[News Item]]></category>
		<category><![CDATA[nljug]]></category>
		<category><![CDATA[OSGi]]></category>

		<guid isPermaLink="false">http://lsd.luminis.net/?p=189</guid>
		<description><![CDATA[Aan de druk bezochte J-Spring Java conferentie in een zomers warm Spant! in Bussum, heeft <b>luminis</b> weer een flinke bijdrage geleverd: gratis tompouce bij de stand, een boekverloting, 3 presentaties over uiteenlopende onderwerpen en sponsor van de slotborrel!]]></description>
			<content:encoded><![CDATA[<p>Aan de druk bezochte J-Spring Java conferentie in een zomers warm Spant! in Bussum, heeft <strong>luminis</strong> weer een flinke bijdrage geleverd. Bij de stand werd de bezoeker getrakteerd op een overheerlijke tompouce (van de <em>echte</em> bakker!) en werden lootjes uitgedeeld voor een boekverloting. Op inhoudelijk vlak bestond de bijdrage uit 3 presentaties over uiteenlopende onderwerpen. En voor de bezoekers die het uithoudingsvermogen hadden om tot het eind te blijven, was er dan nog de door <strong>luminis</strong> gesponsorde borrel!</p>
<p><img src="http://blog.luminis.nl/luminis/resource/peter/meerviltjes.jpg" alt="" /></p>
<p>De presentatie van Jaap Vriend ging over <a href="lwuit_een_lichtgewicht_ui_toolkit">LWUIT</a>, een UI library voor J2ME. Deze library biedt een op Swing lijkend programmeermodel en maakt het veel makkelijker om een J2ME applicatie er op alle telefoons hetzelfde uit te laten zien.</p>
<p>Richard van der Laan presenteerde samen met Tony Sloos van ArchitecIT een pragmatische benadering van MDA. Aan de hand van een concreet voorbeeld lieten ze zien hoe je bottom-up MDA kunt invoeren, waarbij je er vanaf het begin voordeel van hebt.</p>
<p>Onze OSGi guru, Marcel Offermans, had een leuke demo samengesteld op basis van <a href="unboxing_the_bug">de leukste bug</a>. Nu is een live demo natuurlijk altijd riskant, maar Marcel is typisch iemand die dat wel aan kan. Helaas voor hem (en voor het publiek) waren de goden hem dit keer niet zo goed gezind en lukte het niet de demo dat te laten doen wat hij had moeten doen. Dus die houden we van hem tegoed! Bij de J-Fall op de <strong>luminis</strong> stand?</p>
<p>De presentaties kun je als pdf downloaden:</p>
<ul>
<li><a href="http://blog.luminis.nl/luminis/resource/jspring/lwuit.pdf">LWUIT, proberen of negeren?</a></li>
<li><a href="http://www.luminis.nl/downloads/JSpring2009_MDA.pdf">MDA: Slimmer ontwikkelen van Java EE applicaties</a></li>
<li><a href="http://www.luminis.nl/downloads/JSpring2009_DeLeuksteBug.pdf">De leukste Bug!</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://lsd.luminis.nl/j-spring-2009/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Enterprise Javabeans 3 in OSGi &#8212; part 2</title>
		<link>http://lsd.luminis.nl/enterprise-javabeans-3-in-osgi-part-2/</link>
		<comments>http://lsd.luminis.nl/enterprise-javabeans-3-in-osgi-part-2/#comments</comments>
		<pubDate>Thu, 29 Jan 2009 17:32:03 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[ejb3]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[OSGi]]></category>

		<guid isPermaLink="false">http://lsd.luminis.net/?p=182</guid>
		<description><![CDATA[
This blog picks up on some unfinished items mentioned in the first blog. More specifically, this blog will focus on:

auto-injecting session beans;
entity-only bundles;
transaction rollback.

Note that if the reader wants to run the example source, he or she is referred to the aformentioned previous blog in which more information on setting up the environment and getting [...]]]></description>
			<content:encoded><![CDATA[<p>
This blog picks up on some unfinished items mentioned in the <a href="http://blog.luminis.nl/roller/luminis/entry/enterprise_javabeans_3_in_osgi">first blog</a>. More specifically, this blog will focus on:</p>
<ul>
<li>auto-injecting session beans;
<li>entity-only bundles;
<li>transaction rollback.
</ul>
<p>Note that if the reader wants to run the <a href="http://blog.luminis.nl/luminis/resource/jaapv/example2.zip" onClick="javascript:pageTracker._trackPageview('/downloads/example2.zip'); ">example source</a>, he or she is referred to the aformentioned previous blog in which more information on setting up the environment and getting the sources to compile/run can be found. To get the samples running, you always need to start <i>ezb-command.jar</i> and <i>entitybeans.jar</i>. Besides those 2 bundles, you either need to start <i>combinedbean.jar</i> (includes 2 stateless beans) <b>or</b> <i>statelessbean1.jar</i> <b>and</b> <i>statelessbean2.jar</i> (both bundles contain 1 stateless bean).</p>
<h3>Auto-injecting session beans</h3>
<p>In EJB3 (and therefore also in EZB) it is possible to inject a reference to a session bean through using the &#8216;@EJB&#8217; annotation. When using this annotation, you can supply the product-specific name of the EJB to which it should be mapped (could be any kind of name &#8211; even though it is often a JNDI one). As it turns out, EZB almost completely supports this feature; both when the EJB to be injected is defined within the same bundle (use <i>combinedbean.jar</i>) and when it is defined in a different bundle (use <i>statelessbean1.jar</i> and <i>statelessbean2.jar</i>) the reference is injected properly and no lookup takes place:</p>
<pre>
    @EJB(mappedName="SL2")
    private Stateless2Remote m_stateless2 = null;

    @EJB
    private Stateless2Remote m_stateless2NotAutoInjected = null;

    // ... and some code using it:

    if (m_stateless2 == null) {
        // '@EJB' injection did not take place, performing lookup
        try {
            m_stateless2 = (Stateless2Remote)new InitialContext().lookup(
                String.format("%s_%s@Remote", "net.luminis.ezb.stateless2.impl.Stateless2Impl", Stateless2Remote.class.getName()));
        } catch (NamingException e) {
            e.printStackTrace(); // lookup failed.
        }
    }
</pre>
<p>Note though, that the mappedName <b>must</b> be set both here and in the implementation of the session bean to be injected. If this is not done, EZB <a href="http://jira.easybeans.org/browse/EZB-322">cannot find/inject it</a>. I.e. in the code above, at the point where m_stateless2 has been set, the member variable m_stateless2NotAutoInjected is still <i>null</i>.</p>
<h3>Entity-only bundles</h3>
<p>When deploying ones bundles you&#8217;re likely to combine related functionality. It&#8217;s possible to simply put everything in a single bundle, but not desirable; the more fine-grained your design, the easier it is to re-use a specific bit of functionality. When you decide to define an entity-only bundle, EZB requires that you include the line</p>
<pre>
<class>net.luminis.ezb.entitybeans.Kangaroo</class>
</pre>
<p>both in <i>persistence.xml</i> of the entity-bundle, but also in all bundles using the entity-bundle. This inconvenience may be corrected, but for now, it&#8217;s not a very flexible way of working; when you add an entity bean to your entity-bundle, you not only have to update the <i>persistence.xml</i> in that bundle, but also in all bundles using it!</p>
<h3>Rollback</h3>
<p>Finally, the source code attached to this blog also includes an example of how EZB handles a transaction rollback. It is possible to trigger such a rollback by using:</p>
<pre>
m_sessionContext.setRollbackOnly();
</pre>
<p>to signal the session to perform a rollback of every action associated with the current transaction. In this example the functionality is illustrated through using the command</p>
<pre>
ezb use_injected_max
</pre>
<p>which not only uses an injected session bean to create a Kangaroo entity, but also triggers a rollback if 4 Kangaroos have already been created. (Check the methods <i>addKangaroo()</i> and <i>addKangarooWithMaximumCheck()</i> in <i>Stateless2Impl</i> to find out more.</p>
]]></content:encoded>
			<wfw:commentRss>http://lsd.luminis.nl/enterprise-javabeans-3-in-osgi-part-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Unboxing the Bug</title>
		<link>http://lsd.luminis.nl/unboxing-the-bug/</link>
		<comments>http://lsd.luminis.nl/unboxing-the-bug/#comments</comments>
		<pubDate>Mon, 05 Jan 2009 18:53:31 +0000</pubDate>
		<dc:creator>Marcel Offermans</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[buglabs]]></category>
		<category><![CDATA[hardware]]></category>
		<category><![CDATA[LEGO]]></category>
		<category><![CDATA[OSGi]]></category>
		<category><![CDATA[smartservices]]></category>

		<guid isPermaLink="false">http://lsd.luminis.net/?p=174</guid>
		<description><![CDATA[<img class="thumbnail" src="http://blog.luminis.nl/roller/luminis/resource/marrs/buglabs.png" />
<p>What a great way to start the new year. A cool and shiny box with a Bug inside. This must be one of the coolest gadgets around. Thanks a lot, BugLabs!</p>]]></description>
			<content:encoded><![CDATA[<p>First of all, happy new year! I&#8217;m sure 2009 will be a great year for everybody.</p>
<p>Today, the long anticipated Bug arrived in the mail. I met Ken almost a year ago now, at EclipseCon, where he did a very nice demo of a new device. Call it LEGO for adults. The box contains hotpluggable hardware modules, such as motion sensors, a touch screen, a GPS locator, a generic I/O board for custom extensions which makes the hardware as dynamic as the software inside. That software, of course, is OSGi based, so there is full modularity there too. Add a well designed SDK for developing and deploying bundles for the system and you have a system that is very appealing to developers and can be used for all kinds of technology demos. Today&#8217;s blog ends with a nice picture of the opened box, showing some of the goodies inside. Expect more in depth articles in the near future!</p>
<p><img src="http://blog.luminis.nl/roller/luminis/resource/marrs/bugbox.png" /></p>
]]></content:encoded>
			<wfw:commentRss>http://lsd.luminis.nl/unboxing-the-bug/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
