Tuesday, March 26, 2013

OSGi DevCon 2013 - Whats Coming Up This Week

Wow, Day 1 of OSGi DevCon is already over.  The location here in Boston this year is excellent,  plenty of space and pretty good wifi, although they seem to be selling out of beers too fast at the hotel bar!  If you want to keep up with the latest activity be sure to follow the OSGi Alliance Twitter feed (@osgialliance).

Day 1 was Tutorials day and Neil Bartlett and Tim Ward both had good attendance at their OSGi Tutorials. There were also two OSGi BOFs in the evening.  Jamie Goodyear hosted a Karaf Users BOF and Glyn Normington and Chris Frost hosted a Virgo BOF.

But Day 1 was just the warm up.... There is a really full schedule of talks and activities planned over the next three days.

You can find the full conference schedule for the talks online.

A few activities that aren't in the main schedule and which may be of interest include:

OSGi BOF this evening - 7pm to 9pm in Seaport Ballroom B - You can find full details of the BOF here.
  • Highlights include an update on the latest OSGi specifications and a sneak peak of whats coming up in the future
  • OSGi Tooling discussion

Also there will be a free prize draw to win one of several OSGi Books, so plenty of swag too!

OSGi and JavaScript Workshop - Thurs March 28, 1.30pm to 3.30pm 
Simon Kaegi, who is presenting at the conference on the same topic, will be hosting this workshop to look at how OSGi concepts might map to JavaScript, with the aim to gather requirements and foster discussion around producing an OSGi Alliance RFP for this.  So this is your chance to get involved and input and influence in to a potential future OSGi specification.

The Workshop is free for anyone to attend.  Both conference delegates and non-conference delegates.  However you do need to register to ensure you get access.  Click here for full details and to register.

OSGi Surgery
There is an OSGi Surgery being run where you can book a free 30 minute one on one meeting with Neil Bartlett to discuss anything OSGi.

Whether you want to review code or an issue you are having, explore how OSGi might fit in your environment, or if you are brand new to OSGi and just want to ask some newbie questions that you dont feel comfortable asking in one of the talks then this is a great opportunity.  Slots are limited and you need to book in advance.  Details and how to book can be found here.

Hope you have been able to join us at the conference and enjoy Day 2!  If you have any questions please contact us by email.

OSGi DevCon 2013 Program Committee
BJ Hargrave & Mike Francis


Thursday, March 14, 2013

New OSGi Early Access Drafts available

Earlier this week a new OSGi Early Access Draft was made available. A lot of new work is currently underway in both the Enterprise Expert Group (EEG) as well as the Core Platform Expert Group (CPEG) and in this document you can see where things currently are. Below you can find a short summary of each of the RFCs to get an idea what they are about.

RFC 180 - Portable Java Contracts. This RFC is about how you import technologies that originated in the JCP and specifically how these are versioned. A previous version of this RFC was included in the last EA draft and you can find more information on what RFC 180 is about in this posting:
http://osgithoughts.blogspot.com/2012/10/new-osgi-eeg-early-access-draft.html

RFC 182 - Defines a REST Management Interface for OSGi Frameworks. A number of remote management specifications already exist for OSGi, but especially in the context of Cloud Computing a REST-based management API is highly desirable. This is defined in RFC 182.

RFC 183 - Cloud Ecosystems. This RFC defines how a number of OSGi frameworks can work together in a Cloud Computing context, or other environment where multiple frameworks collaborate together. It describes how OSGi frameworks and their associated node-related meta-data can be discovered within the Ecosystem. It also covers how these frameworks can communicate across nodes to provide a fluid environment where a logical application is spread across multiple nodes and its components and services can easily be moved from one VM to another to deal with changes in machine load, available resources and other constraints.

RFC 184 - Blueprint 1.1. This RFC defines a collection of updates to the Blueprint specification that include the ability to switch off damping, change the behavior of the grace period and other changes.

RFC 185 - Data Transfer Objects. OSGi has always provided mechanisms for remotely managing its technology, but as the number of specs and the number of management technologies both grew maintaining coverage across all specs for all management technologies became a challenge. Data Transfer Objects provide a means for an OSGi specification to provide information suitable for a management agent in a technology-neutral style. The idea is that every OSGi spec defines its DTOs and that this can then be easily, possibly mechanically, mapped to most management technologies, so that they are kept up-to-date with a lot less effort than what was previously required. RFC 182 builds on top of these DTOs, other management specs (such as JMX) will most likely be updated in the future to take advantage of them too.

RFC 187 - Complex Repository Requirements. The Enterprise R5 specification defines the OSGi Repository spec. This was really the first Bundle Repository specification, although the Apache Felix project did have an OBR project before. The OSGi Repository is a simple yet powerful spec, which defines an API that allows one to find resources based on capabilities. RFC 187 adds a small enhancement to this specification which makes the querying mechanism even richer. It allows the combination of multiple capability namespaces into a single query so that you can express things like: I need a bundle that exports package org.foo and has license X. Or I need a bundle that provides the Declarative Services capability and has passed our company's internal QA process.

RFC 188 - Native Namespace. This specification adds a capability namespace for the generic OSGi Capabilities and Requirements model to represent the Bundle-NativeCode header. While other requirements in the Bundle Manifest, such as Import-Package or Fragment-Host can already be described using generic requirement namespaces, the Bundle-NativeCode did not have such a mapping yet. This RFC addresses this issue.

RFC 189 - HTTP Service Updates. The HTTP Service specification has been around for a long time and has seen many projects using it. However, it was long due an update to modernize it in relation to the Servlet Specification and the way people generally use OSGi Services. This RFC brings the HTTP Service spec up-to-date. It makes it possible to use Servlet Filters, adds the ability to use the Whiteboard pattern and provides additional configuration mechanisms.

RFC 191 - Weaving Hook Enhancements. This RFC enhances the Weaving Hooks allowing consumers to find out in what stage the weaving of a certain class is. In particular it helps the Subsystems specification to react appropriately to any imports that were added dynamically during the weaving phase.

RFC 193 - CDI Integration. This RFC focuses on how CDI beans can be deployed in OSGi and how these interact with the OSGi Service Registry. It brings annotation-based interaction with OSGi Services based on the popular CDI annotations. As with any OSGi component technology that uses the Service Registry, it will allow you to mix-and-match them. So a CDI bean can be injected by a service created in a Blueprint component. Similarly a simple Declarative Services client could obtain a service that was created in a CDI bean, and so on...

RFC 195 - Service Scopes. Up until now the OSGi Service Registry has supported two models. Either a registered service instance is shared across all consuming bundles or each distinct client bundle gets a separate instance. Recent work in the context of CDI and EJB integration (an OSGi/EJB RFC is being worked on but didn't make this draft) indicates that additional models are desirable. For example where a new service instance is returned every time the service is obtained, to fit stateful session models. This RFC describes additions to the OSGi Service Registry that support these models.

You can find the full documents in the EA draft at the following link: http://www.osgi.org/Download/File?url=/download/osgi-early-draft-2013-03.pdf

If you are interested in becoming involved in any of these RFCs, join our efforts: http://www.osgi.org/Join. If you already work for a member company, contact the EEG or CPEG chairs for more information on getting involved see http://www.osgi.org/EEG or http://www.osgi.org/CPEG.

Also note that some of these topics will be discussed at EclipseCon/OSGi DevCon Boston March 25-28. For more information see here: http://blog.osgi.org/2013/03/boston-calling.html

Wednesday, March 13, 2013

Boston Calling

OSGi DevCon 2013, one of our main events of the year, is just 11 days away.. 
 
Will you be joining us in Boston at the Seaport Hotel & World Trade Center?

We have a jam packed schedule with a full program of OSGi Tutorials and Talks, an OSGi BOF on Tuesday evening and an OSGi and JavaScript Workshop on Thursday.  There is plenty on offer whether you are an OSGi beginner or more.experienced.  If you havent registered already be sure to sign up soon.

The conference program Talks are:
  • Modularizing Large Legacy Java Applications
  • Deploying Heterogeneous Artifacts to the Cloud with OSGi
  • Winning the WAR on complexity
  • Managing Installations and Provisioning of OSGi Applications
  • Enabling Smart Data on M2M Gateways and Aggregators
  • OSGi and JavaScript
  • RFC-193: Bringing CDI to the OSGi platform
  • Liberate your components with OSGi services
  • Modularity in the Cloud: A case study
  • What’s new in the Http Service Specification
  • DS, BP, EJB, CDI,WTF!?
  • Cooking up a Runtime with the new OSGi Resolver
  • Master Bundle Buildling
  • OSGi Cloud Ecosystems
  • Practical OSGi Subsystems
  • Apache Karaf in the Trenches
  • OSGi server runtimes – build, borrow or buy?
And the tutorials are:
  • Mastering OSGi with Ease
  • Stack Roulette - 180 Runtimes in 180 Minutes!
For anyone that hasnt been to an OSGi DevCon before then on top of all of this there will be plenty of OSGi experts and OSGi Alliance representatives in attendance who will be pleased to answer any of your questions.  Its also a great opportunity to network with your peers, to learn more about how OSGi is being used, and find out about the latest and greatest advancements and future capabilities that are being planned.

We hope to see you March 25 to 28.

REGISTER NOW




Monday, February 25, 2013

New OSGi Tool Chain Documentation

People sometimes say that OSGi is hard to use because tooling support is lacking. Well, there are actually quite a lot of OSGi-related tools out there, but many of them address a specific area. They often work together with other tools to address a larger context. A modular approach to tooling, if you like... One of the issues with this approach was however that it could be hard to find out how these tools are working together to address a real life scenario. An example scenario would be how to set up an entire development environment that includes a headless build, and IDE with debugging facilities and a testing environment. Documentation describing how to do all this using a combination of existing tools was not easily available.

Over the past months a number of people have worked together on creating a set of documentation pages that describe various OSGi toolchains: how a number of tools can be combined to create an end-to-end solution. For example, it describes how Bndtools can be used with Ant and Eclipse to create a comprehensive development setup. But there are more options. Not everyone uses Bndtools, other people might use Tycho with Eclipse and Maven. This is also documented. As is how to use Maven with Bnd, Eclipse and Pax-Exam. 
Additionally there is a page describing how to set up a Scala build environment for OSGi using SBT.

All the details of how to get going are described on a new set of pages focusing on documenting OSGi tool chains on the OSGi wiki. You can find them here: http://wiki.osgi.org/wiki/ToolChains

The pages that are there now are just a starting point. They should get you going with a number of OSGi tooling technologies. As most of the pages use a similar example it is also possible to compare the various approaches. However, there is always room for improvement. As this is an open environment feel free to contribute. If you are using a different toolset, document it! Or if you have anything to improve the descriptions add it in!

http://wiki.osgi.org/wiki/ToolChains

Tuesday, February 19, 2013

java.util.ServiceLoader in OSGi

When migrating existing projects to OSGi, generally the biggest issue is the modularization of the code. Non-modular projects might have built up dependencies over time that you weren't aware of, with the risk of creating a spaghetti-like dependency chain in the end. Migrating to OSGi modularity gets rid of that spaghetti. However there are sometimes other challenges, one of which can be getting java.util.ServiceLoader to work inside OSGi.

ServiceLoader was introduced in Java 6 to generalize the various forms of 'FactoryFinder' patterns that were in existence throughout the JRE. It provides a basic plug-in model where implementations of a class (subclasses) or an interface can advertise themselves via a file that has the name of that interface (or class) in the META-INF/services directory of a Jar file. When looking up implementations via ServiceLoader.load(someClass.class), ServiceLoader scans all the Jars visible to the Thread Context Classloader for the associated file in META-INF/services and then uses a zero-arg constructor to instantiate the classes found.

There are a number of issues with this for a modular environment. First of all, ServiceLoader is non-modular by design in that it expects visibility of all Jars in the system, as they can all potentially contain an implementation. Additionally, depending on the Thread Context Classloader is also a questionable design decision as that can only really work well in situations where there is only 1 classloader (e.g. the system classpath) or in situations where all threads are managed by a container. In OSGi this is clearly not the case, as OSGi bundles are free to create threads and an OSGi system typically contains many classloaders.
Note that ServiceLoader also has a load(Class, ClassLoader) API which does not suffer from the issues described above.
Still we want to be able to make existing libraries that rely on ServiceLoader work in OSGi. The OSGi Enterprise R5 specs contain the ServiceLoader Mediator specification which addresses this issue.

ServiceLoader provider
Let's first look at the provider side. An obvious thing to do with bundles that contain META-INF/services resources is to register them as OSGi Services so that OSGi-aware consumers can simply use them from the OSGi Service Registry. So you'll get that with an implementation of this spec. For example take the following provider bundle where the org.acme.MySpiImpl class implements the foo.bar.MySPI interface. In this bundle,

the META-INF/services/foo.bar.MySPI file contains:
  org.acme.MySpiImpl

META-INF/MANIFEST.MF contains:
  Require-Capability: osgi.extender;
    filter:="(osgi.extender=osgi.serviceloader.registrar)"
  Provide-Capability: osgi.serviceloader;
    osgi.serviceloader=foo.bar.MySPI

The ServiceLoader mediator is controlled through the OSGi Manifest via generic capabilities and requirements. This mechanism was introduced in the OSGi 4.3 core specification. Basically what the two lines in the manifest state is that a Service Loader registrar extender is required and that the bundle provides the osgi.serviceloader capability for foo.bar.MySPI.

Once the provider bundle has been extended by the ServiceLoader mediator, you can find its corresponding service present in the OSGi Service Registry:

  g! inspect capability service 8
  org.acme.provider.bundle [8] provides:
  -------------------------------------------
  service; foo.bar.MySPI with properties:
    service.id = 17
    serviceloader.mediator = 6

you can identify services that are registered this way by the fact that the serviceloader.mediator property is present.

The OSGi Service Registry provides a much richer service environment than the functionality provided by java.util.ServiceLoader as besides the ability to plug-in service implementations it supports a dynamic lifecycle (services can come and go) and it has its rich service lookup query mechanism - plus it is designed to work in a modular environment.

If you can change the client-side code that uses the provider to consume it from the OSGi Service Registry, you have all you need at this point.

ServiceLoader consumer
However, in some cases you may not have access to the client-side code that is using ServiceLoader.load(). Maybe you're using an existing library that was written in another project. Maybe you're using a commercial library that you can't modify. For these cases the Service Loader Mediator specification also describes a way to get existing ServiceLoader.load() consumer code to work. While implementations can implement this in any way they like, the Reference Implementation in Apache Aries (SPI Fly) makes this work by keeping track of the providers and then, using byte code instrumentation, set the Thread Context ClassLoader to provide visibility of the appropriate provider jars for the duration of the ServiceLoader.load() call in the consumer bundle. Here's an example:

The consumer may contain code similar to:
  ServiceLoader<MySPI> ldr = ServiceLoader.load(MySPI.class);
  for (MySPI spiObject : ldr) {
    spiObject.doit(); // invoke the SPI object
  }

In the META-INF/MANIFEST.MF, the consumer bundle has:
  Require-Capability: osgi.extender;
      filter:="(osgi.extender=osgi.serviceloader.processor)",
    osgi.serviceloader;
      filter:="(osgi.serviceloader=foo.bar.MySPI)";
      cardinality:=multiple

This may look like a mouthful, but it's basically two generic OSGi requirements stated in a single Require-Capability header. The consumer requires the osgi.serviceloader.processor extender. This extender is responsible for ensuring that the ServiceLoader.load() call has the Thread Context Classloader set. The consumer also requires the osgi.serviceloader capability for foo.bar.MySPI. This capability is provided by the provider bundle and effectively instructs the extender what to set the TCCL to.

As with the provider, the consumer needs to opt in to the process by specifying the requirement headers in the OSGi manifest, however you don't need to change the actual client side code. If you don't want to modify the original Jar file at all you can wrap it as-is in an OSGi bundle, and provide the additional Manifest header in the wrapped bundle. Or you can simply add the additional manifest header to the existing Jar, whichever you prefer.

The Service Loader Mediator specification helps with migrating existing libraries that use java.util.ServiceLoader to OSGi and is available since June 2012 as part of the Enterprise R5 release. The Reference Implementation at Apache Aries is now released at version 1.0. For the consumer side, Aries comes in 2 variants: one that uses static weaving: you run a command-line tool on the consumer jar which then produces a new jar that works in OSGi. The other variant uses dynamic weaving, which means that you can install your consumer bundle as-is and have it processed at run-time in the OSGi Framework. More details on the RI can be found here: http://aries.apache.org/modules/spi-fly.html

As with any OSGi Specification, you can always check this Wikipedia page for additional implementations: http://en.wikipedia.org/wiki/OSGi_Specification_Implementations

Thursday, February 14, 2013

New Server for OSGi

The OSGi Alliance had been using a dedicated server for various functions for many years. But it was getting to be too old to continue to be used. It was running RHEL 4 and I could not find a Java 7 binary for that and I was not interested in trying to compile OpenJDK from source!

So this past week, I migrated and upgraded the various services (osgi.org and osgiusers.org websites, bugzilla systems, hudson build system, mailman mail lists, git and subversion repositories, ldap user database) from the old server to a shiny new server. I even able to install Java 7.

Most people probably did not notice the migration as the websites were only down for about 10 minutes while the ip addresses were switched between servers.

So hopefully, the OSGi community can enjoy our new server for a number of years to come.

Tuesday, February 12, 2013

OSGi DevCon 2013 Registration Deadline & Workshop Announced

OSGi DevCon 2013 in Boston, MA is inching closer. If you haven't registered yet, then be sure to do so by close on Thursday this week (14 Feb) as thats the deadline for the Advanced discounted passes giving you a saving of $500.

Plus if you are from an OSGi Member company then be sure to use the OSGI coupon code when you register for an addition $100 off your pass. You can find further details on how to register on the OSGi DevCon 2013 home page.

OSGi & JavaScript Workshop Announced

We are pleased to announce an OSGi and JavaScript Workshop at OSGi DevCon 2013. This will be taking place from 13.30hrs to 15.30hrs on Thursday March 28. The workshop is free to attend and open to all (both conference and non-conference delegates), however places are strictly limited so be sure to REGISTER soon.

The workshop will be hosted by Simon Kaegi, from IBM, who has been working in this area for some time.  The workshop will include a short presentation looking at how OSGi concepts might map to JavaScript and will be followed by open discussion. The aim of the session will be to gather requirements and foster discussion around producing an OSGi Alliance RFP.

Further details about the workshop and how to register can be found here.  As ever if you have any questions you can reach the Program Committee by email.

Looking forward to seeing you in Boston next month.

OSGi DevCon 2013 Program Committee
BJ Hargrave & Mike Francis