/karaf-blueprint-fragment

This example show how to create fragment for bundles

Primary LanguageJava

Abstract

This project show you how to create fragment in OSGi for extending bundles that exist.

Common bundle contains two interfaces, UserServiceFragment is not exported and not accessible by other bundle to provide service according to it.

Fragment bundle is a fragment for Common bundle to exporting another package of it.

Host bundle is a provider that implement all interfaces that exported by Common and Fragment

Client bundle get services of Host and use them.

Install

Compile Project

$ mvn install

Deploy Bundles

  • Install aries-blueprint
$ karaf@root()> feature:install aries-blueprint
  • Deploy Common bundle
$ karaf@root()> bundle:install -s mvn:com.khtm.test/common/1.0.0-SNAPSHOT
  • Deploy Fragment bundle
$ karaf@root()> bundle:install mvn:com.khtm.test/fragment/1.0.0-SNAPSHOT
  • Deploy Host bundle
$ karaf@root()> bundle:install -s mvn:com.khtm.test/host/1.0.0-SNAPSHOT
  • Deploy Client bundle
$ karaf@root()> bundle:install -s mvn:com.khtm.test/client/1.0.0-SNAPSHOT

Output

after installing Client bundle output display as follow:

User(id=1, firstName=alireza, lastName=khatami doost)
User(id=2, firstName=majid, lastName=vakili)
User(id=3, firstName=morteza, lastName=mosavi)

Repository Address: https://github.com/alirezakhtm/karaf-blueprint-fragment