<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">

  <title><![CDATA[Tag: osgi | AlBlue&rsquo;s Blog]]></title>
  <link href="http://alblue.bandlem.com/Tag/osgi/atom.xml" rel="self"/>
  <link href="http://alblue.bandlem.com/"/>
  <updated>2012-04-20T11:39:08+01:00</updated>
  <id>http://alblue.bandlem.com/</id>
  <author>
    <name><![CDATA[Alex Blewitt]]></name>
    
  </author>
  <generator uri="http://octopress.org/">Octopress</generator>

  
  <entry>
    <title type="html"><![CDATA[Why OSGi qualifiers aren't working]]></title>
    <link href="http://alblue.bandlem.com/2012/04/osgi-qualifiers.html"/>
    <updated>2012-04-11T09:00:00+01:00</updated>
    <id>http://alblue.bandlem.com/2012/04/osgi-qualifiers</id>
    <content type="html"><![CDATA[<p>In my
<a href="http://alblue.bandlem.com/2012/03/human-tooling.html">previous post</a>,
I argued that the decision not to support SNAPSHOT ranges in OSGi was
a missed opportunity for the platform, perhaps one that will limit its adoption
in the future. Despite several vocal critics (largely arguing from a point of
not having used Maven and its SNAPSHOT versioning scheme), I decided to see how
much of a problem it really was.</p>

<p>The arguments of 'Maybe this would cause problems' don't really seem to be
borne out by the Maven repository, which has over 400G of versioned artefacts
that have gone through the -SNAPSHOT process during development and rarely, if
ever, has any problems in versioned code. (That's not to say mistake can never
happen; but it's easy enough to publish a new asset with a new patch version if
required, as has been done occasionally before such as the javax.jms releases.)</p>

<p>The problem with the existence of the OSGi build qualifier is that it means
Eclipse developers don't actually take care to version code properly. Instead,
the build process just spits out recompiled bundles, often without a
corresponding bump in version number where required or needed.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Using Humans to solve a Tooling problem]]></title>
    <link href="http://alblue.bandlem.com/2012/03/human-tooling.html"/>
    <updated>2012-04-04T07:00:00+01:00</updated>
    <id>http://alblue.bandlem.com/2012/03/human-tooling</id>
    <content type="html"><![CDATA[<p>I've just written up a piece at InfoQ on how
<a href="http://www.infoq.com/news/2012/04/osgi-snapshot">OSGi have abandoned -SNAPSHOT versions</a>,
and I thought I'd take a minute to explain what I meant by the 'human tooling'
problem.</p>

<p>The issue is whether or not SNAPSHOTs shold be built in a 'lower' numerical
namespace using <code>1.2.3-456</code> which sorts less than <code>1.2.3</code>. By encouraging
a difference between 'unreleased' and 'released' versions, it becomes clear
whether there are changes which are important, and allows developers to report
bugs against a specific version (instead of just 'the latest version').</p>

<p>According to both the <a href="http://semver.org/">Semantic Versioning</a>
and the
<a href="http://wiki.eclipse.org/Version_Numbering">Eclipse Version Numbering</a>
rules, the patch number (third segment) should be changed whenever there is
a difference between build artefacts. As I've listed on the InfoQ article,
that plainly doesn't happen in some cases:</p>

<ul>
<li>org.eclipse.cdt.codan.checkers.ui_1.0.0.201109151620.jar</li>
<li>org.eclipse.cdt.codan.checkers.ui_1.0.0.201202111925.jar</li>
<li>org.eclipse.core.filebuffers_3.5.200.v20110505-0800.jar</li>
<li>org.eclipse.core.filebuffers_3.5.200.v20110928-1504.jar</li>
<li>org.eclipse.core.variables_3.2.500.v20110511.jar</li>
<li>org.eclipse.core.variables_3.2.500.v20110928-1503.jar</li>
<li>org.eclipse.emf.ecore_2.7.0.v20110912-0920.jar</li>
<li>org.eclipse.emf.ecore_2.7.0.v20120127-1122.jar</li>
<li>org.eclipse.equinox.frameworkadmin.equinox_1.0.300.v20110506.jar</li>
<li>org.eclipse.equinox.frameworkadmin.equinox_1.0.300.v20110815-1438.jar</li>
<li>org.eclipse.equinox.p2.updatesite_1.0.300.v20110510.jar</li>
<li>org.eclipse.equinox.p2.updatesite_1.0.300.v20110815-1419.jar</li>
<li>org.eclipse.jdt.compiler.tool_1.0.100.v_B76_R37x.jar</li>
<li>org.eclipse.jdt.compiler.tool_1.0.100.v_B79_R37x.jar</li>
<li>org.eclipse.jface_3.7.0.I20110522-1430.jar</li>
<li>org.eclipse.jface_3.7.0.v20110928-1505.jar</li>
<li>org.eclipse.ltk.core.refactoring_3.5.201.r371_v20110824-0800.jar</li>
<li>org.eclipse.ltk.core.refactoring_3.5.201.r372_v20111101-0700.jar</li>
<li>org.eclipse.pde.runtime_3.4.201.v20110819-0851.jar</li>
<li>org.eclipse.pde.runtime_3.4.201.v20110928-1516.jar</li>
<li>org.eclipse.ui_3.7.0.I20110602-0100.jar</li>
<li>org.eclipse.ui_3.7.0.v20110928-1505.jar</li>
</ul>


<p>The point of showing the cross-section of the above is not to highlight
specific projects, but to show this is a widespread problem that goes
across all projects. The problem is, there is no 'penalty' for leaving a
<code>1.2.3.qualifier</code> as the Manifest entry and just spinning out builds with
new build qualifiers in place.</p>

<p>The key advantage of having a different version numbering format between
release versions and pre-release versions is to ensure that at release, the
version number is updated appropriately. This means that the development
process generally follows:</p>

<ul>
<li>Create 1.0.0-SNAPSHOT for development</li>
<li>Do work</li>
<li>Release 1.0.0</li>
<li>Update version to 1.0.1-SNAPSHOT</li>
<li>Do work</li>
<li>Release 1.0.1 or 1.1.0 (or 2.0.0) as appropriate</li>
<li>goto 10</li>
</ul>


<p>The decision as to what to call the next number can either be tracked
by updates to the -SNAPSHOT itself (e.g. moving to 1.1.0-SNAPSHOT) or
can be deferred to later in the process. There's even tooling to help
you do that (the
<a href="http://maven.apache.org/plugins/maven-release-plugin/">mvn release plugin</a>) -- though this just removes the -SNAPSHOTS for you rather than
doing any semantic analysis.</p>

<p>This pattern is so common that it's even codified as a bullet point in
the Semantic Versioning specification:</p>

<blockquote><p>A pre-release version MAY be denoted by appending a dash and a series of dot
separated identifiers immediately following the patch version. Identifiers
MUST be comprised of only ASCII alphanumerics and dash [0-9A-Za-z-].
Pre-release versions satisfy but have a lower precedence than the associated
normal version. Examples: 1.0.0-alpha, 1.0.0-alpha.1, 1.0.0-0.3.7,
1.0.0-x.7.z.92.</p></blockquote>

<p>The 'pre-release versions satisfy but have a lower precedence than' sums
up the rule in a nutshell: in other words, anywhere a 1.2.3 is valid then
all 1.2.3-<em> are valid as well; anywhere a 1.2.3 is not valid then
all 1.2.3-</em> are not valid. So, in a range like <code>[1.2.3,4.5.6)</code> then any
pre-release state of 1.2.3-<em> is included, but any pre-release state of
4.5.6-</em> is not included.</p>

<p>This was even implemented successfully in Equinox, with an implementation
in <a href="http://download.eclipse.org/eclipse/downloads/drops4/S-4.2M6-201203151300/eclipse-news-M6.html#Equinox">3.8M6</a>.</p>

<p>Unfortunately, the concerns listed by the CPEG were out of touch with how
developers work outside of the OSGi space, and instead of reaching out
with a mechanism which would have been compatible for released artifacts
(whilst providing a SNAPSHOT style build system that would not be loadable
on older OSGi runtimes) it has been removed from the specification. Given that
OSGi R5 is a major release of the runtime, this would have been the ideal
time for introducing a new version syntax, and one that would have been
quickly adopted elsewhere.</p>

<p>So instead of having 'memorable' artifact names like <code>org.eclipse.ui_3.7.0.jar</code>
we'll be stuck with unmemorable names like
<code>org.eclipse.ui_3.7.0.v20110928-1505.jar</code> for the forseeable future in
the OSGi world. This causes more cognitive work for humans (trying to
remember the name) whilst introducing more opportunity for mistakes (by
releasing the same major/minor/patch with different builds).</p>

<p>This is what I refer to as humans solving the tooling problem, rather than
the other way around.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Declarative Services vs Objects]]></title>
    <link href="http://alblue.bandlem.com/2011/11/declarative-services-vs-objects.html"/>
    <updated>2011-11-16T20:00:00+00:00</updated>
    <id>http://alblue.bandlem.com/2011/11/declarative-services-vs-objects</id>
    <content type="html"><![CDATA[<p>I'm coming to the conclusion there is an opportunity for improvement of the Declarative Services specification. Right now, DS needs to be able to instantiate a class and then mutate it as services come and go, instead of creating and disposing of classes on demand.</p>


<p>This poses somewhat of a problem if you want to publish objects in the OSGi service registry of types which you don't control. According to the Declarative Services specification, you need to have an object which has a default constructor. The object is then fully configured with a number of <code>bind</code> and <code>unbind</code> methods, which means the object goes through a series of states where it is not fully valid.</p>


<p>There's also the category of classes which aren't under your control (e.g. an existing API) or are acquired elsewhere (e.g. a third party library). These often can't be extended or otherwise mutated.</p>


<p><b>Example</b></p>


<p>Let's say we want to have a list of URLs stored as services in the registry. We'll be publishing <code>URL</code> objects as the service (and using <code>java.net.URL</code> as the interface type as well; it is a contrived example, after all). Now, the URL doesn't have a default constructor; every URL must have a url. So we can use it for registering a component which needs a service (e.g. <code>BookmarkService</code>) quite happily. But we can't <em>register</em> a URL with DS.</p>


<p>This presents us with a challenge. We might have a component which can register URL services, but given a 1..n <code>BookmarkService</code> and no URLs published, Declarative Services can't help us. In essence, there's no way to have a delayed URL service in DS.</p>


<p>What you can do is provide a <code>URLFactoryService</code> with DS. This can be activated on demand, and a <code>registerURLs()</code> method called which in turn registers a bunch of <code>URL</code> objects in the registry; and once that's done, DS can kick off the <code>BookmarkService</code>.</p>


<p>Unfortunately, there's no way of being able to tell DS that the <code>URLFactoryService</code> is something which is capable of generating <code>URL</code> objects, so DS never knows it needs to start the <code>URLFactoryService</code> to acquire the <code>URL</code>s.</p>


<p><b>Solution</b></p>


<p>The solutions are either to not use DS to populate the initial set of URLs (and require an <code>earlyStart</code> or <code>startlevel</code> hack to bring the initial bundle on-line) or to modify DS in a way which allows the implementation class to be a factory for the interface type <em>but without being a subtype of it</em>. The existing factory specification currently requires that the factory class is still an instance of the interface class; all that changes is the cardinality.</p>


<p>Here's what the solution might look like:</p>


<blockquote><pre><code>
&lt;scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="URLdemo"&gt;
   &lt;implementation class="URLService"/&gt;
   &lt;service&gt;
      &lt;provide interface="java.net.URL"/&gt;
   &lt;/service&gt;
&lt;/scr:component&gt;
</code></pre></blockquote>


<p>In this case, the <code>URLFactoryService</code> doesn't implement/extend <code>java.net.URL</code>. But this tells DS that when this component is activated, it gets a <code>URL</code> out of it, which is what we want DS to know.</p>


<p>We could use a new API, like <code>ServiceOnDemand</code>, which is a generified type that can provide us with a service when we need it:</p>


<blockquote><pre><code>
public interface ServiceOnDemand&lt;T&gt; {
  public T getService();
}
</code></pre></blockquote>


<p>If the <code>URLFactoryService</code> implemented the <code>ServiceOnDemand&lt;URL&gt;</code> interface, then a call to <code>getService</code> would return us with the URL object that could subsequently be registered on our behalf into the service registry. We can still use the <code>bind</code> and <code>unbind</code> calls as before; they just affect the <code>ServiceOnDemand</code> dataset. After each change of the properties (and providing the component was valid) the <code>getService()</code> could be treated as a factory for these object types, being called only when it is in a fully configured state.</p>


<p>For tear down, it becomes just as easy. Instead of removing the <code>URLFactoryService</code> from the registry, we can just remove its previously generated <code>URL</code> objects. The new DS would have to co-ordinate to know which services were registered and associated with which factory; but this shouldn't be significantly different to the way the factory works at the moment.</p>


<p>We could also use this in conjunction with the DS factory class. The key difference here is that the factory class <em>must</em> implement the interface provided, which isn't necessarily always possible.</p>


<p><b>Summary</b></p>


<p>DS, and in particular its lazy activation of components, is a great way of providing systems which evolve into being. Unfortunately, the current system is constrained to allowing only objects to be registered to which the user has full control. Although the above used <code>URL</code> as an example, the same could also be said for network-discovered services such as over LDAP or DNS service records, or even database connections (which typically can't be subclassed since they are binary only drivers). Finally, this could be the missing link between config admin and declarative services, which have never really played well together. Being able to use DS to fire up a factory, which consumes its configuration and then is able to generate multiple services would allow us all to avoid the pain and effort that is otherwise trying to control start ordering in order to provide services dynamically.</p>

]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[OSGi Community Event 2011 - OSGi, Past Present and Future Keynote]]></title>
    <link href="http://alblue.bandlem.com/2011/09/osgi-community-event-2011-osgi-past.html"/>
    <updated>2011-09-26T09:00:00+01:00</updated>
    <id>http://alblue.bandlem.com/2011/09/community-event-2011-osgi-past</id>
    <content type="html"><![CDATA[<p>As I mentioned
<a rel="nofollow" href="http://alblue.bandlem.com/2011/09/speaking-at-osgi-community-event.html">a couple of weeks ago</a>,
last week I gave a keynote at the OSGi Community
Event. During the event I unveiled
<a rel="nofollow" href="http://alblue.bandlem.com/2011/09/omega-problem.html">the Omega problem</a>,
which is the condition whereby projects are given inexplicable and unmemorable
Greek letters, which unnecessarily interferes with getting started with OSGi.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[The Omega Problem]]></title>
    <link href="http://alblue.bandlem.com/2011/09/omega-problem.html"/>
    <updated>2011-09-21T09:00:00+01:00</updated>
    <id>http://alblue.bandlem.com/2011/09/omega-problem</id>
    <content type="html"><![CDATA[<p>What is the <span alt="Omega">&Omega;</span> problem? It's a problem caused by the use of greek letters and astrological signs to refer to OSGi projects (or <em>&Omega;SGi projects</em>), thereby hiding the purpose of the project itself behind a name that is likely to be both unfamiliar and eminently forgettable.</p>

]]></content>
  </entry>
  
</feed>

