osgi best practices shown on apache
TRANSCRIPT
![Page 1: OSGI Best practices shown on Apache](https://reader036.vdocument.in/reader036/viewer/2022071600/613d156f736caf36b7591e6d/html5/thumbnails/1.jpg)
OSGI Best practices shown on
Apache
![Page 2: OSGI Best practices shown on Apache](https://reader036.vdocument.in/reader036/viewer/2022071600/613d156f736caf36b7591e6d/html5/thumbnails/2.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022071600/613d156f736caf36b7591e6d/html5/thumbnails/3.jpg)
Agenda
● OSGi features and motivation● Karaf container● OSGi application best practices● Demo Tasklist application
![Page 4: OSGI Best practices shown on Apache](https://reader036.vdocument.in/reader036/viewer/2022071600/613d156f736caf36b7591e6d/html5/thumbnails/4.jpg)
OSGi Features
● Bundle Classloader (explicit Imports / Exports)● Bundle Lifecycle● Service Registry● Configuration
Admin Service
![Page 5: OSGI Best practices shown on Apache](https://reader036.vdocument.in/reader036/viewer/2022071600/613d156f736caf36b7591e6d/html5/thumbnails/5.jpg)
OSGi Best Practices - Motivation
OSGi is hard
![Page 6: OSGI Best practices shown on Apache](https://reader036.vdocument.in/reader036/viewer/2022071600/613d156f736caf36b7591e6d/html5/thumbnails/6.jpg)
OSGi Best Practices - Motivation
OSGi FunFollow Best Practices
![Page 7: OSGI Best practices shown on Apache](https://reader036.vdocument.in/reader036/viewer/2022071600/613d156f736caf36b7591e6d/html5/thumbnails/7.jpg)
Apache
Container ? Framework ?
Extras ?
![Page 8: OSGI Best practices shown on Apache](https://reader036.vdocument.in/reader036/viewer/2022071600/613d156f736caf36b7591e6d/html5/thumbnails/8.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022071600/613d156f736caf36b7591e6d/html5/thumbnails/9.jpg)
KarafOSGi Applikation
OSGi Best Practices
Config
ServicesBlueprint
Bundle creation
![Page 10: OSGI Best practices shown on Apache](https://reader036.vdocument.in/reader036/viewer/2022071600/613d156f736caf36b7591e6d/html5/thumbnails/10.jpg)
Tasklist Example
TaskTaskService
Model
Persistence
TaskServiceImpl
UI-Vaadin
ImplementsUses
ExampleApplication
![Page 11: OSGI Best practices shown on Apache](https://reader036.vdocument.in/reader036/viewer/2022071600/613d156f736caf36b7591e6d/html5/thumbnails/11.jpg)
Creating Bundles with maven
maven-bundle-plugin
bnd
jar File with OSGi Manifest
![Page 12: OSGI Best practices shown on Apache](https://reader036.vdocument.in/reader036/viewer/2022071600/613d156f736caf36b7591e6d/html5/thumbnails/12.jpg)
Dynamic Wiring
OSGi is dynamic in nature Bundles, Services, Config
Isn't that complicated ?
![Page 13: OSGI Best practices shown on Apache](https://reader036.vdocument.in/reader036/viewer/2022071600/613d156f736caf36b7591e6d/html5/thumbnails/13.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022071600/613d156f736caf36b7591e6d/html5/thumbnails/14.jpg)
Blueprint
Aries Blueprint (Spring like dependency injection for OSGi)
declarative dynamic wiring
![Page 15: OSGI Best practices shown on Apache](https://reader036.vdocument.in/reader036/viewer/2022071600/613d156f736caf36b7591e6d/html5/thumbnails/15.jpg)
OSGi Services
SAregister
Bget listen
Java Object
Java Interface + Properties +
priority
Bundle ServiceBundle
![Page 16: OSGI Best practices shown on Apache](https://reader036.vdocument.in/reader036/viewer/2022071600/613d156f736caf36b7591e6d/html5/thumbnails/16.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022071600/613d156f736caf36b7591e6d/html5/thumbnails/17.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022071600/613d156f736caf36b7591e6d/html5/thumbnails/18.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022071600/613d156f736caf36b7591e6d/html5/thumbnails/19.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022071600/613d156f736caf36b7591e6d/html5/thumbnails/20.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022071600/613d156f736caf36b7591e6d/html5/thumbnails/21.jpg)
DEMO
![Page 22: OSGI Best practices shown on Apache](https://reader036.vdocument.in/reader036/viewer/2022071600/613d156f736caf36b7591e6d/html5/thumbnails/22.jpg)
Advanced Topics
● CDI on OSGi (Weld-OSGi, Karaf EE, Glassfish)● DOSGi (CXF-DOSGi)● Aries JPA and JTA
![Page 23: OSGI Best practices shown on Apache](https://reader036.vdocument.in/reader036/viewer/2022071600/613d156f736caf36b7591e6d/html5/thumbnails/23.jpg)
Questions?
(c) Damian Navas
![Page 24: OSGI Best practices shown on Apache](https://reader036.vdocument.in/reader036/viewer/2022071600/613d156f736caf36b7591e6d/html5/thumbnails/24.jpg)
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