Best practices für Services und Integration in OSGi
Speaker
Christian Schneider
Open Source Architect bei Talend
Committer bei
Blog:
Ziele
Was möchte ich vermitteln?
Beispiel Voting
Idee
Beispiel Voting - Architektur
model
Vote, Voting,�VoteService
service
VoteService impl
Rest Service
UI
jQuery
Twitter Adapter
Camel Route, Twitter Component
OSGi Service
module dependency
service dependency
Front End
Service
Model
OSGi Features
Apache
Container ?
Framework ?
Extras ?
Apache
OSGI Framework (Felix / Equinox)
HTTP
JAAS
Spring
Console
Logging
Deployer
Instance
Blueprint
Core
WAR
Standard
Enterprise
OBR
JPA
JTA
Cellar
KAR
CXF
Camel
ActiveMQ
JClouds
OpenEJB
Webconsole
Management
Extern
OSGi Best Practices
Karaf
OSGi Applikation
Config
Services
Blueprint
Bundle creation
Bundles erzeugen mit maven
maven-bundle-plugin
bnd
jar Datei mit OSGi Manifest
Dynamic Wiring
OSGi ist dynamisch
Bundles, Services, Config
Ist das nicht kompliziert?
Dynamic Wiring
Ja .. wenn man dagegen arbeitet
Dependency Injection
Aries Blueprint oder Declarative Services�(Dependency injection für OSGi)
deklaratives dynamisches wiring
OSGi Services
S
A
register
B
get listen
Java Object
Java Interface + Properties +
priority
Bundle
Service
Bundle
OSGi Services in Blueprint
Provider
Consumer
mandatory: Blueprint Kontext startet nur wenn der service verfügbar ist
<bean id="voteService" class="net.lr.tutorial.karaf.vote.service.MemoryVoteService" />�<service ref="voteService" interface="net.lr.tutorial.karaf.vote.model.VoteService" />
<reference id="voteService" interface="net.lr.tutorial.karaf.vote.model.VoteService"/>
ConfigAdmin Service
pid=net.lr.myconfig
key1=value1
key2=value2
Configuration
update(Properties)
Service Registry
register
update()
triggert
ManagedService
Configuration getConfiguration(String pid)
Configuration[] listConfigurations(String filter)
ConfigurationAdmin
ConfigAdmin Service
in 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>
Kontext Neustart bei Änderung in der Konfiguration
Konfigurationswerte sind als Variablen verfügbar
ConfigAdmin Service�in Apache Karaf
Felix�Fileinstall
etc
change
pid.cfg
ConfigAdmin
Update
polls
Property-Dateien
dynamische updates
Managed Service
Create /
Update
Deployment
Feature
Feature repo
Bundle
1..*
1..*
features:addurl mvn:net.lr.tasklist/tasklist-features/1.0.0-SNAPSHOT/xml
features:install example-tasklist
DEMO
CXF und Blueprint
<bean id="voteService" class="net.lr.tutorial.karaf.vote.service.MemoryVoteService" />
<jaxrs:server address="/vote" id="voting-jaxrs-server">
<jaxrs:serviceBeans>
<ref component-id="voteService" />
</jaxrs:serviceBeans>
</jaxrs:server>
<jaxws:endpoint implementor="#voteService" address="/votesoap"/>
Advanced Topics
Fragen?
Links
Christian Schneider
Voting Beispiel: https://github.com/cschneider/Karaf-Tutorial/tree/master/voting
Apache Karaf Tutorials: http://liquid-reality.de/display/liquid/Karaf+Tutorials
OSGi - Alliance http://www.osgi.org
Apache Karaf http://karaf.apache.org/
Apache Felix http://felix.apache.org/
Apache Aries Blueprint http://aries.apache.org/modules/blueprint.html
Talend ESB (based on Apache Karaf): http://www.talend.com/products/esb
Konzept Verteilter ESB
Container 1
Container N
Service
Integration
Web Applikation
...
Security
Service Locator
Messaging Broker
Logging Server
Eigene Module
ESB Infrastruktur
Registry
Querschnitt
Management