Gert Vanthienen's blog

Tuesday, January 26, 2010

Scala on Karaf

Over the holiday season, I had a bit of spare time to work the Camel Scala DSL again. While doing this, I realized that it was a bit too hard to actually use the Scala DSL on Karaf (need to configure Maven to use both the Scala plugin and the Felix bundle plugin to build the deployable jar).

Wouldn't it be nice to just drop a Scala source file in Karaf's deploy folder and get everything done automatically? With this idea in mind, I started a new project called Slang on the FUSE Forge to add support for additional languages to Karaf.

You can now try out a first shot at the Scala language support - you still have to build it yourself at the moment, but once you installed the feature on Karaf, you can just drop this source file in the deploy folder:

import org.fusesource.slang.scala.common.ScalaActivator

package org.fusesource.slang.scala.examples

class Activator extends ScalaActivator {

  publish(new HelloWorldServiceImpl())

class HelloWorldServiceImpl extends HelloWorldService {
  def hello = println("Saying hello")

trait HelloWorldService {
  def hello

The result will be a bundle on Karaf that exports the HelloWorldService interface and has published the HelloWorldServiceImpl in the OSGi Service Registry. Next on my todo list is to actually get it to run the Camel route built in the Scala DSL this way.

Labels: ,


  • Very interesting idea. We could use the same approach with BluePrint service, Spring DM, ...
    The contract should be that we provide the interface(s) and class(s) implementing them. When deployed, the XML or even better @Annotations are added to allow the services to be published in OSGI and available from other bundles or Web Resource (using @Resource) !

    By Blogger cmoulliard, At January 26, 2010 at 5:20 PM  

Post a Comment

Subscribe to Post Comments [Atom]

<< Home