Archive for the 'osgi' Category

ScalaModules slides from W-JAX 09 online

There were a lot of interesting talks at the OSGi Day at W-JAX. If you are interested in the slides of my ScalaModules talk you can take it from here: http://www.slideshare.net/heiko.seeberger/wjax-09-scalamodules

Invitation to improve ScalaModules’s DSL

Over the last months the ScalaModules team has worked on the upcoming 2.0 release. There will be a lot of improvements, e.g. auto-registration of service interfaces, operator notation, filters as objects and the user guide transferred to the Wiki. We are not ready for a final release yet, but most things should already be fairly stable.

There is still one thing we are racking our brains over a lot and maybe one of you could come up with a better solution that we have got right now. The new API for registering services offers auto-registration of service interfaces, such that there is no need to explicitly define the service interface(s). The following snippet will register the service greeting under the service interface Greeting, because greeting implements Greeting.

trait Greeting ...
val greeting = ...
ctx register greeting

Of course there are times when you want to explicitly register a service under a certain service interface. Now it would be very nice to write something like

ctx register greeting as classOf[AnotherInterface]

But this will not work in the current implementation, because register will be executed before as, which will register greeting under Greeting, just like above. Hence you have to use parenthesis like

ctx register (greeting as classOf[AnotherInterface])

Of course we have come up with a nice operator notation which takes the neccessary precedence into account. You could register greeting under the service interface AnotherInterface like this

ctx < greeting / classOf[AnotherInterface]

There is no need to use parenthesis here, because / will be executed first, because its precedence is higher than <.

But we would still like to get rid of the parenthesis in the "wordy" style. Roman already came up with an idea which you can take from the ScalaModules Google group. But when it comes to using as and withProps at the same time this is not adequate. So the question is, whether you have an idea how we could write something like

ctx register as classOf[AnotherInterface] withProps ("x" -> "y")

I am looking forward for your suggestions!

OSGi-fied Scala libraries updated to 2.7.6

Now that we have got Scala 2.7.6 I also updated the OSGi version of the Scala libraries. Please take it from the scala-tools.org Maven repository.

Currently there is an ongoing discussion about modularizing the official Scala code base, just take a look at the scala-internals mailing list. Hopefully we will see some success soon which might make the extra OSGi version obsolete though. But right now these extra OSGi-fied libraries are the way to go if you want to run OSGi on Scala or Scala on OSGi.

OSGi on Scala slides from OSGi DevCon Europe 09 online

In my former blog post I reasoned about whether I should do a live demo of OSGi on Scala / ScalaModules at OSGi DevCon Europe 09. As I received very positive feedback from the community (thanx for that!) I decided to go for it. Now I just finished my short talk and everything (at least the hacking part) went fine. For those not able to attend, please find the slides (which try to give you some live feeling) at my Slidespace.

Running OSGi and ScalaModules in Scala’s REPL

Next Monday I will talk about OSGi on Scala at OSGi DevCon Europe 09. As I have already given this talk twice (OSGi DevCon 09 and JAX 09), I am currently searching for some kind of fresh and cool style. Sitting in a very lonely German town I have come up with a crazy idea: Why not do the (short) talk using Scala's REPL (the interactive Scala console) instead of slides? To be honest, I am not yet sure whether to go this way, but my trials were very facinating and hence I would like to share my experiences with you.

OK, one step back. What exactly am I talking about? Well, fairly simple: Run the Scala REPL, launch OSGi (Felix, because it is very easy to launch/embed) to get a BundleContext (of the system bundle) and do some ScalaModules tricks to show the power of this DSL for OSGi.

In order to have Felix and ScalaModules on the classpath we have to copy felix.jar (currently using 1.8.0), scalamodules-core-1.1-SNAPSHOT.jar and scalamodules-util-1.1-SNAPSHOT.jar to a local directory and run Scala like this:

scala -cp felix.jar:scalamodules-core-1.1-SNAPSHOT.jar:scalamodules-util-1.1-SNAPSHOT.jar
scala>

First let's import some important stuff:

scala> import org.apache.felix.framework._
import org.apache.felix.framework._

scala> import org.scalamodules.core.RichBundleContext._
import org.scalamodules.core.RichBundleContext._

Then let's create and start Felix and get the BundleContext (which subsequently will be implicitly converted into a RichBundleContext):

scala> val felix = new Felix(null)
felix: org.apache.felix.framework.Felix = org.apache.felix.framework [0]

scala> felix.start

scala> val ctx = felix.getBundleContext
ctx: org.osgi.framework.BundleContext = org.apache.felix.framework.BundleContextImpl@e0c389

Then let's create a service interface:

scala> trait Greeting { def hello: String }
defined trait Greeting

Now let's use ScalaModules to (try to) get a Greeting service and use it. If you are experienced in OSGi you will know that for this task you would have to get a ServiceReference, check for null, get the service, check for null again and finally unget the ServiceReference again => Fairly low-level and involved. Now look at ScalaModules:

scala> ctx getOne classOf[Greeting] andApply { _.hello } match {
| case Some(s) => println(s)
| case None => println("No Greeting service available!")
| }
No Greeting service available!

OK, now let's register a Greeting service:

scala> val greeting = new Greeting { def hello = "Hello" }
greeting: java.lang.Object with Greeting = $anon$1@6159e9

scala> ctx registers classOf[String] theService greeting
:13: error: type mismatch;
found : java.lang.Object with Greeting
required: String
ctx registerAs classOf[String] theService greeting
^

As you can see, service registration with ScalaModules is type-safe at compile time. Hence let's do it right now and try to use it once more:

scala> ctx registerAs classOf[Greeting] theService greeting
res4: org.osgi.framework.ServiceRegistration = ...

scala> ctx getOne classOf[Greeting] andApply { _.hello } match {
| case Some(s) => println(s)
| case None => println("No Greeting service available!")
| }
Hello

There a lot of other things we could do the easy way using ScalaModules instead of OSGi API. I will show some more of these at my talk at OSGi DevCon Europe 2009, but first I have to decide whether using REPL for the talk is a good idea. What do you think?

OSGi-fied Scala libraries updated to 2.7.5

Some days ago Scala 2.7.5 was released and today I updated the OSGi version of the Scala libraries (see my former blog), too. I received some (positive) early feedback, but I am still very interested in knowing about any kind of real-world "production" usage.

Currently I am using these libraries in an effort to add OSGi support to Lift. This is very challenging, not only because of too little time, but also because Lift still has to work without OSGi. Well, hopefully I can get some basic OSGi support ready for Lift 1.1.

Eclipse Stammtisch Stuttgart June 4th

Eclipse Stammtische have been a lot of fun in the past. We are organizing the next one
together with Ralph Müller, representative of the Eclipse Foundation and Instinctools:

Date

04.06.2009 at 19:00

Location

Wirtschaftsförderung Stuttgart, 70174 Stuttgart,
Friedrichstraße 10
(If entrance is closed please call: 0160 8411709)

Agenda:

19:00

Overview of the Eclipse Foundation and news
about the Open Source Community

Ralph Müller, representative of the
Eclipse Foundation Europe

19:30

The Eclipse Financial Platform Proposal
Dr. Jörn Weigle,
Managing Director,
WeigleWilczek

19:45

OSGi on Clouds
Alexey Aristov,
R&D Director,
WeigleWilczek

20:00

Producing documentation for Eclipse
RCP applications
Alexej Spas,
Senior IT Manager,
*instinctools

20:30

Get together at „Joe Pena`s
Kriegsbergstr. 15, 70174 Stuttgart

We look forward to meeting you at the Eclipse Stammtisch!

Please let us know, if you participate by sending an e-mail to:

Yvonne Dotzauer dotzauer [at] weiglewilczek.com

or at doodle: http://doodle.com/t55ew57zuysbm4m9

Scala libraries as OSGi bundles

As OSGi purely relies on Java, it is easy and straightforward to enable OSGi for Scala: Just provide the Scala libraries (scala-lang.jar, scala-swing.jar, etc.) as OSGi bundles with suitable bundle manifests. The “official” Scala libraries are not (yet) delivered as OSGi bundles. There is an Eclipse plug-in which is part of the Scala IDE for Eclipse which basically is an OSGi bundle, but it is an all-in-one bundle (assembles scala-*.jar) and - very important - contains a rather special bundle manifest that is not-so-good for general purpose.

Therefore I have created the scala-lang-osgi project which provides OSGi bundles for each Scala library. No changes are made to the libraries themselves but only the necessary manifest headers are added to the MANIFEST.MF file. All OSGi-fied Scala libraries are deployed to the scala-tools.org Maven repository with group id org.scala-lang-osgi using the same artifact id and version as the non-OSGi Scala libraries (e.g. scala-library, scala-swing, etc.). Of course there is also a snapshot repository.

These OSGi-fied Scala libraries are already used in projects that rely on OSGi and Scala, e.g. ScalaModules and BindForge.  If you also go for OSGi on Scala, please give it a try and give me your feedback.

OSGi on Scala slides online

Roman and me just gave a talk about OSGi on Scala at the OSGi Experts Day (there are quite a lot of OSGi Days) at the JAX 09 conference. The audience was a little quiet and there were no questions - I guess they were very hungry and wanted to get out to lunch.

Nevertheless: Get fluent with ScalaModules and forge ahead with BindForge and tell us what you think!

OSGi Service Component Models slides online

Kai and me had a talk about OSGi Service Component Models at the OSGi Special Day at the JAX 09 conference. The place was pretty crowded and a lot of people showed up after the talk. Viva OSGi!