tree: 41adf07df3816b7f787e4dfadcc7a19ee7354f0e [path history] [tgz]
  2. karaf-scr-example-api/
  3. karaf-scr-example-client/
  4. karaf-scr-example-features/
  5. karaf-scr-example-provider/
  6. pom.xml

Apache Karaf SCR example


SCR (Service Component Runtime) is a convenient way to use services with annotations.

As it‘s part of the OSGi compendium specification, you don’t need any large dependency to use it.


  • karaf-ds-example-api provides the BookingService interface and Booking POJO.
  • karaf-ds-example-provider implements and exposes a BookingService using Component annotations.
  • karaf-ds-example-client uses a BookingService reference injected thanks to Reference annotations.
  • karaf-ds-example-features contains a Karaf features repository used for the deployment.

## Build

Simply use Apache Maven:

mvn clean install

## Features and Deployment

On a running Karaf instance, you register the example features repository with:

karaf@root()> feature:repo-add mvn:org.apache.karaf.examples/karaf-scr-example-features/LATEST/xml

Then, you can install the karaf-scr-example-client feature:

karaf@root()> feature:install karaf-scr-example-client

This feature installs the karaf-scr-example-provider feature providing the service, and the client bundle.


When you install the client feature, you should see on the console:

1 - AF520 - John Doe

2 - AF59 - Alan Parker