<?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; Java</title>
	<atom:link href="http://osgi.mjahn.net/category/java/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>Extenders in OSGi &#8211; what is all the buzz about?</title>
		<link>http://osgi.mjahn.net/2009/03/04/extenders-in-osgi-what-is-all-the-buzz-about/</link>
		<comments>http://osgi.mjahn.net/2009/03/04/extenders-in-osgi-what-is-all-the-buzz-about/#comments</comments>
		<pubDate>Wed, 04 Mar 2009 02:14:07 +0000</pubDate>
		<dc:creator>Mirko Jahn</dc:creator>
				<category><![CDATA[JSR 291]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[OSGi]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[extender]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[pattern]]></category>

		<guid isPermaLink="false">http://osgi.mjahn.net/?p=98</guid>
		<description><![CDATA[It feels like recently extenders became extremely fashionable among the OSGi community. Eclipse is using an extender like pattern to track their plugin.xml configurations and Spring DM introduced the plain osgi extender together with a special web extender. It seems like everyone has one lately, but what is all the buzz about and how should [...]]]></description>
			<content:encoded><![CDATA[<p>It feels like recently extenders became extremely fashionable among the OSGi community. <a title="external: Eclipse.org Website" href="http://www.eclipse.org" target="_blank">Eclipse</a> is using an extender like pattern to track their <a title="external: plugin.xml usage - a simple tutorial" href="http://www.eclipse.org/articles/Article-Your%20First%20Plug-in/YourFirstPlugin.html" target="_blank">plugin.xml</a> configurations and <a title="external: Spring DM aka Spring OSGi" href="http://www.springsource.org/osgi" target="_blank">Spring DM</a> introduced the plain osgi <a title="external: Spring extender" href="http://static.springframework.org/osgi/docs/current/reference/html/bnd-app-ctx.html#bnd-app-ctx:extender" target="_blank">extender</a> together with a special <a title="external: Spring Web Extender" href="http://static.springframework.org/osgi/docs/current/reference/html/web.html#web:configuration" target="_blank">web extender</a>. It seems like everyone has one lately, but what is all the buzz about and how should or could you use one &#8211; and even more important, when should you use one. As always in software development there is no clear black and white answer to this, but this blog post at least tries to shade some light on this topic to help you making the right decisions.</p>
<p><strong>The buzz, what is it about?</strong></p>
<p>Before the extender hit the light, people were advertising the white board pattern as THE OSGi way of doing things. A way of inverting control, taking the burden of house keeping from the consumer like it is required with the well known listeners. On the OSGi website you can even find a good paper on &#8220;<a title="external: listeners considered harmful [pdf]" href="http://www.osgi.org/wiki/uploads/Links/whiteboard.pdf" target="_blank">why listeners are considered harmful</a>&#8220;. Well, things change or better progress and with the extender another problem got addressed. The inconvenient with the white board pattern is that the client still has to take care of some stuff ending up in boilerplate code. Here is where the extender has its strengths. The core idea is to have a designated bundle that scans all already deployed bundles as well as all bundles that are being deployed during runtime for specific features, properties, interfaces, annotations, what ever you want in order to take appropriate actions on behave of this bundle. These actions can be something simple as registering a service for every implementation of a certain interface or as complex as doing some xml transformations of configuration files that will be loaded in your system triggering a whole cascade of events. The key point is that it is completely up to the extender what to do and how during deploy time.</p>
<p>Imagine you have your application extensively using the white board pattern without an extender. All &#8220;consumers&#8221; of your service have to publish a specific service in the registry in order to get recognized. You have to exactly specify what the signature of this service has to be. This can be any number of interfaces or just properties you register along with the service. All this is just fine, but when it comes to changes of your approach you have to let all you&#8217;re clients know about the changes and wait till they have adapted/ migrated or provide a runtime compatibility layer that checks for the old and the new syntax. With the extender, you can still use the white board pattern, but this time you take care of registering the service. Now, everything is defined in your extender, which interfaces are important, what properties to add. As soon as it comes to a change in your design, chances are good that you can just adapt the extender in order to register the client services with new properties, use different interfaces (if possible of course) or even use something advanced as a generic proxy that wraps around the old interface and registers itself with the new API. You can now intercept service calls, if you like or need and transform the transfered data as you please. But the best thing about it, despite the mentioned is that all this happens during deploy time of the bundle so it just happens once without the need for your clients to touch any of their code. This makes the interfaces between service providers and consumers more solid and less likely to break.</p>
<p><strong>Pros and Cons &#8211; abridge </strong></p>
<p>Of course, there is no such thing as free lunch. The extender also has its limitations, you should well be aware of. Here is a short list with the compiled pros and cons. Of course, depending on the scenario you might find more to either ones. If you think I forgot something important or don&#8217;t agree, don&#8217;t hesitate to comment. Constructive feedback is always appreciated.</p>
<p><em>disadvantages</em>:</p>
<p>- One of the first things that pops into ones mind is the problem of disabling the extender for a specific bundle. This might be interesting, because you don&#8217;t want to start/enable all bundles at start-up or just don&#8217;t want to provide all the functionality at once (f.i. to increase start-up speed). There are ways, like white/ black listing bundles, lazy activation triggered by properties or manual selection based user input. Although all this is possible, it is somewhat against the idea of the extender, which is automatically processing and removing repetitive tasks.<br />
- The second difficulty is the customization. Of course you can define a specific format that enables you to customize the way your extender works and what it does, but there are scenarios where you can&#8217;t upfront decide what to do. A common way to work around this is defining your own DSL describing your &#8220;intent&#8221; in an abstract way, like in your own DSL. However, this introduces another layer of complexity and can make your application/design even more complex &#8211; depending on your scenario of course. This is not a problem of the extender, but a general problem one usually faces when working in OSGi. Everything is intended to be generic, but at some point you have to be specific on what you actually wonna do. So, I guess it is not a real drawback, but something to consider.<br />
- Last but not least every automatic mechanism requires awareness of developers. Everyone using your bundles should be aware that something is happening behind the curtains. Otherwise chances are high the mechanism will be circumvented or miss used. Again, I think this holds true for many mechanism or patterns, but is well worth mentioning here.</p>
<p><em>advantages (assuming done right)</em>:</p>
<p>- First of all an extender means less burden for the developer. The overall goal is to remove boilerplate code, typical copy &amp; paste use cases and deterministic, error prone tasks. For most developers this is not only boring, but also a major pain point when fixing a bug or misconfiguration. By eliminating or at least minimizing such repeating tasks, you&#8217;re doing the average Joe and ultimately yourself a big favor.<br />
- You might have guessed it. Eliminating c&amp;p from your code base also makes your application more robust to changes. I mentioned that already above, but just let me emphasize that the ability to express the intend, rather then the actual how is one of the greatest advantages.<br />
- Inversion of Control. Yes, I know it is a buzz word and it is usually used grasp attention, but here it really makes sense. Like the whiteboard pattern one does remove the burden of the consumer. What kind of burden this is, depends on the extender. In many cases it will be registering the services the right way, indicating a specific functionality or setting a configuration. The beauty about this is similar to the white board pattern. Less burden for the &#8220;extendee&#8221; (the one being extended by an extender) and a centralized management logic, which can be updated, improved by the &#8220;extender&#8221;. I think it is important to note here that the extender can provide or consume, depending on your design, unlike the white board pattern.<br />
- Of course, one advantage generates others like less source code for instance. Unless you&#8217;re getting paid by lines of code you&#8217;re producing (just a joke -I honestly hope no one is evaluated on that one!), having a smaller code base is always a good thing. Other advantages would be less complex extendee bundles or simpler adaption to new requirements.</p>
<p><strong>Conclusion and outlook</strong></p>
<p>As you could see, extenders are the next evolutional step in the OSGi world. There are great new ways of designing your applications that can make your application even more robust and simpler to use. However, there also comes the responsibility to use the technology wisely and not just for the sake of it. As seen with Eclipse and now Spring, more and more advanced extender concepts are popping up and we certainly haven&#8217;t seen everything possible yet. In a future blog post, I am going to look deeper in how to create an actual extender, what to keep in mind, how the up-coming <a title="external: OSGi R4.2 specification - draft 2 [pdf]" href="http://www.osgi.org/download/osgi-4.2-early-draft2.pdf" target="_blank">OSGi R4.2</a> spec will help us here, what kind of extenders are there already and of course common pitfalls one may face implementing your own. Stay tuned and have fun experimenting with extenders.</p>
<p>Cheers<br />
Mirko</p>
]]></content:encoded>
			<wfw:commentRss>http://osgi.mjahn.net/2009/03/04/extenders-in-osgi-what-is-all-the-buzz-about/feed/</wfw:commentRss>
		<slash:comments>3</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>OSGi dynamics and legacy code &#8211; taming the beast in the future?</title>
		<link>http://osgi.mjahn.net/2008/10/28/osgi-dynamics-and-legacy-code-taming-the-beast-in-the-future/</link>
		<comments>http://osgi.mjahn.net/2008/10/28/osgi-dynamics-and-legacy-code-taming-the-beast-in-the-future/#comments</comments>
		<pubDate>Tue, 28 Oct 2008 05:34:55 +0000</pubDate>
		<dc:creator>Mirko Jahn</dc:creator>
				<category><![CDATA[JSR 291]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[OSGi]]></category>
		<category><![CDATA[architecture]]></category>

		<guid isPermaLink="false">http://osgi.mjahn.net/?p=61</guid>
		<description><![CDATA[Legacy code in OSGi has always been a problem. OSGi has such a dynamic nature, most libraries are either not aware of the potential errors that can be imposed by suddenly disappearing bundles or just use techniques not suitable for the OSGi programming model, like absolute paths, usage of file references instead of URLs, context [...]]]></description>
			<content:encoded><![CDATA[<p>Legacy code in OSGi has always been a problem. OSGi has such a dynamic nature, most libraries are either not aware of the potential errors that can be imposed by suddenly disappearing bundles or just use techniques not suitable for the OSGi programming model, like absolute paths, usage of file references instead of URLs, context class loaders and others alike. Despite these, I would call generally bad programing practices, which can be avoided even in non OSGi environments (maybe except the context class loader problem), there is one thing which is typical for regular applications and just doesn&#8217;t quite work within OSGi &#8211; static, implementation based APIs.</p>
<p>So, what do I mean with that. In short, the common APIs you are usually faced with when dealing with plain Java applications. You have a class which represents your API, you may have some configuration files to set your system up and that&#8217;s it &#8211; plain simple. Logging is a perfect example for that. Let&#8217;s take any of your preferred, non OSGi logging APIs. You have a configuration file or system properties, which set the basic configuration and then you are good to go. Just call a static factory, obtain you logging object and start what ever you wanna do with it.</p>
<p>Now, what is the problem with this in an OSGi context? At first glance, nothing. You can set-up your system and it behaves like in plain Java. Problems only occur when you start trying to use it in a dynamic, typical OSGi-way. Changing a configuration during run-time, providing the configuration in a different bundle or fragment will require you to take more things like the start order into account. This in return makes your bundles no longer following core principles of OSGi, which say that as soon as a bundle gets resolved, it can be used.</p>
<p>Solving this seems hard. You can&#8217;t change a public API. Not like usual, just extract interfaces and make the implementation available as a service. Well, in some cases this might be possible, sure it won&#8217;t be in all cases. Looking at this issue, what is the core problem? The export of the API packages! Assuming, you only depend on packages (not using Require-Bundle) bundles, depending on a certain API become resolved, as soon as this API becomes available as an exported package.</p>
<p>A possible solution to this dilemma is treating export packages like services. During run-time, a bundle can explicitly add or remove exported packages. With this, you would be able to only export a certain API when you are certain, it will work as expected. Of course, this needs more thinking, because this imposes several problems (Security is just one of them), but the potential is great. To be honest, I am currently not sure if it is worth the risk or even the effort, but I am definitely sure it is worth exploring. Just think of the possibility to actually eliminate the dynamic import header with all of its drawbacks and removing proprietary workarounds like buddy class loading. So, what do you think?</p>
<p>Cheers,<br />
Mirko</p>
]]></content:encoded>
			<wfw:commentRss>http://osgi.mjahn.net/2008/10/28/osgi-dynamics-and-legacy-code-taming-the-beast-in-the-future/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>What&#8217;s the next killer app for the iPhone?</title>
		<link>http://osgi.mjahn.net/2008/04/29/whats-the-next-killer-app-for-the-iphone/</link>
		<comments>http://osgi.mjahn.net/2008/04/29/whats-the-next-killer-app-for-the-iphone/#comments</comments>
		<pubDate>Tue, 29 Apr 2008 00:25:08 +0000</pubDate>
		<dc:creator>Mirko Jahn</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[OSGi]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Componentization]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[JVM]]></category>
		<category><![CDATA[Universal OSGi]]></category>

		<guid isPermaLink="false">http://osgi.mjahn.net/?p=21</guid>
		<description><![CDATA[The release of the iPhone SDK has been some weeks ago and I actually had time to think about the whole hype thing. Of course, one of my big disappointments was that Java is most likely not going to make it on the iPhone. I actually understand the concerns regarding the UI, but actually I [...]]]></description>
			<content:encoded><![CDATA[<p>The release of the iPhone SDK has been some weeks ago and I actually had time to think about the whole hype thing. Of course, one of my big disappointments was that Java is most likely not going to make it on the iPhone. I actually understand the concerns regarding the UI, but actually I could live quite happily with a headless version. Ok, I have to admit, this wouldn&#8217;t be a standard conform JVM, but when I look at current environments, I really have to ask myself, why such a version doesn&#8217;t already exist? I mean a headless JVM version, only designed to work on servers for instance. Maybe just as a profile, nothing distinct, but optimized for 24/7 server scenarios. I convinced that in such an environment OSGi could play an important role even on iPhones. Just forget for a moment that the current license of the SDK doesn&#8217;t allow background processes as well as &#8220;other languages&#8221; than Objectiv C and focus on the opportunities. OSGi offers a great componentization approach, which the new &#8220;Universal OSGi&#8221; RFP is trying to port to other platforms. Especially the expressiveness of the meta data provided by a bundle is very interesting for other languages as well. Of course, the question is to what extend is this possible, does it make sense to define a subset of functionalities, which everyone can met or does this make the whole idea worthless? Questions, at least for me, not easy to answer yet, but I am very interested in the outcome of the work of the expert group. </p>
<p>Now, despite the existence of Java or even OSGi on an iPhone, what are these new, cool and so desired applications, we can&#8217;t wait to see on our hand held devices? I gave it some thought and here is the list of &#8220;killer apps&#8221; I would love to see on the iPhone sooner or later.</p>
<ul>
<li>Google Maps with GPS: No need to explain that much, this is THE application I am waiting for on the iPhone. No more expensive navigation software extensions for different countries will be needed anymore. You always have it at hand! (Ideally with offline capabilities to enable the use even withouth internet access.)                                 </li>
<li>Instant Messaging: Something like <a href="http://www.fring.com/blog/?p=226">fring</a> is due for a long time. You never need to be offline, no need for expensive &#8220;Text Messages&#8221;, just write your Messages, without length limitations and even with pictures and other gimics. Not to forget features like Voice over IP via Skype for instance.</li>
<li>Environment controller: Let&#8217;s call it the ubiquitous remote. You can not only control all your HIFI and TV equipment with it (ok, we need blue tooth here, but maybe in 3-5 years&#8230;), but also open your garage door, the car, dim the light in the room (the one where you are, based on location information) or your favorite computer game with the gyroscope in the iPhone. Why having tens of different applications, if one can do everything for you?</li>
<li>Black box: Ok, this can be a good and a bad thing, I have to admit, but looking at it from a purely exploratory possitiv perspective, an iPhone can be used as a sort of a black box in case of accidents. Later, officials can be enabled to reconstruct the precise movements of the iPhone. A little bit like a flight recorder in airplanes. One can record where, with which speed, which movements the fon was moved.</li>
<li>Emergency tool: Not only a phone, which calls 911, 110 or what ever the emergency number of the country you are in is, but also a live safer for others &#8211; with applications helping people to apply first aid step by step, with pictures and animated videos to show how it is done properly. An application capable of automatically submitting emergency data to the doctor nearby in an ad-hoc network as soon as the doctor authorizes himself. </li>
<li>Interactive Games: Games are nothing new &#8211; no big deal about it. Something, which is new, are the kind of games introduced by the <a href="http://wii.com/">Nintendo WII</a>. Equipment like a gyroscope or a position tracking system are new and animate people to actually play together. The iPhone can push this even further. With a mobile device, you can play anywhere with everyone, thus making playing a social experience. Just imagine a game you can play on your way to work, with someone in your train. Based on an adhoc-network, you probably don&#8217;t even now the one, but still can play against that individual. Even better are big sport events. Here thousands of people can be enabled to play against each other in some sort of a parallel game. A very interesting field, I have to admit. So many things are involved or have to thought about here: how to handle ad-hoc networks, how to negotiate the right score between two parties and avoid cheating, how to handle online/ offline behavior, how to secure the communication and manage trust in spontaneous networks,&#8230; Maybe I have to elaborate on this one in a later post, this topic just fascinates me, although I actually don&#8217;t play games.</li>
<li>My Personal Buddy: An application, I am imagining for years now. An &#8220;intelligent&#8221; agent helping me to organize my life, by proposing appointments according to my daily behavior, my favorites and so on. I think Peter Kriens once wrote something more detailed about some of the functionalities I would expect. </li>
</ul>
<p>As you probably noticed, I am convinced of the success of the new iPhone and I already have some ideas, what might come in the future. However, the iPhone is surely not the answer to all questions and still has several drawbacks, but it is certainly a move in the right direction. Let&#8217;s seen what&#8217;s coming up next.</p>
<p>Stay tuned,<br />
Mirko</p>
]]></content:encoded>
			<wfw:commentRss>http://osgi.mjahn.net/2008/04/29/whats-the-next-killer-app-for-the-iphone/feed/</wfw:commentRss>
		<slash:comments>4</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>
		<item>
		<title>Java on the iPhone</title>
		<link>http://osgi.mjahn.net/2008/03/10/java-on-the-iphone/</link>
		<comments>http://osgi.mjahn.net/2008/03/10/java-on-the-iphone/#comments</comments>
		<pubDate>Sun, 09 Mar 2008 23:38:03 +0000</pubDate>
		<dc:creator>Mirko Jahn</dc:creator>
				<category><![CDATA[JSR 291]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[OSGi]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[sun]]></category>

		<guid isPermaLink="false">http://osgi.mjahn.net/2008/03/10/java-on-the-iphone/</guid>
		<description><![CDATA[After revealing details of the new SDK for the iPhone last Thursday,  Sun  decided to develop a JVM for the iPhone after Apple showed no intention to do so. Well, for some of you, this is not much of a deal. Java is available on many mobile phones, why care about one more [...]]]></description>
			<content:encoded><![CDATA[<p>After revealing details of the new <a title="external: iPhone SDK" href="http://developer.apple.com/iphone/program/" target="_blank">SDK</a> for the iPhone last Thursday,  <a title="external: Suns decision to develop a JVM for the iPhone" href="http://www.infoworld.com/article/08/03/07/sun-iphone-java_1.html" target="_blank">Sun  decided</a> to develop a JVM for the iPhone after Apple showed no intention to do so. Well, for some of you, this is not much of a deal. Java is available on many mobile phones, why care about one more or less? From my point of view, this makes a huge difference. OSGi, actually developed to improve the mobile sector and fight the short comings of J2ME, never really succeeded due to the lack of computing resources like memory or CPU power on former cell phones. With the iPhone, things might change.</p>
<p><span id="more-17"></span>The iPhone is way more powerful than regular cell phones and provides a perfect platform for next generation mobile applications with its big display and the new intuitive user interface. Even better, with the <a title="external: embedded Rich Client Plattform Project Homepage" href="http://www.eclipse.org/ercp/" target="_blank">eRCP</a> project, Java already has a simple framework foundation for mobile applications and together with native GUI support thanks to eSWT, performance and usability should no longer be an issue. I haven&#8217;t heard about any plans to provide eSWT support for the iPhone yet though, but as soon as Sun provides a JVM at the end of June, I guess it is just a matter of time &#8211; at least I really hope for it!</p>
<p>Going back in time one can say that Sun missed the opportunity to conquer the mobile market. Java is deployed on millions of devices, but real business only a few companies managed to do with it. Now, with a powerful phone, technologies like OSGi, eRCP and native eSWT widgets, I am really curious how Java competes against <a title="external: Google's Android Homepage" href="http://code.google.com/android/" target="_blank">Google&#8217;s Android</a>. The newcomer against the old-timer, does a wealth of experience and a lively community stand against a giant with the wind of fortune and the hype of the brand in its sails? I guess, there is a good chance for Java and I really hope to see my Java applications running on an iPhone, but that&#8217;s a different story. Maybe in a few years my dream comes true and mobile phones no longer need a Java light aka J2ME any more, but will ship with a full blown JSE. So every jPhone ehm, I mean iPhone is sold with Java on board.</p>
]]></content:encoded>
			<wfw:commentRss>http://osgi.mjahn.net/2008/03/10/java-on-the-iphone/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
