introduction to-osgi

30
Introduction to OSGi using Apache Karaf Ioannis Canellos JHUG / 16 April 2011

Upload: ioannis-canellos

Post on 06-Jan-2017

9.222 views

Category:

Technology


3 download

TRANSCRIPT

Page 1: Introduction to-osgi

Introduction to OSGi using

Apache Karaf Ioannis Canellos

JHUG / 16 April 2011

Page 2: Introduction to-osgi

Presenting today…

OSGiOpen Services Gateway initiative, since 1999Initially targeted embedded devicesOSGi containers: Felix, Equinox, Knoperfish, ConciergeMost known use is Eclipse IDE

Apache KarafApache OSGi runtime runs on any OSGi containerBorn inside Service Mix, now is Top level projectStandard runtime for Geronimo, Service Mix, SlingEcosystem for deploying OSGi/EE applications

Page 3: Introduction to-osgi

Part IIntroduction to OSGi

Page 4: Introduction to-osgi

Introduction to OSGi

Problem

Solution

Architecture

Tools

OSGi in the Enterprise

Questions & Answers

Page 5: Introduction to-osgi

The problemaspects

Dependency managementVersion HellConflicting dependenciesClass loading issues

Dynamic behaviorDifficulties to control component lifecycle

Lack of a pure modularity solution

Page 6: Introduction to-osgi

The problemsDependency

managementLarge number of transitive dependencies

Conflicts among among dependencies

Class loading issuesBoot class loader

System class

loader

war war

JTA

JTA

Page 7: Introduction to-osgi

The problemsDynamic Behavior

Components & Services need come and go

Components need to get updated / replaced

Components need to started / stoppedReal life examples

Eclipse IDE

Adding/Removing “plugins”

Ebay

Multiple version of the same component

Page 8: Introduction to-osgi

The problemsModularity

The JVM does not address need for modularity

The class path paradoxThe jar is a “black box”

No dependencies & No versionThe pastitsio example

The “WORA” promise was repeatedly failedJavaBeansEJBs

Has the quest for modularity failed ?

OSGi is already hereProject Jigsaw will be shipped with JDK 8

Page 9: Introduction to-osgi

The OSGi SolutionOverview

A Layer …

A deployment infrastructureBundles = class + metadata (import/exports)Bundles have a lifecycleBundles have their own Class loaderClass loading delegation between dependant bundles

A service platformDefines a Service RegistryBundles provide or request servicesThe service can “come and go”

Page 10: Introduction to-osgi

Architecture

Page 11: Introduction to-osgi

Architecture Execution

EnvironmentThe Runtime where the bundles live

A bundle can bound to an Execution Environment

JOSGi/

Minimum-1.0

JRE-1.3

JRE-1.5

Page 12: Introduction to-osgi

Architecture Module Layer

Bundles import, export or have private packages

Each package can be assigned version range

A bundle (fragment) can be attached to a bundle (host)

Export Package

javax.transaction 1.01B

Export Package

javax.transaction 1.1

Import Package

javax.transaction [1.0,1.1)

Bundle Name: JMS APIImport Package: javax.transactionExport Package: javax.jmsBundle-RequiredExecutionEnvironment: J2SE-1.5

Page 13: Introduction to-osgi

Architecture Module Layer

a MANIFEST.MF exampleManifest-Version: 1.0

Import-Package:

javax.transaction;version="1.1”, javax.transaction.xa;version="1.1”

Export-Package:

javax.jms;version="1.1”

Bundle-SymbolicName: org.apache.geronimo.specs.geronimo-jms_1.1_spec

Tool: Bnd-0.0.227

Page 14: Introduction to-osgi

Stopped

Started

Starting

Uninstalled

Architecture Lifecycle Layer

resolve

update

refresh

uninstall uninstall

start

stop

Installed

Resolved

Page 15: Introduction to-osgi

Architecture Service Layer

Each bundle can register or lookup a Service

Each service corresponds to one or more interfaces

Each service can be assigned and queried using propertiesService

Registryregister lookup

Service Provider

Service Consum

er

Page 16: Introduction to-osgi

OSGi Toolsworking with

servicesManaging Services programmatically

Using the OSGi blueprintSpring Dynamic ModulesApache Aries

Felix i-Pojo

Page 17: Introduction to-osgi

OSGi Toolscreating bundles

Manually providing the MANIFEST.MF

Bnd command line tool

Maven Bundle Plug-in

Spring’s BundlorMaven plug-in flavorCommand line flavor

Page 18: Introduction to-osgi

OSGi ToolsOSGi Bundle

RepositorySimplifies the provisioning of bundles

The “apt-get install” for the OSGi

Integrates with public repositoriesEclipse OrbitSpring’s Enterprise Bundle Repository

Page 19: Introduction to-osgi

OSGi End of Part I

Questions & Answers

Page 20: Introduction to-osgi

Part IIGetting started with Apache

Karaf

Page 21: Introduction to-osgi

Apache Karafagenda

Overview

Shell Console

Deployer

Features Concept

Security

Logging Service

Demo

Questions and Answers

Page 22: Introduction to-osgi

Apache KarafOverview

Born as Service Mix Kernel project

Grown inside Apache Felix project

Become a Top Level Apache project last year

Page 23: Introduction to-osgi

Apache KarafShell ConsoleExtensible

Auto complete & coloring support

Rich command set, covers most OSGi concepts/services

Special commands for the development phase

Page 24: Introduction to-osgi

Apache KarafDeployer

Configuration Bundles Transforma

tion

File Scanner

Configuration

AdminURL

Handler

War Transforme

rSpringTransforme

rBlueprintTransforme

r

OBR Handler

HTTP Handler

Maven Handler

Hot deployment

Large number of supported artifacts

Large number of installation mediums

Page 25: Introduction to-osgi

Apache KarafFeatures ConceptA Karaf feature is a descriptor which defines…

A set of bundlesA set of configurationsA set of other features

Allows provisioning of applications

Maven integration

OBR integration

Page 26: Introduction to-osgi

Apache KarafFeatures Example

<feature name="http" version=”2.2.0” resolver=“(obr)”>

<config name="org.ops4j.pax.web”>

org.osgi.service.http.port=8181

</config>

<feature version="[7.0,8.0)">jetty</feature>

<bundle dependency=“true”>mvn:javax.servlet/servlet-api</bundle>

<bundle>mvn:org.ops4j.pax.web/pax-web-api</bundle>

</feature>

Page 27: Introduction to-osgi

Apache KarafSecurity

JAAS based security

Multiple login module implementationsProperty Login ModuleJDBC Login ModuleLDAP Login Module

Command line supportProvisioning of any JASS realm Add users roles etc

Page 28: Introduction to-osgi

Apache KarafLogging Service

Centralized Logging configuration

Supports most logging APIsLog4JSlf4j Commons Logging

Command line supportclear, display, tail change threshold etc.

OSGi integrationper bundle appender, osgi specific attributes

Page 29: Introduction to-osgi

Apache KarafEnd of Part II

Questions & Answers

Page 30: Introduction to-osgi

Thank you