1. First steps in OSGi
Andrea Chiodoni, 2009
martedì, 17 maggio 2011
2. Understand:
what OSGi is, why OSGi
a n d w h y it i s s o
important to the Java
community.
martedì, 17 maggio 2011
3. Agenda
Jar Hell problem
A definition of OSGi
Modularity and Java
Architecture
Versioning
Sample: Activator
Sample: Service
OSGi implementations
Tools for OSGi
Repositories
Advanced topics
What comes next...
martedì, 17 maggio 2011
4. Jar Hell problem
Missing Module construct at Bootstrap Class Loader
runtime: JARs are only knows at ${JAVA_HOME}/jre/lib/rt.jar
build and deploy time
Delegate to
Information hiding not properly Extension Class Loader
enforced ${JAVA_HOME}/jre/lib/ext/
Version information not consumed Delegate to
at runtime System Class Loader
${CLASSPATH}
Java SE/EE are subject to JAR Hell
Delegate to
problem
User-Defined Class Loader(s)
JAR specification is too old for the
time being (JARs are not modules)!
martedì, 17 maggio 2011
5. Modularity and Java 1/2
JSR 277: Java Module System
A new module system for Java (JAR -> JAM)
Abandoned the 3.12.2008, proceed under Project
Jigsaw
Project Jigsaw (OpenJDK)
Many discussions around “The massive, monolithic
JDK”
Low-level module system to modularise the JDK 7
Available for developers to use in their own code
Not an official part of the Java SE 7!
Interoperate with other module systems (OSGi)
Apache Harmony (based on OSGi core)
martedì, 17 maggio 2011
6. Modularity and Java 2/2
Open Service Gateway initiative (OSGi)
from OSGi Alliance, founded 1999 (Ericsson, IBM,
Oracle,...)
The Dynamic Module System for Java
Target: embedded, client, server systems
Widely adopted: even by SUN (Glassfish v3)
R1 (JSR 8) in May 2000, R4.1 (JSR 291) in May 2007
(current release)
Will be closer to Java (language extensions), SUN-
OSGi Alliance effort (JSR 294)
martedì, 17 maggio 2011
7. What is OSGi
Extension of the JAR
Module = bundle
Naming + definition
Versioning
■ Gestione automatica delle dipendenze
■ Gestione del ciclo di vita del codice (configurazione e distribuzione dinamica)
martedì, 17 maggio 2011
8. Layered architecture
Services
Bundles
Security
Life Cycle
Modules
Execution Environment
Java VM
Native Operating System
martedì, 17 maggio 2011
9. Bundle states
install refresh
update
Installed Starting
resolve refresh
update start
Resolved Active
stop
uninstall uninstall
Stopped
Uninstalled
Explicit transition
Automatic transition
martedì, 17 maggio 2011
10. Service Registry
Service Registry
publish Service discover
Description
Service Provider Service Requester
<<bundle>> <<bundle>>
bind
martedì, 17 maggio 2011
11. Sample:xx
<<bundle>> <<bundle>>
<<service>>
A S B
register get
listen
martedì, 17 maggio 2011
12. Execution Environments
Eclipse Equinox
Eclipse
Spring DM Server
mBedded Server Equinox Edition
Apache Felix
ServiceMix Kernel
Knopflerfish
martedì, 17 maggio 2011
13. Development Tools
Eclipse
Maven Bundle Plugin (Apache Felix)
http://www.springsource.com/repository
Bundle Tool (BND), http://www.aqute.biz/
Code/Bnd
martedì, 17 maggio 2011
14. What comes next
Advanced OSGi
Standard Services
Whiteboard Pattern
Event Admin
Extender Model Building WEB applications
OSGi Bundle Repository (OBR, RFC 112)
Spring Dynamic Modules
Distributed OSGi Specification (RFC 119, OSGi
R4.2)
SCA and OSGi
martedì, 17 maggio 2011