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.
BookingService
interface and Booking
POJO.BookingService
using Component annotations.BookingService
reference injected thanks to Reference annotations.## 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:
karaf@root()> ----------- 1 - AF520 - John Doe ----------- 2 - AF59 - Alan Parker