Book Image

Learning Karaf Cellar

By : Jean Baptiste Onofre, Jean-Baptiste Onofré
Book Image

Learning Karaf Cellar

By: Jean Baptiste Onofre, Jean-Baptiste Onofré

Overview of this book

Table of Contents (16 chapters)

The service bundle

The service bundle exposes a service to the service registry.

A service will be exposed to the distributed service registry just by adding the service.exported.interfaces property to the service.

First, the service bundle implements the Greet interface; it's the implementation of the Greet service, which is as follows:

package org.apache.karaf.cellar.samples.dosgi.greeter.service;

import org.apache.karaf.cellar.samples.dosgi.greeter.api.Greet;
import org.apache.karaf.cellar.samples.dosgi.greeter.api.GreetResponse;
import org.apache.karaf.cellar.samples.dosgi.greeter.api.Greeter;

 * Implementation of the Greeter service.
public class GreeterImpl implements Greeter {

  private int counter=0;
  private String id;

  public GreeterImpl(String id) { = id;

  public GreetResponse greet(Greet greet) {
      String message = greet.getMessage();
      String response = message+"." +String.format("Hello from node %s count %s.",id,counter++)...