14
OSGI Framework Overview A set of specification that defines a component system for java which is modular , dynamic & collaborativ e .

OSGI V4 an Overview

Embed Size (px)

Citation preview

Page 1: OSGI V4 an Overview

8/10/2019 OSGI V4 an Overview

http://slidepdf.com/reader/full/osgi-v4-an-overview 1/14

OSGI Framework Overview

A set of specification that defines a component system for java

which is modular , dynamic & collaborative .

Page 2: OSGI V4 an Overview

8/10/2019 OSGI V4 an Overview

http://slidepdf.com/reader/full/osgi-v4-an-overview 2/14

Agenda

• AEM Architecture

•Why OSGI ?

• Java Class Loader Delegation

• OSGI Architecture

 – Bundles

 – Services

 – Lifecycle

• OSGI Class Loader

• OSGI Bundle Life cycle

• Fragment Bundles

• OSGI Configuration Admin Service

• Q & A

Page 3: OSGI V4 an Overview

8/10/2019 OSGI V4 an Overview

http://slidepdf.com/reader/full/osgi-v4-an-overview 3/14

AEM Architecture

Key Considerations All the components like Sling , CRX , CQSE Servlet Engine are encapsulated with in the OSGI

framework . AEM uses the Apache Felix as the OSGI Container.

Page 4: OSGI V4 an Overview

8/10/2019 OSGI V4 an Overview

http://slidepdf.com/reader/full/osgi-v4-an-overview 4/14

Why OSGI ?

Few benefits a OSGI Components System provides

Reduced Complexity  : Bundles hide their internals and communicate to the external worldthrough well defined services . Extending these bundles with new changes is easy compared to amonolithic system as the changes are controlled . Changes in a monolithic system typically createsa Rippling Effect in the system .

Reuse : The services are stateless and emphasize on reusability . A centralized service registryensures that for decoupling the callers of the interface from the interface implementation .

Dynamic Updates : The OSGI component model is a dynamic model. Bundles can be installed,started, stopped, updated, and uninstalled without bringing down the whole system. Compared totraditional standalone java application , OSGI modules can be deployed with out affecting theother modules .

Versioning  : When a developer of a java application has made two versions of a library availableto a system , this will not be a reported as an error rather in a traditional java application theclasses will be loaded from one of the library . In OSGI , all bundles are versioned and only bundlesthat can collaborate are wired together .

Conflicting Dependencies - Whenever two different libraries are dependent on the differentversions third party library then there is no way to load both the versions of the third party libraryusing the same class loader .

Page 5: OSGI V4 an Overview

8/10/2019 OSGI V4 an Overview

http://slidepdf.com/reader/full/osgi-v4-an-overview 5/14

Java Class Loader Delegation

Key Considerations Java Classes are loaded using Class loaders and they are organized as Tree .

The classes are looked up in the below

Class Cache

Parent

Child

OSGI Class Loader

Page 6: OSGI V4 an Overview

8/10/2019 OSGI V4 an Overview

http://slidepdf.com/reader/full/osgi-v4-an-overview 6/14

OSGI Architecture

Bundles - Bundles are jar files with additional OSGI specific properties defined in its

manifest Services - The core of this layer is the services registry with which a bundle can create an

object and register under one or more service interface . The registered service can be

retrieved by another bundle by a look up in the service registry .

Life-Cycle - The API to install, start, stop, update, and uninstall bundles.

Modules - The layer that defines how a bundle can import and export code.

Security - The layer that handles the security aspects.

Execution Environment - Defines what methods and classes are available in a specificplatform.

Page 7: OSGI V4 an Overview

8/10/2019 OSGI V4 an Overview

http://slidepdf.com/reader/full/osgi-v4-an-overview 7/14

Bundles

• A bundle is a deliverable application . The framework itself is represented as a System bundles.

• A bundle can register zero or more services .

• A Bundle is normally packed in a Java Archive Format with additional information in themanifest like

 – Bundle Symbolic Name ( BSN - convention is to follow the reverse domain name )

 – Bundle Version (major .minor .micro.qualifier  )

 – Import Package List

 – Export Package List

 – Require Bundle List

 – A class that normally can start /stop the bundles ( Bundle Activators )

• Framework can install /update /uninstall bundles dynamically .

• Bundle can include embedded jar files with in it and use a Bundle Class path

Manifest entry to point to them.

Page 8: OSGI V4 an Overview

8/10/2019 OSGI V4 an Overview

http://slidepdf.com/reader/full/osgi-v4-an-overview 8/14

OSGI Class Loader

Key Considerations OSGI Core is placed in the normal Java class path is responsible for creating the framework

instance .

The framework maintains a list of bundle registry indicating the list of bundles loaded , the

class loaders. The bundle class loaders are responsible for maintaining the details extracted

from the MANIFEST file.

Page 9: OSGI V4 an Overview

8/10/2019 OSGI V4 an Overview

http://slidepdf.com/reader/full/osgi-v4-an-overview 9/14

OSGI Bundle Life Cycle

Key ConsiderationsOnce a bundle is installed it checks for whether all the dependencies are resolved .

A bundle moves from Installed To Resolved State if it is able to resolve the dependencies

mentioned in the Bundles Class Path , Package dependencies ,Required Bundles and Fragment

Dependencies

 Once the Bundles Activator Start method is called successfully the bundle moves on to Start

state . In case the bundle has a lazy Activation policy it will wait till the first class is loaded .

Page 10: OSGI V4 an Overview

8/10/2019 OSGI V4 an Overview

http://slidepdf.com/reader/full/osgi-v4-an-overview 10/14

Fragment Bundles

• A jar file with the entry Fragment-Host : {bundle-name} in its manifest file is an OSGI

Fragment .

• A bundle fragment has no effect at all if there is no installed bundle matching {bundle-name}

• Fragment bundles don’t carry an Activator and they don’t involve bundle life cycle . 

• Fragment bundles share the class loader of the their parent bundle .

•A typical use case for a fragment bundles is for importing classes available in a theApplication Servers class path by adding a fragment bundle to the system bundle .

Page 11: OSGI V4 an Overview

8/10/2019 OSGI V4 an Overview

http://slidepdf.com/reader/full/osgi-v4-an-overview 11/14

Configuration Admin Components Static View

client

bundle

Configuration

 Admin impl

Configuration

 Admin

Configuration

bundle

Managed

Service

client

bundle

Managed

ServiceFactory

Configuration

1

11

0..n

Configuration

Plugin

Plugin impl

Page 12: OSGI V4 an Overview

8/10/2019 OSGI V4 an Overview

http://slidepdf.com/reader/full/osgi-v4-an-overview 12/14

OSGI Configuration Admin Service

•Configuration Service is designed for a highly dynamic long livingenvironment .

• The receiver of a Configuration property register’s itself as a Managed

Service with a property called as service.pid to uniquely identify the

configuration property .

•  The Config Admin broadcasts the configuration properties to all ManagedServices .

• Any update on the Configuration Properties are also pushed to the

listening Managed Services .

• Plugins like File Install are few tools available for loading the configuration

properties .

• Configurations are Key / Value pairs .

Page 13: OSGI V4 an Overview

8/10/2019 OSGI V4 an Overview

http://slidepdf.com/reader/full/osgi-v4-an-overview 13/14

References

• http://jackrabbit.apache.org/oak/docs/differe

nces.html 

• http://www.slideshare.net/jukka/oak-the-

architecture-of-apache-jackrabbit-3 

Page 14: OSGI V4 an Overview

8/10/2019 OSGI V4 an Overview

http://slidepdf.com/reader/full/osgi-v4-an-overview 14/14

QA