2. What is it?
“The Open Services Gateway initiative framework is a
module system and service platform for the Java programming
language that implements a complete and dynamic component model,
something that as of 2012 does not exist in standalone Java/VM
environments.” – Wikipedia
OSGi Platform
3. … module system …
“The Open Services Gateway initiative framework is a
module system and service platform for the Java programming
language that implements a complete and dynamic component model,
something that as of 2012 does not exist in standalone Java/VM
environments.” – Wikipedia
OSGi Platform
4. … service platform …
“The Open Services Gateway initiative framework is a
module system and service platform for the Java programming
language that implements a complete and dynamic component model,
something that as of 2012 does not exist in standalone Java/VM
environments.” – Wikipedia
OSGi Platform
5. … for Java programming language …
“The Open Services Gateway initiative framework is a
module system and service platform for the Java programming
language that implements a complete and dynamic component model,
something that as of 2012 does not exist in standalone Java/VM
environments.” – Wikipedia
OSGi Platform
6. …complete and dynamic component model …
“The Open Services Gateway initiative framework is a
module system and service platform for the Java programming
language that implements a complete and dynamic component
model, something that as of 2012 does not exist in standalone
Java/VM environments.” – Wikipedia
OSGi Platform
7. … does not exist in standalone Java/VM …
“The Open Services Gateway initiative framework is a
module system and service platform for the Java programming
language that implements a complete and dynamic component
model, something that as of 2012 does not exist in standalone
Java/VM environments.” – Wikipedia
OSGi Platform
8. OSGi history
o Initially was developed as an embedded platform for the “home
gateway”;
o and make it easier to deploy Java application on embedded devices
o OSGi Alliance was formed in 1999, and it has following mission:
• Maintaining and publishing OSGi specification
• Certifying implementations
• Organizing events.
o Specification target was: “Define Java-based service platform, full
dynamic component model”
• Because JVM does not support natively dynamic module system
– starting, stopping, updating application at runtime
• JAR dependencies management missing
OSGi Platform
8/42
10. The Dream
Adaptive
o Flexible
A
B
C
D
E
F
G
H
I
o Contracts
o Robust
o Secure
o Evolution
o Distributed
OSGi Platform
10/42
11. The Dream
Adaptive
o Flexible
A
B
C
D
E
F
G
H
I
o Contracts
o Robust
o Secure
o Evolution
o Distributed
OSGi Platform
11/42
12. The Dream
Adaptive
Flexible
A
Ba
Bb
C
o Contracts
o Robust
D
E
F
G
H
I
o Secure
o Evolution
o Distributed
OSGi Platform
12/42
13. The Dream
Adaptive
Flexible
A
Ba
Bb
C
o Contracts
o Robust
D
E
F
G
H
I
o Secure
o Evolution
o Distributed
OSGi Platform
13/42
14. The Dream
Adaptive
Flexible
A
Ba
Bb
C
Contracts
o Robust
D
E
F
G
H
I
o Secure
o Evolution
o Distributed
OSGi Platform
14/42
15. The Dream
Adaptive
Flexible
A
Ba
Bb
C
Contracts
o Robust
D
E
F
G
H
I
o Secure
o Evolution
o Distributed
OSGi Platform
15/42
16. The Dream
Adaptive
Flexible
A
Ba
Bb
C
Contracts
Robust
D
E
G
F
H
o Secure
o Evolution
o Distributed
OSGi Platform
16/42
17. The Dream
Adaptive
Flexible
A
Ba
Bb
C
Contracts
Robust
D
E
G
F
H
o Secure
o Evolution
o Distributed
OSGi Platform
17/42
18. The Dream
Adaptive
Flexible
A
Ba
Bb
C
Contracts
Robust
D
E
G
F
H
Secure
o Evolution
o Distributed
OSGi Platform
18/42
19. The Dream
Adaptive
Flexible
A
Ba
Bb
C
Contracts
Robust
D
E
G
F
H
Secure
o Evolution
o Distributed
OSGi Platform
19/42
20. The Dream
Adaptive
Flexible
A
Ba
Bb
C
Contracts
Robust
D
E
F
G
H
I v2.0
Secure
o Evolution
o Distributed
OSGi Platform
20/42
21. The Dream
Adaptive
Flexible
A
Ba
Bb
C
Contracts
Robust
D
E
F
G
H
I v2.0
Secure
Evolution
o Distributed
OSGi Platform
21/42
22. The Dream
Adaptive
Flexible
A
Ba
Bb
C
Contracts
Robust
D
E
F
G
H
I v2.0
Secure
Evolution
o Distributed
OSGi Platform
22/42
23. The Dream
Adaptive
Flexible
A
Ba
Bb
Contracts
Robust
D
E
F
Secure
Evolution
Distributed
G
OSGi Platform
I v2.0
23/42
24. What is an OSGi application
o Collection of bundles integrated via Service interfaces
o Bundles may be independently developed and deployed
o Bundles and their associated services may appear or
disappear at any time
o Resulting application follows a Service-Oriented
Component Model approach
o Combines Ideas from both component and service orientation
OSGi Platform
24/42
25. Architecture abstraction
o Application is a set of independent components,
collaborating between each other in a service orienting
way.
Application
A
C
D
B
E
OSGi Platform
F
25/42
26. Architecture abstraction
o Application implement reduced functionality, all
additional features implements as plug-ins
C
A
Application
B
D
E
OSGi Platform
F
26/42
28. Next level of modularity
Subroutines
(50’s)
×
×
×
×
Focus on “what”, not “how”
Encapsulate the implementation details
Formalize the input data (arguments)
Formalize the output data (return values)
OSGi Platform
28/42
29. Next level of modularity
Input (arguments)
function
Output (return)
Then systems grew…
Functions
Subroutines
(50’s)
Spaghetti Code
OSGi Platform
29/42
30. Next level of modularity
Imported Functions
Module
Exported Functions
Then systems grew…
Modules
(70’s)
Functions
Subroutines
(50’s)
Sharing Proved Hard
OSGi Platform
30/42
31. Next level of modularity
Imported Members
Type
Exported Members
Then systems grew…
Classes/Objects (80’s)
Modules
(70’s)
Functions
Subroutines
(50’s)
OSGi Platform
31/42
32. Next level of modularity
Imported Types
Packages
(90’s)
Type
Exported Types
Then and multiplies
…… systems grew…
and distributed
Classes/Objects (80’s)
Modules
(70’s)
Functions
Subroutines
(50’s)
OSGi Platform
32/42
33. Next level of modularity
Small Java App …
OSGi Platform
33/42
35. Bundle
o A Bundle - is a module in OSGi terminology
o What is a bundle?
• Simply a JAR file plus module metadata
• Modules metadata is stored in META-INF/MANIFEST.MF
• Define what the module provides and require
o What does a bundle JAR contain?
• Java classes (i.e., standard JAR file content)
• Resources (e.g., configuration files, images, etc.)
• Native code
• Embedded JAR files
• Bundles have their own class path
OSGi Platform
35/42
37. Life cycle of bundles
INSTALLED
STARTING
RESOLVED
ACTIVE
UNINSTALLED
STOPPING
OSGi Platform
37/42
38. Services System
o Services are simple POJOs with a published service interface
o Coupling to the framework is isolated to the Activator and
collaborators
o Services may bind to other services through their published
interfaces
o The framework provides a standard Service Factory mechanism
track
publish
Bundle A
Bundle B
Service Registry
track
publish
Bundle C
Service
OSGi Platform
38/42
50. OSGi implementations
o Specification it is good, but without implementation it
is a dead stuff
o The most popular open source implementation is:
• Equinox
• Apache Felix
• Knopflerfish
OSGi Platform
50/42
51. OSGi in Enterprise (as example)
o Why?
• Create modular and reusable software
• Create evolvable software
• Create line of products
o What?
•
•
•
•
•
•
Desktop Applications
Web Applications
Service Layers
Content Management Systems
Embedded and Mobile Applications
Cloud Applications
OSGi Platform
51/42
52. Conclusions
o Java needs improved modularity support
• Lagging behind .NET in this area for years
• The OSGi framework provides it now
o Importance and relevance of OSGi is growing
• Industry support for mobile applications
• Significant uptake in the enterprise space
OSGi Platform
52/42