Top Banner
OSGI Best practices shown on Apache
24

OSGI Best practices shown on Apache

Sep 12, 2021

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: OSGI Best practices shown on Apache

OSGI Best practices shown on

Apache

Page 2: OSGI Best practices shown on Apache

Speaker

Christian Schneider Open Source Architect at Talend

Working on ● Apache Karaf● Apache CXF● Apache Camel● OPS4j pax url, pax exam

Blog:http://www.liquid-reality.de

Page 3: OSGI Best practices shown on Apache

Agenda

● OSGi features and motivation● Karaf container● OSGi application best practices● Demo Tasklist application

Page 4: OSGI Best practices shown on Apache

OSGi Features

● Bundle Classloader (explicit Imports / Exports)● Bundle Lifecycle● Service Registry● Configuration

Admin Service

Page 5: OSGI Best practices shown on Apache

OSGi Best Practices - Motivation

OSGi is hard

Page 6: OSGI Best practices shown on Apache

OSGi Best Practices - Motivation

OSGi FunFollow Best Practices

Page 7: OSGI Best practices shown on Apache

Apache

Container ? Framework ?

Extras ?

Page 8: OSGI Best practices shown on Apache

Apache

OSGI Framework (Felix / Equinox)

HTTP

JAAS

Spring

Console LoggingDeployer

Instance

Blueprint

Cor

e

WARSta

ndar

dE

nter

pris

e

OBR

JPA JTA Cellar

KAR

CXF Camel ActiveMQ JClouds OpenEJB

Webconsole Management

Ext

erna

l

Page 9: OSGI Best practices shown on Apache

KarafOSGi Applikation

OSGi Best Practices

Config

ServicesBlueprint

Bundle creation

Page 10: OSGI Best practices shown on Apache

Tasklist Example

TaskTaskService

Model

Persistence

TaskServiceImpl

UI-Vaadin

ImplementsUses

ExampleApplication

Page 11: OSGI Best practices shown on Apache

Creating Bundles with maven

maven-bundle-plugin

bnd

jar File with OSGi Manifest

Page 12: OSGI Best practices shown on Apache

Dynamic Wiring

OSGi is dynamic in nature Bundles, Services, Config

Isn't that complicated ?

Page 13: OSGI Best practices shown on Apache

Dynamic Wiring

Yes ... if you fight it

● Startlevel tuning● Import Services by Hand● Update configs by hand

Page 14: OSGI Best practices shown on Apache

Blueprint

Aries Blueprint (Spring like dependency injection for OSGi)

declarative dynamic wiring

Page 15: OSGI Best practices shown on Apache

OSGi Services

SAregister

Bget listen

Java Object

Java Interface + Properties +

priority

Bundle ServiceBundle

Page 16: OSGI Best practices shown on Apache

OSGi Servicesin Blueprint

Provider

Consumer

mandatory: Context only starts when service is available

<bean id="taskService" class="net.lr...TaskServiceImpl" />

<service ref="taskService" interface="net.lr.tasklist.model.TaskService"/>

<reference id="taskService" availability="mandatory" interface="net.lr.tasklist.model.TaskService" />

Page 17: OSGI Best practices shown on Apache

ConfigAdmin Service

pid=net.lr.myconfig

key1=value1key2=value2

Configuration

update(Properties)

Service Registry

register

update()triggert

ManagedService

Configuration getConfiguration(String pid)Configuration[] listConfigurations(String filter)

ConfigurationAdmin

Page 18: OSGI Best practices shown on Apache

ConfigAdmin Servicein Blueprint

<cm:property-placeholder persistent-id="ConfigApp" update-strategy="reload">

<cm:default-properties>

<cm:property name="title" value="Default Title"/>

</cm:default-properties>

</cm:property-placeholder>

<bean id="myApp" class="net.lr...MyApp" init-method="refresh">

<property name="title" value="${title}"></property>

</bean>

Context Kontext Restart on config changes

Keys available as placeholders

Page 19: OSGI Best practices shown on Apache

ConfigAdminin Apache

FelixFileinstall

etc change

pid.cfg ConfigAdminUpdate

polls

property files dynamic updates

Managed Service

Create /Update

Page 20: OSGI Best practices shown on Apache

Deployment

FeatureFeature repo Bundle

1..* 1..*

features:addurl mvn:net.lr.tasklist/tasklist-features/1.0.0-SNAPSHOT/xmlfeatures:install example-tasklist

Page 21: OSGI Best practices shown on Apache

DEMO

Page 22: OSGI Best practices shown on Apache

Advanced Topics

● CDI on OSGi (Weld-OSGi, Karaf EE, Glassfish)● DOSGi (CXF-DOSGi)● Aries JPA and JTA

Page 24: OSGI Best practices shown on Apache

LinksChristian Schneider

http://www.liquid-reality.de@schneider_chrishttps://github.com/cschneider

Apache Karaf Tutorials: http://liquid-reality.de/display/liquid/Karaf+TutorialsOSGi - Alliance http://www.osgi.orgApache Karaf http://karaf.apache.org/Apache Felix http://felix.apache.org/Apache Aries Blueprint http://aries.apache.org/modules/blueprint.htmlTalend ESB (based on Apache Karaf): http://www.talend.com/products/esb