<?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>All the small things &#187; Componentization</title>
	<atom:link href="http://osgi.mjahn.net/category/componentization/feed/" rel="self" type="application/rss+xml" />
	<link>http://osgi.mjahn.net</link>
	<description>A blog about OSGi, software architecture, componentization and everything else, I consider worth writing about.</description>
	<lastBuildDate>Tue, 11 May 2010 02:39:48 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Is there a future for software versioning?</title>
		<link>http://osgi.mjahn.net/2009/12/15/is-there-a-future-for-software-versioning/</link>
		<comments>http://osgi.mjahn.net/2009/12/15/is-there-a-future-for-software-versioning/#comments</comments>
		<pubDate>Tue, 15 Dec 2009 00:42:24 +0000</pubDate>
		<dc:creator>Mirko Jahn</dc:creator>
				<category><![CDATA[Componentization]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[OSGi]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://osgi.mjahn.net/?p=184</guid>
		<description><![CDATA[Versioning in software is as old as software itself. So, one should assume we are able to handle versions pretty good right? Well, you can&#8217;t be more wrong. Versions at the moment &#8211; and this holds true for ALL programming languages and concepts I know off &#8211; haven&#8217;t even remotely been done right till now. [...]]]></description>
			<content:encoded><![CDATA[<p>Versioning in software is as old as software itself. So, one should assume we are able to handle versions pretty good right? Well, you can&#8217;t be more wrong. Versions at the moment &#8211; and this holds true for ALL programming languages and concepts I know off &#8211; haven&#8217;t even remotely been done right till now. You ask why? Well, that&#8217;s easy to explain&#8230;</p>
<p>Currently, versions can only be considered as simple timestamps with a sophisticated syntax. You might be able to read intentions from the provider but further than that they are useless. The syntax of a version theme might indicate some sort of intend to express compatibility, but in fact this is never enforced, so you can&#8217;t really trust it! You ALWAYS have to check it yourself (manually or with integration tests) to figure out if it really fulfills the contract. As a result you can only be sure to some extend that some bits changed, if the version got increased &#8211; what ever this means. For me, this is the ultimate problem with dynamism in applications. You can&#8217;t test all possible installation scenarios of your clients as soon as you open yourself to third parties. Someone will break your perfect little world, better anticipate it!</p>
<p>In OSGi, things get even harder from a testers perspective (and developer for that matter). As the only system, I know of, it defines a way to describe future versions a component (aka bundle) can be compatible against. For instance you can specify that you require a certain version of a package your module depends up-on. Therefore you just add the required dependency in your Manifest.mf file as a range:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">Import-Package: dictionary;version=&quot;[1.0.0,2.0.0)&quot;</pre></div></div>

<p>A typical usage scenario in OSGi might look like this:</p>
<div id="attachment_187" class="wp-caption aligncenter" style="width: 556px"><img class="size-full wp-image-187" title="osgi_design" src="http://osgi.mjahn.net/wp-content/uploads/2009/07/osgi_design.jpg" border="0" alt="OSGi dependency versioning" width="546" height="240" /><p class="wp-caption-text">OSGi dependency versioning</p></div>
<p>Here the dictionary &#8220;user&#8221; (cl.client) defines a usage dependency of the dictionary API (dictionary.api). As you can see, the dependency definition differs between a &#8220;user&#8221; and an &#8220;implementer&#8221;, because the implementer of the functionality (dictionary.impl) not only has to be binary compatible, but also source code compatible (like implementing a new method of an interface). Fortunately the OSGi allows to at least express such a dependency. The distinct version scheme of OSGi imposes a specific usage. If you&#8217;re not binary compatible bump up the major number, if you&#8217;re binary compatible bump the minor number. If you do bug fixing, not affecting the API go for the build number and last but not least, if you want to indicate a distinct notion like a release or an iteration, use the quantifier. That&#8217;s what it should look like:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">[major[.minor[.build[.quantifier]]]]&quot;</pre></div></div>

<p>You may think this is a need approach and you&#8217;re probably right. It is great compared to everything else we have right now. Unfortunately this is not the silver bullet. Not at all, but it is a scheme which is explicit and well defined to some extend. Someone reading this, will at least have an idea what the intention of the component author was.</p>
<p>Now, what is the catch. Plain simple, this versioning scheme is not enforced. Everyone can version their OSGi artifacts however they want. There is no enforcement whatsoever. When you go to any bundle repository, none of them are verified and frankly, I don&#8217;t know how they ever will be. Of course, we can go all fancy and do API checks as Eclipse[1] does (and by the way, which is doing a pretty good job so far) or use an approach introduced by Premek Brada[2] at the last OSGi DevCon in Zurich. There is even the possibility to rerun all the former unit tests of a bundle that should be compatible with the latest version to check for semantic inconsistencies, but who is doing this and who guarantees that this covers all edge cases? No one can! Well, at least yet. Maybe in some years with fancy self learning AI on quantum computers, but for now we have to stick what we got.</p>
<p>I understand, my post is quite dark and negative up to now &#8211; nothing will work, we will ultimately fail, software reuse as the epic fail, blah blah blah. It&#8217;s true, we are not going to be a 100% perfect, but maybe, we don&#8217;t need to. Maybe we should just take what we got and try to make the best out of it. Evolve slowly but consistently and fail gracefully&#8230;</p>
<p>For one, testing is inevitable. For instance take the small and innocent build number that indicates just a bugfix. Now what is a bugfix? It can be a performance improvement &#8211; ok, that fine. It can also be a miscalculation or returning true instead of false in some odd case. When developing against such an behavior it is certainly not a compatible change, when you expect such a behavior and it gets fixed in a build number increased release. On the other hand, bumping the major number, because it in fact affects the client is a pretty heavy step, rendering all users incompatible unless they bump the version range to a higher number. The only thing in my opinion is creating test code to check if this behavior continues to be there and implement ways in your code to handle the fact that at some point it is different. This is painful, but there will always be this one edge case screwing with you.</p>
<p>Another thing we can do is rethinking of the actual version scheme. For one, this bump in the minor or major version, does it actually affect the implementer of the API? Well, not necessarily &#8211; not in all cases. So why do we start from 0 every time a higher number gets increased? Aren&#8217;t they distinct from each other? Well, maybe they have to get increased by one, but why reset them back to zero?</p>
<blockquote><p>2.4.2 becomes 3.5.3 or 3.4.2 instead of 3.0.0.</p></blockquote>
<p>The same holds true to version ranges. Why is the consumer in charge of defining the range? Ultimately, the provider knows what version the current library is still compatible with (from a client point of view). Now, having both, the client and provider version range can allow for a very flexible system.</p>
<div class="wp-caption alignnone" style="width: 495px"><img title="Inverse Versioning" src="http://osgi.mjahn.net/wp-content/uploads/2009/12/inverse_versioning.jpg" alt="Inverse Versioning" width="485" height="167" /><p class="wp-caption-text">Inverse Versioning</p></div>
<p>Last but not least, the ranges we&#8217;re defining, if a version segment gets increased independently from each other, as explained before, should version ranges then incorporate this as well? Allowing ranges on all version segments, not only as a whole?</p>
<div class="wp-caption alignnone" style="width: 544px"><img title="Inverse versioning with distinct version segments" src="http://osgi.mjahn.net/wp-content/uploads/2009/12/inverse+range_versioning.jpg" alt="Inverse versioning with distinct version segments" width="534" height="212" /><p class="wp-caption-text">Inverse versioning with distinct version segments</p></div>
<p>I know, I am describing a maintenance nightmare. How could one stay sane with so many variants? Short answer, humans can&#8217;t! Fortunately, there are tools and best practices that can help. With tooling you can get the version right you can depend upon. This is already done. With approaches like running old unit tests against the new API that specifically aim at the API level can verify the (most) of the behavior didn&#8217;t change. It is not easy &#8211; no doubt, but it is a chance we should take. At least when we want to get to a point where we actually can reuse 3rd party components.</p>
<p>Truth to be told, most of the things I said are just idea&#8217;s I picked up over the last few years and there is currently a lot of discussion going on.</p>
<ul>
<li>Peter Kriens: <a title="external: Peter Kriens on Versions" href="http://www.osgi.org/blog/2009/12/versions.html" target="_blank">http://www.osgi.org/blog/2009/12/versions.html</a></li>
<li>Chris Aniszczyk: <a title="external: Chris Aniszczyk on Jigsaw Versioning is Ridiculous" href="http://aniszczyk.org/2009/11/23/jigsaw-versioning-is-ridiculous/" target="_blank">http://aniszczyk.org/2009/11/23/jigsaw-versioning-is-ridiculous/</a></li>
<li>Neil Bartlett: <a title="external: Neil Bartlet on Reasons Not to Mourn JSR 294" href="http://neilbartlett.name/blog/2009/12/11/reasons-not-to-mourn-jsr-294/" target="_blank">http://neilbartlett.name/blog/2009/12/11/reasons-not-to-mourn-jsr-294/</a></li>
<li>&#8220;Sun&#8221; Versioning: <a title="external: Packaging Best Practices - Versioning" href="http://wikis.sun.com/display/IpsBestPractices/Packaging+Best+Practices+-+Versioning" target="_blank">http://wikis.sun.com/display/IpsBestPractices/Packaging+Best+Practices+-+Versioning</a></li>
<li>Alex Blewitt: <a title="external: Alex Blewitt on Version numbers and JSR277" href="http://alblue.blogspot.com/2008/05/version-numbers-and-jsr277.html" target="_blank">http://alblue.blogspot.com/2008/05/version-numbers-and-jsr277.html</a> and <a title="external: Alex Blewitt on JSR294 is dead, long live OSGi!" rel="nofollow" href="http://alblue.blogspot.com/2009/12/jsr294-is-dead-long-live-osgi.html" target="_blank">http://alblue.blogspot.com/2009/12/jsr294-is-dead-long-live-osgi.html</a></li>
<li>Mirko Jahn (myself &#8211; sorry): <a title="external: Referencing myself is lame, I know, but the comments are important enough to justify that I hope!" href="http://osgi.mjahn.net/2009/04/02/the-myth-of-software-reuse/" target="_blank">http://osgi.mjahn.net/2009/04/02/the-myth-of-software-reuse/</a></li>
</ul>
<p>If you want to get a full picture, I urge you to read through all of those sources, because ultimately, the worst thing we can do is redoing the mistakes of our past!</p>
<p>Cheers,<br />
Mirko</p>
<p>References:</p>
<p>[1] PDE API Tools: <a title="PDE API Tools" href="http://www.eclipse.org/pde/pde-api-tools/">http://www.eclipse.org/pde/pde-api-tools/</a><br />
[2] Safe Bundle Updates: <a title="external: Safe Bundle Updates" href="http://www.slideshare.net/pbrada/safe-bundle-updates" target="_blank">http://www.slideshare.net/pbrada/safe-bundle-updates</a></p>
<p>Update[1]: I added the links Alex mentioned. I certainly read his blog, which eventually influenced me as well. None of these concepts are coming from me personally unfortunately. I can&#8217;t take any credit for it.  Sorry for not giving you the credit you deserved in the first place, Alex. Btw., the order is arbitrary coming from the top of my head. No semantics are applied whatsoever! I hope I haven&#8217;t forgotten someone else as well!</p>
]]></content:encoded>
			<wfw:commentRss>http://osgi.mjahn.net/2009/12/15/is-there-a-future-for-software-versioning/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>OSGi vs. Jigsaw &#8211; Why can&#8217;t we TALK?</title>
		<link>http://osgi.mjahn.net/2009/07/01/osgi-vs-jigsaw-why-cant-we-talk/</link>
		<comments>http://osgi.mjahn.net/2009/07/01/osgi-vs-jigsaw-why-cant-we-talk/#comments</comments>
		<pubDate>Wed, 01 Jul 2009 02:01:48 +0000</pubDate>
		<dc:creator>Mirko Jahn</dc:creator>
				<category><![CDATA[Componentization]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[OSGi]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://osgi.mjahn.net/?p=164</guid>
		<description><![CDATA[Before starting, I just want to make clear that I am not a member of the OSGi Alliance nor a participant of any EG. I just happen to use OSGi since Eclipse started to investigate OSGi as their componentization model in its core. Since then I got more and more attached to OSGi and I [...]]]></description>
			<content:encoded><![CDATA[<p>Before starting, I just want to make clear that I am not a member of the OSGi Alliance nor a participant of any EG. I just happen to use OSGi since Eclipse started to investigate OSGi as their componentization model in its core. Since then I got more and more attached to OSGi and I don&#8217;t want to give up any of its features, so I guess you can call me a fanboy if you like. Of course, I am following the dispute between OSGi and Jigsaw since project Jigsaw was announced and I have to admit, that I was and am not happy with the approach Sun was taking not using a JSR and hoping to establish a modularization standard beyond the JVM. I already expressed my feelings in an older blog post called [<a title="internal: Componentization Wars Part II" href="http://osgi.mjahn.net/2008/12/04/componentization-wars-part-ii-guerrilla-tactics/" target="_blank">Componentization Wars Part II</a>]. Anyway, I guess there are some things I can&#8217;t change, so I&#8217;ll try my best to at least help the Jigsaw community to benefit from my experiences with OSGi and hope the input will help to create a better system (we all can benefit from). At the end only the quality of the technology should count and we should all work together to progress. So please consider the rest of this post as  my humble contribution. Take it or leave it,  it&#8217;s just an offer.</p>
<p>I thought a lot about the resistance of parts of the Java community in reusing the OSGi standard and starting from what we already have and in my conclusion the problem is two fold. First, it has come from a source outside the JSR initially. Well, I know this is debatable, because OSGi was one of the first JSRs and now with JSR 291 it in fact is one, but it is not &#8220;developed&#8221; within the JSR process, so one can say this is a valid point. Second modularization is in fact a tough call. When looking around, there is no other language or standard (even beyond Java itself) that has entirely tackled the problem and boy since David Parna&#8217;s introduction of the concept of modularity in 1972 quite some time has passed. A &#8220;fan&#8221; or not one has to admit that OSGi has already has gained a name in terms of modularizing the JVM and looking at the time required, well it took over 10 years to get that far. So I think it is fair to say that modularization is not easy to accomplish and to get right. In fact I had my problems (and partially still have) with OSGi as well. Let me explain&#8230;</p>
<p><strong>My first contact with OSGi</strong></p>
<p>When I first encountered OSGi I was working at IBM Research trying to explore ways to improve the modularization approach of [<a title="external: Apache UIMA Website" href="http://incubator.apache.org/uima/" target="_blank">UIMA</a>]. UIMA itself already had the notion of components or modules if you prefer already, but in a way it left certain features to get improved. In particular the isolation of each module wasn&#8217;t enforced, so introducing 3rd party modules into the runtime was a risky business. Especially when giving the fact that these modules had access to basically all resources. You never know what they are using or how they behave in the system. That, for instance was a reason to separate the processing into an other Java process. If that one fails, not the entire system is affected. OSGi in this context wasn&#8217;t THE savior, but it helped to make it more robust. No Java based model can provide real isolation of modules on JVM level (without the need to create a separate JVM instance is still something entirely missing in Java &#8211; one can ALWAYS create an OutOfMemoryError if he or she intends to). The great benefit of OSGi was simple. Hiding internal APIs, making dependencies explicit and potentially create a repository of reusable artifacts being usable without pages of manuals describing on how to set-up a system suitable for these modules.</p>
<p><strong>How OSGi is received (on first encounter)</strong></p>
<p>As you may imagine, one of the most important goals was to hide OSGi as much as possible. No services, no Import-Package (but Require-Bundle on one aggregation bundle), basically reduce OSGi to its minimum. Well, the appreciation was&#8230; limited. All people I was working with were exceptional bright and determined researchers in MLP. They developed highly sophisticated algorithms on how to analyze unstructured data, but only a few were software engineers. So the code was&#8230; working, but not production ready. Enforcing them to apply rules that ultimately made it harder for them getting things done and as a result slowing them down wasn&#8217;t something they welcomed very much. This is something I can totally understand and relate to! What is a system worth, if you don&#8217;t gain anything! Well, the problem here is that they didn&#8217;t gain anything, because they just used their code and to a limited extend the code of others, so the overhead of integrating with others was rather limited. The real benefit is visible when you start reusing multiple artifacts and potentially in different versions. This is something we (as a community) are trying to achieve for decades but failed so far, if you ask me.</p>
<p><strong>Some reflections about our history</strong></p>
<p>Looking at the history of Java it feels like it is a common problem. One tends to address the immediate problems. In principle there is nothing wrong with that, but in often after introducing a new standard you realize that the actual problem is way more complicated or you haven&#8217;t anticipated all vital use cases and the trivial approach looking so attractive at the beginning won&#8217;t work in the long run. The problem then is only that you don&#8217;t want to brake backwards compatibility and eventually this will drive the design of your solution, ultimately removing many otherwise possible ways to go. Talking about history, when we look back, jars where introduced as a distribution format for applets. Surely solving the immediate problem. After a while, Java on the server emerges and yet another problem arose. Separation of different web applications. Well, we know how it ended, eventually we got different class loading solutions for each J2EE vendor, because this part of the specification was left out.</p>
<p><strong>My point is&#8230;</strong></p>
<p>Now we have Jigsaw addressing a subset of OSGi&#8217;s modularization capabilities, which by itself is perfectly fine (even if it is not OSGi what they are going to use). The problem I fear is only that soon there will be more requirements altering the current approach unfitting. In particular, the great benefit of modules should be to be able to reuse them, without the need to understand all their internals. It was stated that OSGi&#8217;s restrictive class loading approach is not suitable for many applications. I tend to agree. I experienced this pain and it wasn&#8217;t pleasant. I heard that not allowing split packages is not acceptable, because it is a necessity. Why? Is it, because it is a good design or just because current systems are using it? If you want to create modules, you want to make them robust, so except for the exposed (public) API, it shouldn&#8217;t matter how it is implemented. If modules are not enforced to have their own class loader, you can never be sure whether or not you&#8217;ll have collisions. Yes, this is a pain in the **** to rethink and rewrite existing code! And I also have better things to do, than to retrofit some working libraries &#8211; no doubt! The question we should ask ourselves however is what do we really want? A system seamlessly integrating with existing code or provide a new way of thinking which might not be as simple as hoped, but give us what we need in the long run? Do we want reusable entities or a better provisioning system as plain jars? Don&#8217;t get me wrong here, I am not saying OSGi is the solution or should be used at all! Just saying that the requirements are dictating what you should get and if you intend to create &#8220;real&#8221; modules, the lessons OSGi learned are most valuable, even if you are eventually taking a completely different approach. In fact it has its short comings and flaws as any other system has.</p>
<p><strong>OSGi is not perfect either<br />
</strong></p>
<p>Working with OSGi for a while, I came across several places, where I noticed the need for improvement. For instance, OSGi provides a pretty strict module system, which when running is well defined. Unfortunately, there is a problem with how to get to this state or even knowing when this state is achieved. The idea behind its model is that using services, there should not be any dependency on the start order, because everything can change at any time. This is a nice idea, but in real world it is impossible to achieve. For instance, I am currently working with embedded devices and due to the limited hardware the  start-up can take minutes. Based on the dynamics however, a user might already see a web interface popping up, which seems perfectly usable. However, when using OSGi&#8217;s ConfigAdmin service to gather all configured configurations, it can happen that not yet started bundles don&#8217;t provide the required information, so the resulting configuration is incomplete. Similar things apply to the start order (no start levels are not sufficient) when using security. It is just not standardized how to ensure that certain bundles have to be loaded before everything else in order to start a particular runtime with security on. OSGi limits itself to define the runtime behavior, leaving out configuration issues when moving from one container to another. Basically the configuration for the start levels of each bundle getting loaded is an implementation detail &#8211; doesn&#8217;t this look familiar to you when using JEE <img src='http://osgi.mjahn.net/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> . Also providing tools to inspect the runtime behavior (how the container resolves dependencies is not sufficiently defined, so you have to jump through a lot of hoops or use implementation details of a particular implementation. Not really helpful/desirable from a tooling provider perspective. I could go one and on, like with every other technology. Work in progress is written over everyone of them. So, you see, there is so much that can still be done to improve our situation. No one is perfect and will ever be. We can just try to do our best to progress and learn from our faults.</p>
<p><strong>Properties of a true module system</strong></p>
<p>Well, after talking so much about what&#8217;s not right and what can be improved, I guess it is just fair to also draw a rough picture of a system providing the features of true &#8211; meaning reusable &#8211; modules. To help me out a little, I took the liberty in quoting one of the experts of componentization/modularization (which is not quite the same). Clemens Szyperski is currently working for Microsoft (I think) and so has no real relation to Java at all, but his observations and remarks hold true even in our space.</p>
<blockquote><p>„A software component is a unit of composition with contractually specified interfaces and explicit context dependencies only. A software component can be deployed independently and is subject to composition by third parties.“ [Szyperski et. al. 2002, p.41]</p></blockquote>
<p>&#8230; and a more brief definition of required properties.</p>
<blockquote><p>„The characteristic properties of a component are that it:<br />
• is a unit of independent deployment;<br />
• is a unit of third-party composition;<br />
• has no (externally) observable state.“ [Szyperski et. al. 2002, p.36]</p></blockquote>
<p>I think this sets the floor for more further investigations. In particular, the citations above are nice, but pretty vague and open to interpretation. For instance, what is &#8220;independent&#8221; when we&#8217;re talking about deployment? What does composition mean in this context? Is it just a descriptor, is it a zip or rpm file containing everything? I don&#8217;t know and it doesn&#8217;t actually matter I think. What matters is that the resulting system is compelling, concise and valid within itself. Of course, some features seem better than others, but we also need freedom to explore new ways of thinking.</p>
<p>So while thinking about the core features of a (potentially) new module system, for me I identify the following as most important:</p>
<ul>
<li>Isolation:  When talking about isolation, I am basically talking about trust. Having a module system defining an isolation on module level (which currently can only achieved by having a custom class loader), gives me as the module designer the trust that I can create something without the fear of breaking something on the user side, just because of an implementation detail that is not part of the public API.I can trust that when I have the isolation on module level, I know what will have to deal with. As they say: Good fences make for good neighbors.</li>
<li>Information hiding: Yes this is as old as it can get in software engineering, but this is the most critical part in so many ways. First of all, I understand modules as a way of abstraction. Zoom out of the implementation details and just focus on the API. That&#8217;s what I want! Black Boxes, only with interfaces (or maybe factories visible). Of course, API contracts purely defined in Java Interfaces are not precise enough to provide all required information (like ranges, value lists, limits,&#8230;), but is a starting point. The right documentation should or for now has to do the rest.</li>
<li>Enabling reuse: Currently the silver bullet to decouple is dependency injection. Although a great way of doing so, it is not enforced. Anyone can just programmatically wire up classes. As a result you get bound to an implementation, which again makes reuse and updates way harder. If I know I have to use a certain API, I usually don&#8217;t care who is providing the implementation and that&#8217;s key for every robust system.</li>
<li>Predictability: Well, usually even in JEE we assume we know how an application will behave, once deployed, but in reality, it is just not true. Resolution is based on the class path which can contain, depending on where you deploy your application, basically any classes and libraries. Now you have many not easy to manage factors affecting what gets loaded when. For instance there can be multiple logging frameworks in different versions pressent interfeering with the one provided by your application. Depending when they are found in the class path, they might cause problems or not. A deterministic system, that declaratively defines its dependencies will only see the required ones. Everything else is just hidden and serve other applications if they need it &#8211; no interference with each other!</li>
<li>flexible binding, yet safe binding: This is something increasingly important and also not accomplished satisfyingly by any module system I know of &#8211; so far. Basically what one wants is to create an application based on the dependencies known and being able to fix later in time appearing problems without the need to redeploy and change the whole application. For instance if a security vulnerability in one module is detected. The latest version should be deployable and tell the runtime that it is a fixed version of some of the existing ones within the runtime, so those versions can be replaced.</li>
<li>robustness: Currently no in-JVM approach can guarantee any runtime behavior like the consumed memory or the allocated cpu cycles. If you get a malicious module, it can bring down the entire JVM. There are already research projects out there providing such features, so in theory it should be possible to achieve this on JVM level.</li>
</ul>
<p>Of course, there is more, but I think the list is contains the most important parts. You might have noticed, there is no mentioning of OSGi or the way OSGi is doing it. I believe there is always more than one way to accomplish your goals, so maybe the OSGi community overlooked a possibility &#8211; I honestly don&#8217;t know. So if you&#8217;re able to come up with any solution that fulfills these requirements, I would be more than happy. Maybe and only maybe you can consider looking at some of the approaches the OSGi was taking to tackle parts of these problems.</p>
<p>Yours,<br />
Mirko</p>
<p><strong>References:</strong></p>
<p>[UIMA]: <a title="external: Apache UIMA Website" href="http://incubator.apache.org/uima/" target="_blank">http://incubator.apache.org/uima/</a><br />
[Componentization Wars Part II]: <a title="internal: Componentization Wars Part II" href="http://osgi.mjahn.net/2008/12/04/componentization-wars-part-ii-guerrilla-tactics/" target="_blank">http://osgi.mjahn.net/2008/12/04/componentization-wars-part-ii-guerrilla-tactics/<br />
</a>[dmeuima]: <a title="external: DME-UIMA" href="http://www.alphaworks.ibm.com/tech/dmeuima/" target="_blank">http://www.alphaworks.ibm.com/tech/dmeuima/</a><br />
[Szyperski et. al. 2002]: Szyperski, Clemens ; Gruntz, Dominik ; Murer, Stephan: Component Software. Beyond Object-Oriented Programming. Addison-Wesley Professional, 2002 – ISBN 0201745720</p>
]]></content:encoded>
			<wfw:commentRss>http://osgi.mjahn.net/2009/07/01/osgi-vs-jigsaw-why-cant-we-talk/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>The Quest for Software Reuse</title>
		<link>http://osgi.mjahn.net/2009/04/23/the-quest-for-software-reuse/</link>
		<comments>http://osgi.mjahn.net/2009/04/23/the-quest-for-software-reuse/#comments</comments>
		<pubDate>Thu, 23 Apr 2009 11:02:50 +0000</pubDate>
		<dc:creator>Mirko Jahn</dc:creator>
				<category><![CDATA[Componentization]]></category>
		<category><![CDATA[OSGi]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[maven]]></category>
		<category><![CDATA[modul]]></category>
		<category><![CDATA[platform]]></category>
		<category><![CDATA[repositories]]></category>
		<category><![CDATA[software product line]]></category>
		<category><![CDATA[software reuse]]></category>
		<category><![CDATA[standard]]></category>

		<guid isPermaLink="false">http://osgi.mjahn.net/?p=144</guid>
		<description><![CDATA[Inspired by Peter&#8217;s comment I am following up on my last post on &#8220;The Myth about Software Reuse&#8221;. I received quiet a lot feedback concerning the topic and I felt I should share some of my thoughts and visions in order to answer some of the questions and destroy the concerns I may have provoked.
In [...]]]></description>
			<content:encoded><![CDATA[<p>Inspired by Peter&#8217;s comment I am following up on my <a title="[internal]: The myth of software reuse" href="http://osgi.mjahn.net/2009/04/02/the-myth-of-software-reuse/" target="_blank">last post</a> on &#8220;The Myth about Software Reuse&#8221;. I received quiet a lot feedback concerning the topic and I felt I should share some of my thoughts and visions in order to answer some of the questions and destroy the concerns I may have provoked.</p>
<p>In my last post I concluded that OSGi has all the features necessary to create great and reusable artifacts/ bundles if you prefer. As Richard pointed out it is THE technology, if you&#8217;re trying to build modular applications and if done right even reusable modules. The only flaw here is the &#8220;if done right&#8221; part. People do mistakes, I do it all the time and I bet you are doing it too. It&#8217;s in our nature, we can&#8217;t help it. Unfortunately when talking about mistakes in the context of reusable artifacts the implications can be disastrous.  Having a faulty versioned artifact and you rely on its correctness it will most certainly break some functionality or even the whole application. OSGi by itself doesn&#8217;t either enforce any constraints on versioning your bundles nor does it give you a detailed guideline on doing so (neither does Java). This is the reason, why the the folks from <a title="external: LinkedIn blog about their OSGi usage" href="http://blog.linkedin.com/2009/02/17/osgi-at-linkedin-bundle-repositories/" target="_blank">LinkedIn</a> choose to only rely on one distinct version in their dependencies &#8211; the safest call for sure. If there are no rules, you check for them or predict the behavior of future bundles. Everything is custom made. This vacuum of  control renders bundles unpredictable in their versioning behavior and almost impossible to use in a forward compatible way usually applied when talking about Software Product Lines for instance.</p>
<p>If you will, one can say that the lack of control is the root of our problem &#8211; enforce control end everything falls into part, right? Unfortunately control is a two bladed sword. On the one hand you have a controlled environment where you exactly know what is going on and what to expect, on the other hand it limits your possibilities and hinders exploring new ways of thinking. Especially if you feel like not having enough information/knowledge about  the problem domain this is the ultimate killer criteria for progress &#8211; no exactly what we desire. Picking up Peters comment from my last blog post, this holds pretty much true for versioning policies in OSGi so far &#8211; we just don&#8217;t know enough yet. However, I gave it some thought and I think there is a way around this problem. Hold on a bit and I&#8217;ll explain what I am thinking.</p>
<p>The core of the problem from my point of view is the way we receive our dependencies. Being a good OSGi citizen one should use packages to express dependencies of course, but that&#8217;s just one part of the story. The other one are the bundles contributing these dependencies. As mentioned in my previous post, there are multiple repositories for 3rd party bundles one can use (like  [<a title="external: The Spring bundle repository" href="http://www.springsource.com/repository/app/" target="_blank">spring-repo</a>], [<a title="external: The Eclipse bundle repository" href="http://www.eclipse.org/orbit/" target="_blank">orbit-repo</a>] or [<a title="external: The OSGi bundle repository" href="http://www.osgi.org/Repository/HomePage" target="_blank">osgi-repo</a>]). The problem here however is that one has no guaranties on what you&#8217;re getting from there. Of course you get the source you require &#8211; hopefully, but not necessarily the correct meta data you are looking for or even worse are requiring (see <a title="[external]: Bundlor bug report" href="https://issuetracker.springsource.com/browse/BNDLR-196" target="_blank">bundlor bug report</a> for instance). The core problem here is specifying versions and version ranges in particular. There are no fixed rules and as Peter stated in my previous post it is a field that needs more exploration, which I can&#8217;t agree more. However, I think there is a way to satisfy the need for room of further exploration as well as accomplish the need for more control &#8211; the issue with the two bladed sword, I was talking about earlier. Let me elaborate on this a little bit more&#8230;</p>
<p>In my opinion, all we need is actually a repository we can trust. Trust in that sense, that we know for certain that the artifacts provided are following certain rules. The rules however shouldn&#8217;t be set in a hard coded/wired way, so that the rules can evolve and provide extra information while we evolve in understanding the topic. Another important feature (for me at least) is the &#8220;not lock in&#8221; option. I don&#8217;t want to lock myself into some vendor specific rules, if I don&#8217;t have to or don&#8217;t agree on them. It would be nice, if certain vendors provide me with some of their artifacts, but ultimately I want to be in control of what is going into my application and how.</p>
<p>Now, I think all this (and even more) can be accomplished with the right repository design. The OSGi is currently working on their <a title="external: Hal Hildebrand on the OSGi Bundle Repository aka RFP 122" href="http://www.tensegrity.hellblazer.com/2009/03/osgi-rfp-122---the-osgi-bundle-repository.html" target="_blank">RFP 122</a> for repositories and as far as I can tell this would be a great opportunity to consider the following additions.</p>
<p>Imagine while uploading artifacts to the repository one can also provide additional meta data and go through a verification process where certain features are tested. For instance, assuming a base version is already at present, the provider can check what actually changed between the last and the current version. Assuming there are certain rules deployed to check for API changes, the one uploading/providing the artifact can be guided through a process where he can assign the correct version information. This goes so far that not only the exported packages can be checked but also the version ranges of the imports, because all artifacts known to the repository are going through the same process (assuming a proper base-lining of course). So what could these checks be?</p>
<ul>
<li>check for the minimal version to apply for an exported package (ensuring API breaks are assigned to a major version increase f.i.). Of course semantic changes can&#8217;t be picked up, but here the human interaction comes into play.</li>
<li>check the smallest possible matching version for a package import known to the repository to ensure maximal compatibility. Again, human interaction or API test cases can assist for semantic incompatibilities.</li>
<li>multiple exporters of the same package can be identified and if appropriate an optional property like the provider, purpose, etc. can be added to make a provider selection possible.</li>
<li>even errors, like missing import statements can be detected here.</li>
</ul>
<p>Now, after having checked for these and potentially other things, the bundle can be altered to contain the defined meta data. It can even be signed and express its validity by complying to these &#8220;rules&#8221;. The resulting bundle can now be downloaded or stored on the server for further use.</p>
<p>Of course, this brings some more problems. First of all, not everyone wants to have its components uploaded to some server, so these information on how to alter the bundle can be used as transformation guidelines and the actual artifacts remain on another server (to protect IP for instance). The repository is so to speak just a proxy. On a request, it takes the bundle, alters it and provides it to the requester (if he has the correct access rights). Now, of course not every &#8220;jar&#8221; is allowed to be altered. We need to have some sort of proof that the uploader/provider is the author or has the rights to do so. I can think of many ways to do so, like verifying domain ownership or manual approval processes, but this will not be the topic of this post.</p>
<p>Another, very important problem is the hosting. One might not have the ability to use a open, freely available repository, because the bundles in question are commercial with protected IP. In that case an instance of this very repository must be available for local installation, so it can be used in companies as well. Of course chaining of those repositories must be possible as well. This brings me to the next point.</p>
<p>Rules valid for the whole world might not hold true for a certain company or even more important, while the knowledge about how to handle these reusable artifacts evolves and finer, more advanced checks become necessary or other languages should be supported as well, the verification process must be pluggable, updatable to ones (evolving) needs. With this we don&#8217;t have to buy into a solution that has to be correct forever. We can evolve while we&#8217;re going. Because the rules on how to alter the original bundle are stored, they can be changed, enhanced or removed at any time later if necessary. Of course, this can potentially cause other problems, but at least it would be possible.</p>
<p>Having this flexibility, of course one needs to know for certain, what one will receive when requesting an artifact. In fact one might even won&#8217;t to have only certain rules applied or a special set of rules only in &#8220;beta&#8221; mode available. This should also be possible with a distinct request API.</p>
<p>With the ability to change bundles on the fly, it is also possible to reuse existing infrastructures like maven repositories, obr or p2 for instance. A maven repository for instance can theoretically provide the meta data necessary to create the correct bundles by providing a rule-set in a distinct file as meta data. With something like this a maven repo can be used as a data source for the bundle repository. Pretty much the same hold true for any other repository I can think of.</p>
<p>The beauty of such a repository is that no one is forced to go with the main stream. Everyone can for their own bundles overwrite the default behavior in their own instances of repositories and f.i. limit the versions chosen to exactly one instead of a range. The central repository however enforces certain rules, so everyone can trust the output and alter it as needed. Even the decision if a bundle should be altered or if it can only be re-wrapped in a new bundle can be defined by a rule the bundle provider can define. You basically get all the freedom to do what you want locally and rely on common rules from the central repo.</p>
<p>There is even plenty of space for service providers making money by providing their own repositories with enterprise support. Porting the latest OSS libraries to the repo or ensuring test coverage of the released bundles, advanced checks to detect semantical changes are just a few possible enterprise features.</p>
<p>However, this is just the surface I scratched, there are so many more things I could add here, but I think you got the basic idea. The remaining question now is: Are we ready for something like this? Is there anyone interested in such a repository? Talking for me, I was looking for something similar quite a while and whenever I talked to someone about this, they agreed that it even has a business case worth spending money on. Don&#8217;t get me wrong. I don&#8217;t think this is the silver bullet &#8211; there is no such thing, but I believe it can be the basis to propel real software reuse and form a coalition between vendors and open source &#8211; a common standard with a tool-set capable of pushing us further.</p>
<p>Currently I am thinking about proposing a talk for the upcoming <a title="[external]: OSGi DevCon at the OSGi Homepage" href="http://www.osgi.org/DevConEurope2009/HomePage" target="_blank">OSGi DevCon</a> in Zurich and was wondering if someone would be interested in this topic as a talk, BOF or even just a bunch of people getting together while grabbing a beer. Me and my company are currently at a point where we are needing something like this and I would very much like to share my ideas and get some other views and experiences on this one. Let me know what you&#8217;re thinking!</p>
<p>Cheers,<br />
Mirko</p>
<p><strong>References (in chronological order):</strong></p>
<p>[last post]: http://osgi.mjahn.net/2009/04/02/<span id="editable-post-name" title="Click to edit this part of the permalink">the-myth-of-software-reuse</span>/<br />
[LinkedIn]: <a title="external: LinkedIn blog about their OSGi usage" href="http://blog.linkedin.com/2009/02/17/osgi-at-linkedin-bundle-repositories/" target="_blank">http://blog.linkedin.com/2009/02/17/osgi-at-linkedin-bundle-repositories/</a><br />
[spring-repo]: <a title="external: The Spring bundle repository" href="http://www.springsource.com/repository/app/" target="_blank">http://www.springsource.com/repository/app/</a><br />
[orbit-repo]: <a title="external: The Eclipse bundle repository" href="http://www.eclipse.org/orbit/" target="_blank">http://www.eclipse.org/orbit/</a><br />
[osgi-repo]: <a title="external: The OSGi bundle repository" href="http://www.osgi.org/Repository/HomePage" target="_blank">http://www.osgi.org/Repository/HomePage/<br />
</a>[bundlor bug report]: <a title="[external]: Bundlor bug report" href="https://issuetracker.springsource.com/browse/BNDLR-196" target="_blank">https://issuetracker.springsource.com/browse/BNDLR-196</a><br />
[RFP 122]: <a title="external: Hal Hildebrand on the OSGi Bundle Repository aka RFP 122" href="http://www.tensegrity.hellblazer.com/2009/03/osgi-rfp-122---the-osgi-bundle-repository.html" target="_blank">http://www.tensegrity.hellblazer.com/2009/03/osgi-rfp-122&#8212;the-osgi-bundle-repository.html<br />
</a>[OSGi DevCon]: <a title="external: Hal Hildebrand on the OSGi Bundle Repository aka RFP 122" href="http://www.tensegrity.hellblazer.com/2009/03/osgi-rfp-122---the-osgi-bundle-repository.html" target="_blank"></a><a title="[external]: OSGi DevCon at the OSGi Homepage" href="http://www.osgi.org/DevConEurope2009/HomePage" target="_blank">http://www.osgi.org/DevConEurope2009/HomePage</a></p>
]]></content:encoded>
			<wfw:commentRss>http://osgi.mjahn.net/2009/04/23/the-quest-for-software-reuse/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>The myth of software reuse</title>
		<link>http://osgi.mjahn.net/2009/04/02/the-myth-of-software-reuse/</link>
		<comments>http://osgi.mjahn.net/2009/04/02/the-myth-of-software-reuse/#comments</comments>
		<pubDate>Thu, 02 Apr 2009 02:24:38 +0000</pubDate>
		<dc:creator>Mirko Jahn</dc:creator>
				<category><![CDATA[Componentization]]></category>
		<category><![CDATA[OSGi]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[software product line]]></category>
		<category><![CDATA[software reuse]]></category>
		<category><![CDATA[versioning]]></category>

		<guid isPermaLink="false">http://osgi.mjahn.net/?p=117</guid>
		<description><![CDATA[
The ones of you who know me, know that I believe in software reuse and I am trying to evangelize about it for quiet some time. Methods, Classes, Aspects, Components, Modules, Software Product Lines, you name it &#8211; everything is focused on reuse to some extend. With OSGi for the first time we are able [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://osgi.mjahn.net/wp-content/uploads/2009/04/impossible-triangle-small.jpg"><img class="alignleft size-medium wp-image-133" style="border-width: 0px;" title="Is it real?" src="http://osgi.mjahn.net/wp-content/uploads/2009/04/impossible-triangle-small.jpg" alt="Are we fooling ourselves? Or is it real?" width="200" height="192" /></a></p>
<p>The ones of you who know me, know that I believe in software reuse and I am trying to evangelize about it for quiet some time. Methods, Classes, Aspects, Components, Modules, Software Product Lines, you name it &#8211; everything is focused on reuse to some extend. With <a title="external: OSGi Home page" href="http://www.osgi.org" target="_blank">OSGi</a> for the first time we are able to create true reusable software artifacts and theoretically mix and match them on an as needed basis. Great new opportunities are coming and with the recently held <a title="external: OSGi Tool Summit" href="http://www.osgi.org/Event/20090327" target="_blank">OSGi Tool Summit</a> chances are good that we&#8217;ll soon see more and better integrated tooling support in our daily work with OSGi. So, we all should be happy bees right?</p>
<p>Well, what we are producing right now is a massive amount of bundles, no question about this. Virtually everyone is now shipping with at least some basic OSGi headers. Several projects are trying to provide bundle repositories for the not (yet) converted projects (like [<a title="external: The Spring bundle repository" href="http://www.springsource.com/repository/app/" target="_blank">spring-repo</a>], [<a title="external: The Eclipse bundle repository" href="http://www.eclipse.org/orbit/" target="_blank">orbit-repo</a>], [<a title="external: The OSGi bundle repository" href="http://www.osgi.org/Repository/HomePage" target="_blank">osgi-repo</a>]) and some go even further and try to wrap incompatible APIs in a compatibility layer (see [<a title="external: DynamicJava.org Homepage" href="http://www.dynamicjava.org/projects/jsr-api" target="_blank">DynamicJava</a>] for instance). Great work and very much appreciated, but this is not the point. What we got so far are &#8220;just&#8221; explicit software artifacts. We only know what is behind bundle X in version Y, a subjectively taken SNAPSHOT somewhere in the infinity of time. It doesn&#8217;t answer the question on how this code can and will evolve or how future versions will fit into my universe.</p>
<p><strong>The problem domain</strong></p>
<p>Too abstract? Let&#8217;s examine an arbitrary example. Assuming you are trying to create a web application similar to <a title="external: Flickr Homepage" href="http://www.flickr.com/" target="_blank">flickr</a> but on some sort of an embedded device to use at home. Taking the state of the art tools, you might choose to develop your app with Spring DM or any other frameworks you like, take your pick. For now, we stick to this one. As a starter we use the following assets: <a title="external: Spring DM product page" href="http://www.springsource.org/osgi" target="_blank">Spring DM 1.1.3</a>, <a title="external: Spring download page" href="http://www.springsource.org/download/" target="_blank">Spring 2.5.6</a> and <a title="external: Maven 2 download page" href="http://maven.apache.org/download.html" target="_blank">Maven 2</a> as a built system. So far so good. Once you start developing you realize that you also need a file upload feature for your pictures. Of course someone already developed something to upload files and we are trying to reuse that stuff of course, so you look around. Soon, you&#8217;ll find <a title="external: Apache Commons Fileupload Homepage" href="http://commons.apache.org/fileupload/" target="_blank">commons-fileupload</a>. The spring guys are putting a lot of work into building up a repository of reusable osgi bundles in their bundle repository and we can just use the OSGi-ified version of it from here: [<a title="external: Apache Commons Fileupload on the Spring bundle repository" href="http://www.springsource.com/repository/app/bundle/version/detail?name=com.springsource.org.apache.commons.fileupload&amp;version=1.2.0" target="_blank">spring comFileUpload</a>], which is really great! But then you soon realize that you can&#8217;t use that version. Take a look at it&#8217;s (simplified) header:</p>

<div class="wp_syntax"><div class="code"><pre class="ini" style="font-family:monospace;">Manifest-Version: <span style="">1.0</span>
Bundle-ManifestVersion: <span style="">2</span>
Bundle-Name: Apache Commons File Upload
Bundle-Version: 1.2.0
Bundle-SymbolicName: com.springsource.org.apache.commons.fileupload
Bundle-Vendor: SpringSource
Export-Package: org.apache.commons.fileupload<span style="color: #666666; font-style: italic;">;version=&quot;1.2.0&quot;;</span>
  uses:<span style="color: #000066; font-weight:bold;">=</span><span style="color: #933;">&quot;javax.servlet.http&quot;</span>,
 org.apache.commons.fileupload.disk<span style="color: #666666; font-style: italic;">;version=&quot;1.2.0&quot;;</span>
  uses:<span style="color: #000066; font-weight:bold;">=</span><span style="color: #933;">&quot;org.apache.commons.fileupload&quot;</span>,
 org.apache.commons.fileupload.portlet<span style="color: #666666; font-style: italic;">;version=&quot;1.2.0&quot;;</span>
  uses:<span style="color: #000066; font-weight:bold;">=</span><span style="color: #933;">&quot;javax.portlet,org.apache.commons.fileupload&quot;</span>,
 org.apache.commons.fileupload.servlet<span style="color: #666666; font-style: italic;">;version=&quot;1.2.0&quot;;</span>
  uses:<span style="color: #000066; font-weight:bold;">=</span><span style="color: #933;">&quot;javax.servlet,javax.servlet.http,org.apache.commons.fileupload&quot;</span>,
 org.apache.commons.fileupload.util<span style="color: #666666; font-style: italic;">;version=&quot;1.2.0&quot;</span>
Import-Package: javax.servlet<span style="color: #666666; font-style: italic;">;version=&quot;[2.5.0, 3.0.0)&quot;,</span>
 javax.servlet.http<span style="color: #666666; font-style: italic;">;version=&quot;[2.5.0, 3.0.0)&quot;,</span>
 javax.portlet<span style="color: #666666; font-style: italic;">;version=&quot;[1.0.0, 2.0.0)&quot;;resolution:=optional,</span>
 org.apache.commons.io<span style="color: #666666; font-style: italic;">;version=&quot;[1.4.0, 2.0.0)&quot;,</span>
 org.apache.commons.io.output<span style="color: #666666; font-style: italic;">;version=&quot;[1.4.0, 2.0.0)&quot;</span></pre></div></div>

<p>As you can see, it requires to have the <a title="external: Sun Servlet Technologie Homepage" href="http://java.sun.com/products/servlet/" target="_blank">Servlet API</a> in version 2.5, which is not available in our case on the embedded device. What now? Well, if you know the bundle, you also know, that in fact it doesn&#8217;t require 2.5! You can re-bundle it and give the bundle another version and here is the problem. The Spring guys did a great work bundling this artifact for us, but they created it based on THEIR environment and not on the minimal requirements of that specific bundle. Even worse, there is not even a real specification stating what version to take and how to version changes correctly. Forward compatibility is just a beautiful dream rather than an actual fact. If you look at well known companies adapting OSGi like <a title="external: LinkedIn blog about their OSGi usage" href="http://blog.linkedin.com/2009/02/17/osgi-at-linkedin-bundle-repositories/" target="_blank">LinkedIn</a>, you&#8217;ll see what I mean. Where are we heading to when one is forced to define dependencies like this:</p>

<div class="wp_syntax"><div class="code"><pre class="ini" style="font-family:monospace;">Import-Package:
 com.linkedin.colorado.helloworld.api<span style="color: #666666; font-style: italic;">;version=”[1.0.0,1.0.1)”,</span>
 com.linkedin.colorado.helloworld.client<span style="color: #666666; font-style: italic;">;version=”[1.0.0,1.0.1)”,</span>
 org.osgi.framework<span style="color: #666666; font-style: italic;">;version=”[1.4.0,1.4.1)”</span></pre></div></div>

<p>Doesn&#8217;t this feel totally odd and just plain wrong? Shouldn&#8217;t we be able to trust the authors or &#8220;something else&#8221; to take care of compatibility issues? Someone who knows the code, its changes and its backwards compatibility better than we do? I don&#8217;t want to change all of my 200 bundles just because we have a new OSGi framework version that now provides a new final static property for instance, I am not using anyway! I want to express that I don&#8217;t care what changed in the provided bundle as long as my code still works as expected and I want to be sure that the provider has the exact same concept about &#8220;compatible code changes&#8221;.  The Eclipse community already realized this and created an API for <a title="external: DeveloperWorks on how to use Eclipse Baselining tools" href="http://www.ibm.com/developerworks/opensource/library/os-eclipse-api-tools/index.html" target="_blank">baselining</a> components and a <a title="external: Eclipse Versioning Schema" href="http://wiki.eclipse.org/Version_Numbering" target="_blank">version schema</a> to apply versions. Along with several detailed instructions on what to consider a change and how this change should be treated in terms of its version (<a title="external: Eclipse Versioning Guide Part I" href="http://wiki.eclipse.org/Evolving_Java-based_APIs" target="_blank">eclipse-vers1</a>, <a title="external: Eclipse Versioning Guide Part II" href="http://wiki.eclipse.org/Evolving_Java-based_APIs_2" target="_blank">eclipse-vers2</a>, <a title="external: Eclipse Versioning Guide Part III" href="http://wiki.eclipse.org/Evolving_Java-based_APIs_3" target="_blank">eclipse-vers3</a>), they have created the first usable guide on defining version numbers for bundles. However, this is just a small step towards reusable artifacts. We also need to agree on such rules and be able to enforce them. Unfortunately a lot of questions remain unanswered yet. For instance, what about semantical changes? How to treat them and more importantly, how to identify those? Code analysis won&#8217;t always help here.</p>
<p>So what do we learn from this? Basically that we can&#8217;t trust any bundle provided by a third party just yet. It doesn&#8217;t matter how good the providers intentions are on providing the perfect bundle. Right now, we are basically left alone. Every time we update to a new version it is like a game. You never know what you&#8217;ll be facing.</p>
<p><strong>Ok, we are screwed. Who to blame?</strong></p>
<p>Now you might ask yourself who&#8217;s fault is it? It is certainly not the Spring guys fault who provide us in this example with the software, but who to blame instead? The tools? Most people either use <a title="external: BND tool Homepage" href="http://www.aqute.biz/Code/Bnd" target="_blank">BND</a>, <a title="external: Eclipse Homepage" href="http://www.eclipse.org/" target="_blank">Eclipse </a>or the newly created <a title="external: Spring Bundlor Homepage" href="http://www.springsource.org/bundlor/" target="_blank">bundlor</a> from Spring. All of these are pretty dumb. They can&#8217;t possibly know, which version to take (although they are trying hard to guess). There is no baseline, no knowledge about the domain or infrastructure). Too many questions are unanswered and the tool authors are left alone, so I think the tools are the last ones to blame. OK, so what about the OSGi specification? It is so vaguely written, when it comes to versioning your bundles &#8211; you can&#8217;t possibly draw any universal conclusion what version to apply. Everyone can have their own interpretation of &#8220;compatible&#8221; changes, which is not compatible among each other. All true, but I don&#8217;t think that a simple specification will be enough nor is the OSGi suitable for that. The issue is too big to be solved by only one company or organization all by themselves. Sun might be the only one fitting, but after all the problems with <a title="external: JSR 277 Homepage" href="http://jcp.org/en/jsr/detail?id=277" target="_blank">JSR 277</a> and project <a title="internal: My view on project JigSaw and JSR 277" href="http://osgi.mjahn.net/2008/12/04/componentization-wars-part-ii-guerrilla-tactics/" target="_blank">JigSaw</a>, I have no convidence in their ability and willingness anymore. To be fair, one have to admit that the <a title="external: Java Language Specification" href="http://java.sun.com/docs/books/jls/third_edition/html/j3TOC.html" target="_blank">Java Language Specification</a> does provide a chapter about <a title="external: Java Language Specification - Binary-Compatibility chapter" href="http://java.sun.com/docs/books/jls/third_edition/html/binaryComp.html" target="_blank">binary compatibility</a>, but it is not much of a help, because not all cases are covered and there is of course no notion of a bundle (I would love to rant about not treating packages as 1st class citizen in Java, but that&#8217;s an entirely different post). Sun also has a <a title="external: Java Sig Test Tool" href="https://sigtest.dev.java.net/" target="_blank">sigtest</a> tool to check for API breaks, but with the given functionality it is pretty much worthless for what we need.</p>
<p><strong>What next?</strong></p>
<p>Is it the job of an external organization to define rules everyone has to apply while developing reusable artifacts for a specific language? I don&#8217;t think so. I think this should be the job of all of us. Maybe as a joint project, maybe umbrella&#8217;d by the JCP, I don&#8217;t no, but definitely as a open and community driven effort. I don&#8217;t wonna lock myself to any vendor or proprietary standard I might get stuck with. I dream of a central repository (maybe based on <a title="external: Hal Hildebrand on the OSGi Bundle Repository aka RFP 122" href="http://www.tensegrity.hellblazer.com/2009/03/osgi-rfp-122---the-osgi-bundle-repository.html" target="_blank">RFP 122</a>, maybe something completely different), where I have a one stop shop for all the 3rd party artifacts I need. At the same time being able to do in-house development with the same reliable system not having to expose anything to the outside world. Open, reliable and trustworthy software with a healthy community of open source artifacts &#8211; does it have to be a dream or can we make it real? I already have ideas how this can come true, but I would be very much interested if you&#8217;re feeling the same or even having concrete projects concerning something similar I haven&#8217;t reference here? Is there a potential for collaboration? What do you think?</p>
<p>My 2 cents,<br />
Mirko</p>
<p><strong>References (in chronological order):</strong></p>
<p>[OSGi]: <a title="external: OSGi Home page" href="http://www.osgi.org" target="_blank">http://www.osgi.org/</a><br />
[OSGi Tool Summit]: <a title="external: OSGi Tool Summit" href="http://www.osgi.org/Event/20090327" target="_blank">http://www.osgi.org/Event/20090327/</a><br />
[spring-repo]: <a title="external: The Spring bundle repository" href="http://www.springsource.com/repository/app/" target="_blank">http://www.springsource.com/repository/app/</a><br />
[orbit-repo]: <a title="external: The Eclipse bundle repository" href="http://www.eclipse.org/orbit/" target="_blank">http://www.eclipse.org/orbit/</a><br />
[osgi-repo]:  <a title="external: The OSGi bundle repository" href="http://www.osgi.org/Repository/HomePage" target="_blank">http://www.osgi.org/Repository/HomePage/<br />
</a> [DynamicJava]: <a title="external: DynamicJava.org Homepage" href="http://www.dynamicjava.org/projects/jsr-api" target="_blank">http://www.dynamicjava.org/projects/jsr-api/</a><br />
[Flickr]: <a title="external: Flickr Homepage" href="http://www.flickr.com/" target="_blank">http://www.flickr.com/</a><br />
[Spring DM 1.1.3]: <a title="external: Spring DM product page" href="http://www.springsource.org/osgi/" target="_blank">http://www.springsource.org/osgi/</a><br />
[Spring 2.5.6]: <a title="external: Spring download page" href="http://www.springsource.org/download/" target="_blank">http://www.springsource.org/download</a>/<br />
[Maven 2]: <a title="external: Maven 2 download page" href="http://maven.apache.org/download.html" target="_blank">http://maven.apache.org/download.html</a><br />
[commons-fileupload]: <a title="external: Apache Commons Fileupload Homepage" href="http://commons.apache.org/fileupload/" target="_blank">http://commons.apache.org/fileupload/</a><br />
[spring comFileUpload]: <a title="external: Apache Commons Fileupload on the Spring bundle repository" href="http://www.springsource.com/repository/app/bundle/version/detail?name=com.springsource.org.apache.commons.fileupload&amp;version=1.2.0" target="_blank">http://www.springsource.com/repository/app/bundle/version/detail?name=com.springsource.org.apache.commons.fileupload&amp;version=1.2.0</a><br />
[Servlet API]: <a title="external: Sun Servlet Technologie Homepage" href="http://java.sun.com/products/servlet/" target="_blank">http://java.sun.com/products/servlet/</a><br />
[LinkedIn]: <a title="external: LinkedIn blog about their OSGi usage" href="http://blog.linkedin.com/2009/02/17/osgi-at-linkedin-bundle-repositories/" target="_blank">http://blog.linkedin.com/2009/02/17/osgi-at-linkedin-bundle-repositories/</a><br />
[baselining]: <a title="external: DeveloperWorks on how to use Eclipse Baselining tools" href="http://www.ibm.com/developerworks/opensource/library/os-eclipse-api-tools/index.html" target="_blank">http://www.ibm.com/developerworks/opensource/library/os-eclipse-api-tools/index.html</a><br />
[version schema]: <a title="external: Eclipse Versioning Schema" href="http://wiki.eclipse.org/Version_Numbering" target="_blank">http://wiki.eclipse.org/Version_Numbering</a><br />
[eclipse-vers1]: <a title="external: Eclipse Versioning Guide Part I" href="http://wiki.eclipse.org/Evolving_Java-based_APIs" target="_blank">http://wiki.eclipse.org/Evolving_Java-based_APIs</a><br />
[eclipse-vers2]: <a title="external: Eclipse Versioning Guide Part II" href="http://wiki.eclipse.org/Evolving_Java-based_APIs_2" target="_blank">http://wiki.eclipse.org/Evolving_Java-based_APIs_2</a><br />
[eclipse-vers3]: <a title="external: Eclipse Versioning Guide Part III" href="http://wiki.eclipse.org/Evolving_Java-based_APIs_3" target="_blank">http://wiki.eclipse.org/Evolving_Java-based_APIs_3</a><br />
[BND]: <a title="external: BND tool Homepage" href="http://www.aqute.biz/Code/Bnd/" target="_blank">http://www.aqute.biz/Code/Bnd/</a><br />
[eclipse]: <a title="external: Eclipse Homepage" href="http://www.eclipse.org/" target="_blank">http://www.eclipse.org/</a><br />
[bundlor]: <a title="external: Spring Bundlor Homepage" href="http://www.springsource.org/bundlor/" target="_blank">http://www.springsource.org/bundlor/</a><br />
[JSR 277]: <a title="external: JSR 277 Homepage" href="http://jcp.org/en/jsr/detail?id=277" target="_blank">http://jcp.org/en/jsr/detail?id=277</a><br />
[jigsaw]: <a title="internal: My view on project JigSaw and JSR 277" href="http://osgi.mjahn.net/2008/12/04/componentization-wars-part-ii-guerrilla-tactics/" target="_blank">http://osgi.mjahn.net/2008/12/04/componentization-wars-part-ii-guerrilla-tactics/</a><br />
[Java Language Specification]: <a title="external: Java Language Specification" href="http://java.sun.com/docs/books/jls/third_edition/html/j3TOC.html" target="_blank">http://java.sun.com/docs/books/jls/third_edition/html/j3TOC.html</a><br />
[binary compatibility]: <a title="external: Java Language Specification - Binary-Compatibility chapter" href="http://java.sun.com/docs/books/jls/third_edition/html/binaryComp.html" target="_blank">http://java.sun.com/docs/books/jls/third_edition/html/binaryComp.html</a><br />
[sigtest tool]: <a title="external: Java Sig Test Tool" href="https://sigtest.dev.java.net/" target="_blank">https://sigtest.dev.java.net/</a><br />
[RFP 122]: <a title="external: Hal Hildebrand on the OSGi Bundle Repository aka RFP 122" href="http://www.tensegrity.hellblazer.com/2009/03/osgi-rfp-122---the-osgi-bundle-repository.html" target="_blank">http://www.tensegrity.hellblazer.com/2009/03/osgi-rfp-122&#8212;the-osgi-bundle-repository.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://osgi.mjahn.net/2009/04/02/the-myth-of-software-reuse/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>The Dynamic Import Issue</title>
		<link>http://osgi.mjahn.net/2009/02/05/the-dynamic-import-issue/</link>
		<comments>http://osgi.mjahn.net/2009/02/05/the-dynamic-import-issue/#comments</comments>
		<pubDate>Thu, 05 Feb 2009 01:09:23 +0000</pubDate>
		<dc:creator>Mirko Jahn</dc:creator>
				<category><![CDATA[Componentization]]></category>
		<category><![CDATA[JSR 291]]></category>
		<category><![CDATA[OSGi]]></category>
		<category><![CDATA[buddy class loading]]></category>
		<category><![CDATA[dynamic import]]></category>
		<category><![CDATA[implementation lookup]]></category>

		<guid isPermaLink="false">http://osgi.mjahn.net/?p=93</guid>
		<description><![CDATA[After some less OSGi technology centric posts I am now getting back to the meat and will highlight the problems involved with dynamic imports. In well designed OSGi applications the &#8220;DynamicImport-Package&#8221; header should be obsolete. Unfortunately not every code is OSGi aware. Actually it is not the missing OSGi awareness that is the core of [...]]]></description>
			<content:encoded><![CDATA[<p>After some less OSGi technology centric posts I am now getting back to the meat and will highlight the problems involved with dynamic imports. In well designed OSGi applications the &#8220;DynamicImport-Package&#8221; header should be obsolete. Unfortunately not every code is OSGi aware. Actually it is not the missing OSGi awareness that is the core of the problem. It is more the notion of making wrong assumptions on the visibility of classes and the misuse of context class loaders in 90% of the cases I saw. But what is the problem in a concrete example?</p>
<p>Well, a common example is JAXB. You have a library/API bundle which for itself provides no real functionality, but needs to be &#8220;enhanced&#8221;. You need actual implementations to provide functionality. Unfortunately your library needs access to those classes. OSGi is very strict with its class path definition. This is done in a static manner and has to be set during build time of your bundle (Import-Package header in the manifest), but your library provider has no idea about the implementation bundles (and it shouldn&#8217;t!). As you can see there is no way of defining such dependencies at built-time. In OSGi the only way to enable this without modification of the bundle code is to include a dynamic import header.</p>
<p>Eclipse soon realized that this is an issue. Especially the undirected import forces in many cases a binding to bundles that are not really related to the bundle defining the import. This causes issues with restarts and updates of the library bundle, because a lot, if not all bundles, can be affect by that. Even worse, it can mean that you end up finding the wrong classes (and I am not yet talking about versions). Eclipse, while migrating to OSGi had a huge amount of legacy code not aware of OSGi concepts and so they were the first really feeling the pain. That&#8217;s why the Eclipse community introduced the concept of <a title="external: Eclipse Buddy Class Loading explained" href="http://wiki.eclipse.org/index.php/Context_Class_Loader_Enhancements" target="_blank">buddy class loading</a>. Although a better way by providing a scope (you have to define that you&#8217;re a contributor on the one side and declare that you&#8217;re open for that on the other side), it doesn&#8217;t solve the problem of different versions or provider selection in general. </p>
<p>Quiet a few people assume this is the only way to work around this kind of problems and they are correct when you don&#8217;t have the possibility of adding you&#8217;re own mechanisms or the API prevents other measures. However, if you have the access to the source, it is likely that you actually can do something that solves the problem. </p>
<p>While working on my thesis, some years ago, I came across this problem and in some cases you are able to use basic OSGi mechanisms to get what you need. The core idea and the requirement is, that the library needs the implementation class and offers a way to either inject the object or tweak the class loading mechanism to actually find the class you are looking for. So the question is how to gain access to the implementation object or its class loader for that matter. For the ones familiar with OSGi this should be obvious. We instantiate the implementation in our implementation bundle and offer that one as a service. We can register that object with the interface(s) theses classes are implementing or the annotation class they got annotated with. This is an universal key to identify the correct service. The nice thing about this is also that OSGi will handle the version problem for free. With Spring or the up coming <a title="external: [pdf] OSGi R4.2 draft 2" href="http://www.osgi.org/Download/File?url=/download/osgi-4.2-early-draft2.pdf" target="_blank">RFC 124</a> we don&#8217;t even have to write a single line of code in most cases, we don&#8217;t even have to touch the bundle. All we need is to provide is a fragment attached to the implementation bundle with a spring configuration inside creating a bean and publishing that one as a service.</p>
<p>Ok, we now have our implementation objects flying around in the ServiceRegistry. The next step is providing access to those objects in our library bundle. This is the actual tricky part and the point where you&#8217;ll most likely will face problems. Your API needs to provide a way of injecting these service objects and should allow you to dynamically manage them (add/remove/update). Otherwise you&#8217;ll end up with a static solution that once started won&#8217;t be able to adapt to the dynamic nature of OSGi. If you&#8217;re API provides/ uses a class loader look up that can be tweaked you&#8217;re the lucky one. Here you can provide a delegating class loader that dynamically queries the ServiceRegistry for the fitting object and returns its class loader. This is what we did in our <a title="external: Adopting OSGi in UIMA @ sys-con.com" href="http://java.sys-con.com/node/449864" target="_blank">OSGi-efied UIMA</a> implementation. The drawback here is, once you provided the defining class loader you lost control on how to resolve others unless your library has some mechanisms for that, which is unfortunately not very likely.</p>
<p>As you&#8217;ve seen, you not always have to go for a dynamic import. All the mentioned approaches have their advantages and disadvantages and none of them are &#8220;perfect&#8221;, but at least you have the choice choosing the one fitting best to the specific problem context.</p>
<p>If you found other ways of migrating problematic legacy code, please let me know. Maybe there is a solution out there, I was just not aware of. You never know <img src='http://osgi.mjahn.net/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>Cheers,<br />
Mirko</p>
]]></content:encoded>
			<wfw:commentRss>http://osgi.mjahn.net/2009/02/05/the-dynamic-import-issue/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Componentization wars part II &#8211; Guerrilla tactics</title>
		<link>http://osgi.mjahn.net/2008/12/04/componentization-wars-part-ii-guerrilla-tactics/</link>
		<comments>http://osgi.mjahn.net/2008/12/04/componentization-wars-part-ii-guerrilla-tactics/#comments</comments>
		<pubDate>Thu, 04 Dec 2008 21:36:33 +0000</pubDate>
		<dc:creator>Mirko Jahn</dc:creator>
				<category><![CDATA[Componentization]]></category>
		<category><![CDATA[JSR 277]]></category>
		<category><![CDATA[JSR 294]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[OSGi]]></category>

		<guid isPermaLink="false">http://osgi.mjahn.net/?p=79</guid>
		<description><![CDATA[Usually when I am blogging, I am talking about the latest technology, standards or general trends. This time however, I wonna talk about politics. No, not about the elections in US, but about politics in software development practiced by the big players to achieve their business goals. Don&#8217;t get me wrong from the start. I [...]]]></description>
			<content:encoded><![CDATA[<p>Usually when I am blogging, I am talking about the latest technology, standards or general trends. This time however, I wonna talk about politics. No, not about the elections in US, but about politics in software development practiced by the big players to achieve their business goals. Don&#8217;t get me wrong from the start. I think this is completely normal in general. We all are trying to achieve our goals the one way or the other, but something just doesn&#8217;t feel right&#8230;</p>
<p>Yesterday I read about the latest <a title="external link: Mark Reinhold's blog" href="http://blogs.sun.com/mr/entry/jigsaw" target="_blank">news</a> concerning Sun&#8217;s plans about the future of <a title="external link: JSR 277" href="http://jcp.org/en/jsr/detail?id=277" target="_blank">JSR 277</a>, <a title="external link: JSR 294" href="http://jcp.org/en/jsr/detail?id=294" target="_blank">JSR 294</a> and its new plans on inventing componentization for its JVM called <a title="external Link: Jigsaw" href="http://blogs.sun.com/mr/entry/jigsaw" target="_blank">Jigsaw</a>. I hate to say it, but for me, it seems like Sun behaves like a small child trying to insist to be the one driving all development and not letting someone else play with its toys. It&#8217;s anything but the behavior of a well establish and industry leading company or one who wants to become one. First they completely ignored the problem of componentization in Java while persuing enterprise development with J(2)EE and missed their chance to actually set the foundation for real software reuse what you would expect from and enterprise ready language specification. Later, when OSGi began to rise they started the JSR 277 and tried to create a competing standard in secret, which didn&#8217;t work out too well as we all know. Now, because of the pressure of the community and the lack of showing a better solution they are abandoning the JSR and start developing their own &#8220;internal&#8221; componentization approach with the Jigsaw project. Of course they are claiming it is not intended to be used outside their own use case for componentizing the JVM, but it is hard for me to believe this. Call me paranoid, but for me it sounds much more like an attempt to develop another system, which after completion is suddenly moved into an official standard. Sun&#8217;s statement that they are going to revive JSR 294 and are inviting even the OSGi Alliance to participate to work on it feels more like a distraction so that Sun is able to pursue its plans with Jigsaw in private that without public notice they suddenly can come up with a self made de-facto standard. Again, I might be to paranoid, but it just doesn&#8217;t feel right. Is all that just a coincident? I don&#8217;t think so. Why can&#8217;t they embrace the work done already and see it as a great chance to propel their Language and create a true reusable software stack, no other vendor can offer? Hal Hildebrand just blogged about Sun&#8217;s attempt to introduce this new project and the way they are trying to persuade big industry players about their great intents&#8230; Well, you should really read his <a title="external link: Hal Hildebrands blog post" href="http://www.tensegrity.hellblazer.com/2008/12/spice-is-not-a-recreational-drug.html" target="_blank">post</a> about it and please tell me, if they have such humble goals, why does everyone they consult have to sign a NDA? I strongly believe that if those ideas are so great, why not share them and let the community decide and participate?</p>
<p>To wrap things up, I ask all of you who feel like me, share you&#8217;re opinion! Comment on Hal&#8217;s post, blog about it, link to it, spread the word. I believe we &#8211; as a community &#8211; have to stand up and say what we think to show Sun, that those kind of guerrilla tactics, especially when so easily to look through are not working. Keep your eyes open and don&#8217;t fall for the dark side <img src='http://osgi.mjahn.net/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>Cheers,<br />
Mirko</p>
]]></content:encoded>
			<wfw:commentRss>http://osgi.mjahn.net/2008/12/04/componentization-wars-part-ii-guerrilla-tactics/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>The Whole &#8211; More than the sum of all parts</title>
		<link>http://osgi.mjahn.net/2008/11/26/the-whole-more-than-the-sum-of-all-parts/</link>
		<comments>http://osgi.mjahn.net/2008/11/26/the-whole-more-than-the-sum-of-all-parts/#comments</comments>
		<pubDate>Wed, 26 Nov 2008 17:43:03 +0000</pubDate>
		<dc:creator>Mirko Jahn</dc:creator>
				<category><![CDATA[Componentization]]></category>
		<category><![CDATA[JSR 291]]></category>
		<category><![CDATA[OSGi]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[architecture]]></category>
		<category><![CDATA[library design]]></category>
		<category><![CDATA[reuse]]></category>
		<category><![CDATA[Spring DM]]></category>

		<guid isPermaLink="false">http://osgi.mjahn.net/?p=53</guid>
		<description><![CDATA[A lot of people are following the buzz about OSGi now and are excited about all the things it can do for you. A great world of new opportunities. Now, after the first draft of OSGi 4.2 it very much looks like we&#8217;re getting even more as an official OSGi standard (with RFC 124). The [...]]]></description>
			<content:encoded><![CDATA[<p>A lot of people are following the buzz about OSGi now and are excited about all the things it can do for you. A great world of new opportunities. Now, after the first draft of OSGi 4.2 it very much looks like we&#8217;re getting even more as an official OSGi standard (with RFC 124). The formally called Spring Dynamic Modules (in short SpringDM) is going to be OSGi-efied. Today, I want to take a short peak into what this can actually mean and how it could affect the software/ component reuse in your software stack even today.</p>
<p>First things first, when I talk to people about OSGi the most common complain is nothing OSGi specific at all. Basically it is the problem of every API out there. If you implement against an open or proprietary API you&#8217;re bound to it to some extend. Ok, this is besides the issue of being to complex. When done right, which includes using all the versioning features OSGi offers it is unfortunately kinda true. We&#8217;re still lacking the right tooling support here. Anyway, let&#8217;s stick to the first one first (I&#8217;ll cover the tooling problem in a later post).  Speaking of proprietary, it is true you have to add custom headers to your jar files, but this alone doesn&#8217;t hurt you. You can still just use the jar as &#8211; yeah well &#8211; a simple jar in your web container or any other Java application without any problems at all. This was simple, but there is more of course &#8211; the OSGi doesn&#8217;t only specify manifest headers. There is also an API you use and program against. Activators for instance can be used to do something like setting up or shutting down your bundle and opening or closing connection pools to databases, registering services signaling that you&#8217;re bundle is there and ready to get its work done. Assuming you are not using any of the compendium APIs the imposed layer is rather small and can be encapsulated in a single package per bundle and more often just one single class.</p>
<p>However, as soon as you start using those few classes they become part of your jar and thus you&#8217;re bound to them. So, we&#8217;re still stuck right?  Well, not really. First of all, every OSGi expert (and probably any other sane software engineer) will tell you not to intermingle your domain logic with middleware APIs of any kind. As already mentioned, with OSGi, you can usually keep this layer pretty thin. With Spring DM we can make it now even thinner and separate domain concerns from the container entirely. So, how can we achieve this. Of course, Spring is not doing any magic, although it does a pretty good job. All it does is actually providing an IoC framework, which declaratively wires beans together. Plain simple speaking, that&#8217;s about it. You could also use other IoC frameworks like Google Guice or pico container if like, but the integration in OSGi with Spring is pretty unique.  The big question remaining is how we can best separate these two concerns.</p>
<p>To start with, you design your domain logic in a bean driven way. By that you not only achieve a well testable domain code, you also remove hard wired dependencies not relevant for your core needs &#8211; a very common practice in Domain Driven Design, to throw in some buzz words <img src='http://osgi.mjahn.net/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  Package all that code in one or more bundles depending on your needs. What you got is the code base you can reuse in any environment. Now, we need the glue code to actually make it work in OSGi &#8211; the package with the few OSGi specific classes. Those you now have to put into a different bundle or fragment (more on this later). By this separation you no longer deliver container specific code, if you don&#8217;t need to. Even more, depending on your deployment scenario, you can change and adjust the configuration to your specific needs, all separated in different bundles/fragments. Removing configurations from your domain bundles has the advantage of independent versioning of you actual code  and configuration. The domain code, if used f.i. in a Software Product Line is now no longer related to the configuration of your products based on this code and can be versioned independently &#8211; enabling you to see what really changes in your application.</p>
<div id="attachment_60" class="wp-caption alignleft" style="width: 310px"><img class="size-medium wp-image-60" title="Application Architecture" src="http://osgi.mjahn.net/wp-content/uploads/2008/10/whole-moreasthesum-300x229.jpg" border="0" alt="Application Architecture" width="300" height="229" /><p class="wp-caption-text">Fig.1 - Sample Application Architecture</p></div>
<p>This approach is shown in figure 1. You have two applications using the same library with different configurations. You can fix bugs or add features in the library without touching the configurations and vice versa. Interesting now is the difference between fragments and bundles. When should I use what? The advantage of a bundle is that it is the way OSGi intends to deploy code. You can use Activators and define your dependencies. The fragment in contrast was actually intended to only carry optional data like i18n information and alike. The advantage however is that the fragment and its host are sharing the same class loader(, which is also the biggest disadvantage and should be considered really carefully!). This distinction basically sets when to use what. When ever the configuration is loaded by the library and can&#8217;t be injected by another bundle, you need to have access to the bundles class path in order to provide the required resource. But wait a minute, you can&#8217;t use Activators in fragments. How could we now do the initialization? Here Spring DM comes in. You can just provide a Spring configuration in your fragment and as soon as the fragment is attached, Spring will recognize it and just initializes your beans defined in the descriptor and you have your Activator again. You even have access to the BundleContext if required. However, this approach is only intended for code that otherwise wouldn&#8217;t work or can&#8217;t be changed for some reasons. The best way to do it is for sure using bundles for that kinda thing.</p>
<p>The main point, I was trying to make here is that with the help of Spring and the up coming manifestation in OSGi R4.2 (if accepted), we have even more opportunities to build reusable and coherent artifacts, perfect suitable for software product lines. However, all the presented possibilities also impose potential for misuse and you should be careful by choosing your way. In many cases the simplest way on first sight eventually becomes a dead end, so be careful and farsighted when making your decisions.</p>
<p>Cheers<br />
Mirko</p>
]]></content:encoded>
			<wfw:commentRss>http://osgi.mjahn.net/2008/11/26/the-whole-more-than-the-sum-of-all-parts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bundle selection extended &#8211; what if&#8230;</title>
		<link>http://osgi.mjahn.net/2008/03/18/bundle-selection-extended-what-if/</link>
		<comments>http://osgi.mjahn.net/2008/03/18/bundle-selection-extended-what-if/#comments</comments>
		<pubDate>Tue, 18 Mar 2008 02:51:28 +0000</pubDate>
		<dc:creator>Mirko Jahn</dc:creator>
				<category><![CDATA[Componentization]]></category>
		<category><![CDATA[JSR 291]]></category>
		<category><![CDATA[OSGi]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[excution environment]]></category>
		<category><![CDATA[framents]]></category>
		<category><![CDATA[native code]]></category>

		<guid isPermaLink="false">http://osgi.mjahn.net/2008/03/18/bundle-selection-extended-what-if/</guid>
		<description><![CDATA[OSGi provides developers with plenty of configuration and selection mechanisms to adapt your application perfectly to a certain environment. One of these features is the usage of native code. Other than plain Java in OSGi you can simply define a header like the following:

Bundle-NativeCode: lib/superDuper.dll;
osname = WindowsNT;
processor = x86;
selection-filter="(net.mjahn.sample.windowing=win32)";
language = en;
language = de

Now doing this [...]]]></description>
			<content:encoded><![CDATA[<p>OSGi provides developers with plenty of configuration and selection mechanisms to adapt your application perfectly to a certain environment. One of these features is the usage of native code. Other than plain Java in OSGi you can simply define a header like the following:<br />
<code><br />
Bundle-NativeCode: lib/superDuper.dll;<br />
osname = WindowsNT;<br />
processor = x86;<br />
selection-filter="(net.mjahn.sample.windowing=win32)";<br />
language = en;<br />
language = de<br />
</code><br />
Now doing this in a fragment is a very nice feature. If your environmental requirements are met, your fragment gets attached to the host and the correct library will be loaded by your OS. On the other hand, if you deploy that fragment on another machine with let&#8217;s say a Solaris OS, it simply won&#8217;t get resolved. The advantage is you can just create an assembly with all native libraries for the different OS versions and systems in different fragments. Depending on your environment, the container will figure out, which fragment to choose and attach to the host. Piece of cake, I would say.</p>
<p>Recently I was faced with a similar, but unfortunately more difficult problem. I wanted to provide two different bundles containing a distinct implementation of a specific API as fragments; depending on the OS it is running on. On first sight, it is the problem, I already discussed, but on a second view, I realized that it is actually plain Java. The API, I am providing in my fragments is OS dependent, but doesn&#8217;t contain native code. I thought, I could work around it, by providing something like a selection-filter or anything similar to the mechanisms of the Bundle-NativeCode header, but there isn&#8217;t. (If I am wrong here, please enlighten me, but I haven&#8217;t found anything in the 4.1 OSGi core specification!).</p>
<p>Of course, if you have the possibility, you can just implement your own mechanisms to do what OSGi does for native code, just with plain old Java code. Check the environment and load the correct libraries or even simpler, just only provide the correct fragment versions. This is all true; it definitely would work that way. The question, I am asking myself is more, shouldn&#8217;t this actually be an infrastructural concern? Shouldn&#8217;t the infrastructure be able to decide what is necessary and suits best? In my opinion, one of the big advantages of OSGi is the expressiveness of constraints. Everything is explicit, so from my point of view, it is logical to enable such declarative dependencies without native code as well.</p>
<p>One question remains: Where should this mechanism be added? Like with singleton bundles together with the &#8220;Bundle-SymbolicName&#8221;? I wouldn&#8217;t say so. I think the &#8220;Bundle-RequiredExecutionEnvironment&#8221; would be a perfect spot for that. A selection based on System properties is flexible, yet distinct enough, so the already introduced &#8220;selection-filter&#8221; could be applied here. The execution environment in general fits the scope of this property way better than any other, already defined in OSGi.</p>
<p>Well, unfortunately, I am not an OSGi member and the next spec will take a while to come, so I guess this is nothing to be expected any time soon, if at all <img src='http://osgi.mjahn.net/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  Maybe I am wrong about all that, because I am missing something, but I actually haven&#8217;t found any evidence stating the opposite. Till then, I hope for the best &#8211; a more compatible (IT) world.</p>
<p>&#8211; Mirko</p>
]]></content:encoded>
			<wfw:commentRss>http://osgi.mjahn.net/2008/03/18/bundle-selection-extended-what-if/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Half bundle, half jar &#8211; the nature of a fragment, a blessing or a curse?</title>
		<link>http://osgi.mjahn.net/2008/03/13/half-bundle-half-jar-%e2%80%93-the-nature-of-fragment-a-blessing-or-a-curse/</link>
		<comments>http://osgi.mjahn.net/2008/03/13/half-bundle-half-jar-%e2%80%93-the-nature-of-fragment-a-blessing-or-a-curse/#comments</comments>
		<pubDate>Thu, 13 Mar 2008 00:10:23 +0000</pubDate>
		<dc:creator>Mirko Jahn</dc:creator>
				<category><![CDATA[Componentization]]></category>
		<category><![CDATA[JSR 291]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[OSGi]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[ClassLoader]]></category>
		<category><![CDATA[fragments]]></category>
		<category><![CDATA[standard]]></category>

		<guid isPermaLink="false">http://osgi.mjahn.net/2008/03/13/half-bundle-half-jar-%e2%80%93-the-nature-of-fragment-a-blessing-or-a-curse/</guid>
		<description><![CDATA[When first diving into OSGi, you probably don&#8217;t notice fragments at all. After a while, once you become familiar with the concept and the main parts of the spec, you start looking into ways to accomplish things, which were fairly simple done in plain Java, but might be really painful in OSGi. By then the [...]]]></description>
			<content:encoded><![CDATA[<p>When first diving into OSGi, you probably don&#8217;t notice fragments at all. After a while, once you become familiar with the concept and the main parts of the spec, you start looking into ways to accomplish things, which were fairly simple done in plain Java, but might be really painful in OSGi. By then the latest, you&#8217;ll find them in the spec and they are really tempting in so many ways. Before I elaborate on that, let me just summarize the main features of fragments in order to give everyone a chance to follow.</p>
<p>Fragments, like bundles are just simple jar files with additional manifest headers; actually they are almost the same as the bundle manifest headers. At first glance, bundles and fragments look alike. Both are jars by definition and specify additional manifest headers. The huge difference is that a Fragment is like virus. It needs to be attached to a host in order to function. During the attaching process of a fragment to a exactly specified host, the manifest files were logically merged if not conflicting and the dependencies are being resolved, if possible (if not possible, the fragment will just not be resolved and attached). After that, the resources in the fragments are loadable with the host ClassLoader, thus the Fragment does NEVER have its own ClassLoader (but its own ProtectionDomain if not an extension fragment, but we are not going there). Actually, there are quiet a few more things worth mentioning, but to understand what I am training to explain here, it should be fine. If something beyond that is needed, I am going to explain it as we go.</p>
<p>Now, that we know, what a Fragment is, what is it actually for where is the problem. Well, the purpose as described in the spec is pretty straight forward and logic. For customization of your bundle depending on the environment, often only very little, yet delicate changes are sometimes necessary. This can be a simple localization issue of your translations or the packaging of system dependant libraries like &#8220;dll&#8221;, &#8220;.so&#8221; or &#8220;.dmg&#8221; you are invoking in your bundle code. Depending on system properties like &#8220;os.name&#8221; or &#8220;lang&#8221; you can let the container decide, which bundles/fragments suit your environment &#8211; so far so good.</p>
<p>Now, where might be the problem with that? To motivate this, one has to keep in mind that one of the strengths of OSGi is its encapsulation model. Based on this declarative, strong and rigid component definition, OSGi became a very robust deployment format/ environment. A bundle or component is very expressive about its requirements and features, which makes it easy to handle them. Now, with Fragments attached to a host, the behavior of the host might change, without any changes of the version information within the bundle. The former strong formalism is now softened. Especially if you look into Software Product Lines, where you have thousands of bundles in many different versions, dynamically wired together, you can&#8217;t test every combination effectively; you have to be sure, that you can rely on a certain behavior, enforced by the component contract, which is in this case no longer possible.</p>
<p><a title="Figure 1 - simple import Fragment attached" href="http://osgi.mjahn.net/wp-content/uploads/2008/03/fragments_p1.jpg"><img src="http://osgi.mjahn.net/wp-content/uploads/2008/03/fragments_p1.jpg" border="0" alt="Figure 1 - simple import Fragment attached" vspace="1" width="240" align="left" /></a>The question is how a fragment potentially manages to violate the component contract. Concerning this question, there has been a discussion on the <a title="external: Thread in the OSGi-Dev list" href="https://mail.osgi.org/pipermail/osgi-dev/2008-March/001093.html" target="_blank">OSGi-Dev </a>list this week. Just imagine you have a bundle <strong>X</strong> with three packages <em>a</em>, <em>b</em> and <em>c</em>. Fragment <strong>F</strong> defines one Import-Package: <em>b</em>. Another Bundle <strong>Z</strong> provides the package <em>b</em> as an export and has <em>c</em> internally available (see figure).</p>
<p>We further assume that bundle <strong>X</strong> defines in package <em>a</em> only a <code>BundleActivater</code> loading a class from package <em>b</em>. Now we have everything set, to begin our small example. Starting the bundle <strong>X</strong> (with the attached fragment <strong>F</strong>) will result in loading the <code>BundleActivator</code>. The activator then will try to load the class from package <em>b</em>. Depending on the OSGi class loading strategy, the class loader first looks into the import statements of the host, if there are no entries (like in our case), the fragment is queried for import statements. This time we&#8217;re successful and the ClassLoader is trying to obtain the class from another bundle. Here we have our problem. The behavior of <strong>X</strong> can be altered by providing another implementation of package <em>b</em> as an export of bundle <strong>Z</strong> in the container (it has to be a different bundle &#8211; import your exports in the fragment won&#8217;t work in that case). The problem here is not, that the package is replaced with an alternate implementation; this is pretty common in OSGi with the best practice of importing your exports. The crux here is that there is no statement of imports and the actual developer of the bundle might not have intended to replace the package at all.<a title="Figure 2 - Fragment replaces the a private package of a bundle" href="http://osgi.mjahn.net/wp-content/uploads/2008/03/fragments_p2.jpg"><img src="http://osgi.mjahn.net/wp-content/uploads/2008/03/fragments_p2.jpg" border="0" alt="Figure 2 - Fragment replaces the a private package of a bundle" vspace="1" width="200" align="left" /></a></p>
<p>Of course this behavior has advantages as well. Consider you have a OSGi-efied bundle, which unfortunately isn&#8217;t converted perfectly, so you still have some Class.forName() calls in one minor package. The license however doesn&#8217;t allow you to touch the bundle at all, but now with the help of a fragment, you can inject your own code as described above. Not sure, if one really needs that, but you can.</p>
<p>Something else you can do with fragments is to emulate a global class space. I was actually working in on a project, where we had a pretty monolithic software in terms of the core DTOs. Although &#8220;Extensions&#8221; were easy exchangeable and loadable with different class loaders, the core data transfer objects were not, unless you serialize them, which of course was out of discussion. Now imagine, you have one core bundle, where every extension contributes its DTOs in form of a fragment, you end up with a global class space for all your DTOs. Nice on first glace, it becomes nasty soon, when you think about the implications. First of all, versioning is now only very limited available. Second, every new deployed fragment lets your whole application refresh, because everything depends on this core bundle and every fragment is attached to it &#8211; at least for me, no desirable solution.</p>
<p>The finish this (actually pretty long) post today, I can think of one last case, where it can help. Imagine, you have multiple versions of a package available and your bundle requires a distinct version, because of strange constraints, but can&#8217;t make these imports explicit, but dynamic with DynamicImport-Package, normally you don&#8217;t have a chance to provide a distinct version. With a fragment, you are able to inject a distinct version before the DynamicImport-Package definition is used in the class loading strategy.</p>
<p>However, I tried to show different ways of using fragments, besides the usual ones of providing translations or system dependant libraries. Everyone can of course do what ever he or she wants, but in my opinion, all these alternative usages are extremely dangerous and I can&#8217;t think of any sane reason to use them in real projects. Just because you can do something doesn&#8217;t mean it is go to do so. I gave it quiet a thought and I actually came to the conclusion, that the class loading behavior should be changed in a way that, no matter what happens, the bundle class path lookup should be performed entirely, before any attached fragment is asked. This would be a valid solution to prevent violations of the bundle contract in my opinion, but well&#8230; these are just my 2 cents. Take it or leave it <img src='http://osgi.mjahn.net/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>&#8211;<br />
Mirko</p>
]]></content:encoded>
			<wfw:commentRss>http://osgi.mjahn.net/2008/03/13/half-bundle-half-jar-%e2%80%93-the-nature-of-fragment-a-blessing-or-a-curse/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
