Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Learning Karaf Cellar

You're reading from   Learning Karaf Cellar Build and implement a complete clustering solution for the Apache Karaf OSGi container

Arrow left icon
Product type Paperback
Published in Jul 2014
Publisher
ISBN-13 9781783984602
Length 124 pages
Edition 1st Edition
Arrow right icon
Authors (2):
Arrow left icon
Jean Baptiste Onofre Jean Baptiste Onofre
Author Profile Icon Jean Baptiste Onofre
Jean Baptiste Onofre
Jean-Baptiste Onofré Jean-Baptiste Onofré
Author Profile Icon Jean-Baptiste Onofré
Jean-Baptiste Onofré
Arrow right icon
View More author details
Toc

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) {
      this.id = id;
  }

  @Override
  public GreetResponse greet(Greet greet) {
      String message = greet.getMessage();
      String response = message+"." +String.format("Hello from node %s count %s.",id,counter++)...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image