Osgi platform
Upcoming SlideShare
Loading in...5
×
 

Osgi platform

on

  • 309 views

Open Services Gateway Initiative slides from Kiev JavaDay 2012 (27 October) Conference

Open Services Gateway Initiative slides from Kiev JavaDay 2012 (27 October) Conference

Statistics

Views

Total Views
309
Views on SlideShare
309
Embed Views
0

Actions

Likes
0
Downloads
6
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Osgi platform Osgi platform Presentation Transcript

  • OSGi platform Yuriy Shapovalov EPAM Systems
  • 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
  • … 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
  • … 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
  • … 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
  • …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
  • … 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
  • 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
  • The Dream o Adaptive B C D E F G H I o Flexible o Contracts o Robust o Secure o Evolution o Distributed OSGi Platform 9/42
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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
  • The Dream  Adaptive  Flexible A Ba Bb C  Contracts  Robust D E G F H  Secure o Evolution o Distributed OSGi Platform 18/42
  • The Dream  Adaptive  Flexible A Ba Bb C  Contracts  Robust D E G F H  Secure o Evolution o Distributed OSGi Platform 19/42
  • 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
  • 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
  • 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
  • The Dream  Adaptive  Flexible A Ba Bb  Contracts  Robust D E F  Secure  Evolution  Distributed G OSGi Platform I v2.0 23/42
  • 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
  • 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
  • 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
  • Architecture abstraction o or even… Application A B A C B D E OSGi Platform D E 27/42
  • 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
  • Next level of modularity Input (arguments) function Output (return) Then systems grew… Functions Subroutines (50’s) Spaghetti Code OSGi Platform 29/42
  • 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
  • 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
  • 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
  • Next level of modularity Small Java App … OSGi Platform 33/42
  • Next level of modularity Bundles Packages (00’s) (90’s) Classes/Objects (80’s) Modules Imported Packages Bundle (JAR file) Exported Packages (70’s) Functions Subroutines (50’s) OSGi Platform 34/42
  • 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
  • OSGi architecture Application composite (Bundles) OSGi Layer Service Bundle Bundle Bundle Life Cycle Bundle Bundle Module Bundle Bundle Security Java VM OS / Hardware OSGi Platform 36/42
  • Life cycle of bundles INSTALLED STARTING RESOLVED ACTIVE UNINSTALLED STOPPING OSGi Platform 37/42
  • 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
  • OSGi Bundle Manifest Bundle-ManifestVersion: 2 Bundle-SymbolicName: org.foo.simplebundle Bundle-Version: 1.0.0 Bundle-Activator: org.foo.Activator Bundle-ClassPath: .,org/foo/embedded.jar Bundle-NativeCode: libfoo.so; osname=Linux; processor=x86, foo.dll; osname=Windows 7; processor=x86 Import-Package:o sgi.service.log; version="[1.0.0,1.1.0)"; resolution:="optional" Export-Package: org.foo.service; version=1.1; vendor="org.foo:"; exclude:="*Impl", org.foo.service.bar; version=1.1; uses:="org.foo.service" OSGi Platform 39/42
  • OSGi Bundle Manifest Bundle-ManifestVersion: 2 Bundle-SymbolicName: org.foo.simplebundle Bundle-Version: 1.0.0 Indicates semantic Bundle-Activator: org.foo.Activator and syntax Bundle-ClassPath: .,org/foo/embedded.jar Bundle-NativeCode: libfoo.so; osname=Linux; processor=x86, foo.dll; osname=Windows 7; processor=x86 Import-Package:o sgi.service.log; version="[1.0.0,1.1.0)"; resolution:="optional" Export-Package: org.foo.service; version=1.1; vendor="org.foo:"; exclude:="*Impl", org.foo.service.bar; version=1.1; uses:="org.foo.service" OSGi Platform 40/42
  • OSGi Bundle Manifest Bundle-ManifestVersion: 2 Bundle-SymbolicName: org.foo.simplebundle Bundle-Version: 1.0.0 Bundle-Activator: org.foo.Activator Indicates semantic Globally unique ID and syntax Bundle-ClassPath: .,org/foo/embedded.jar Bundle-NativeCode: libfoo.so; osname=Linux; processor=x86, foo.dll; osname=Windows 7; processor=x86 Import-Package:o sgi.service.log; version="[1.0.0,1.1.0)"; resolution:="optional" Export-Package: org.foo.service; version=1.1; vendor="org.foo:"; exclude:="*Impl", org.foo.service.bar; version=1.1; uses:="org.foo.service" OSGi Platform 41/42
  • OSGi Bundle Manifest Bundle-ManifestVersion: 2 Bundle-SymbolicName: org.foo.simplebundle Bundle-Version: 1.0.0 Bundle-Activator: org.foo.Activator Bundle-ClassPath: .,org/foo/embedded.jar Bundle-NativeCode: libfoo.so; osname=Linux; processor=x86, Life cycle entry foo.dll; osname=Windows 7; processor=x86 point Import-Package:o sgi.service.log; version="[1.0.0,1.1.0)"; resolution:="optional" Export-Package: org.foo.service; version=1.1; vendor="org.foo:"; exclude:="*Impl", org.foo.service.bar; version=1.1; uses:="org.foo.service" OSGi Platform 42/42
  • OSGi Bundle Manifest Bundle-ManifestVersion: 2 Bundle-SymbolicName: org.foo.simplebundle Bundle-Version: 1.0.0 Bundle-Activator: org.foo.Activator Bundle-ClassPath: .,org/foo/embedded.jar Bundle-NativeCode: libfoo.so; osname=Linux; processor=x86, foo.dll; osname=Windows 7; processor=x86 Internal bundle Import-Package:o sgi.service.log; version="[1.0.0,1.1.0)"; class path resolution:="optional" Export-Package: org.foo.service; version=1.1; vendor="org.foo:"; exclude:="*Impl", org.foo.service.bar; version=1.1; uses:="org.foo.service" OSGi Platform 43/42
  • OSGi Bundle Manifest Bundle-ManifestVersion: 2 Bundle-SymbolicName: org.foo.simplebundle Bundle-Version: 1.0.0 Native code Bundle-Activator: org.foo.Activator dependencies Bundle-ClassPath: .,org/foo/embedded.jar Bundle-NativeCode: libfoo.so; osname=Linux; processor=x86, foo.dll; osname=Windows 7; processor=x86 Import-Package:o sgi.service.log; version="[1.0.0,1.1.0)"; resolution:="optional" Export-Package: org.foo.service; version=1.1; vendor="org.foo:"; exclude:="*Impl", org.foo.service.bar; version=1.1; uses:="org.foo.service" OSGi Platform 44/42
  • OSGi Bundle Manifest Bundle-ManifestVersion: 2 Bundle-SymbolicName: org.foo.simplebundle Bundle-Version: 1.0.0 Bundle-Activator: org.foo.Activator Optional Bundle-ClassPath: .,org/foo/embedded.jar dependency on a package version Bundle-NativeCode: libfoo.so; osname=Linux; processor=x86, range foo.dll; osname=Windows 7; processor=x86 Import-Package: osgi.service.log; version="[1.0.0,1.1.0)"; resolution:="optional" Export-Package: org.foo.service; version=1.1; vendor="org.foo:"; exclude:="*Impl", org.foo.service.bar; version=1.1; uses:="org.foo.service" OSGi Platform 45/42
  • OSGi Bundle Manifest Bundle-ManifestVersion: 2 Bundle-SymbolicName: org.foo.simplebundle Bundle-Version: 1.0.0 Bundle-Activator: org.foo.Activator Bundle-ClassPath: .,org/foo/embedded.jar Provided package with Bundle-NativeCode: libfoo.so; osname=Linux; processor=x86, foo.dll; osname=Windows 7;arbitrary attribute and processor=x86 excluded classes Import-Package:o sgi.service.log; version="[1.0.0,1.1.0)"; resolution:="optional" Export-Package: org.foo.service; version=1.1; vendor="org.foo:"; exclude:="*Impl", org.foo.service.bar; version=1.1; uses:="org.foo.service" OSGi Platform 46/42
  • OSGi Bundle Manifest Bundle-ManifestVersion: 2 Bundle-SymbolicName: org.foo.simplebundle Bundle-Version: 1.0.0 Bundle-Activator: org.foo.Activator Bundle-ClassPath: .,org/foo/embedded.jar Bundle-NativeCode: libfoo.so; osname=Linux; processor=x86, Provided package with foo.dll; osname=Windows 7; processor=x86 dependency on Import-Package:o sgi.service.log; exported package version="[1.0.0,1.1.0)"; resolution:="optional" Export-Package: org.foo.service; version=1.1; vendor="org.foo:"; exclude:="*Impl", org.foo.service.bar; version=1.1; uses:="org.foo.service" OSGi Platform 47/42
  • Declarative Services o Declarative services provides a minimally intrusive way to: • Define components that provide and use services • Automate dependency resolution and maintenance package foo.impl; public class HelloImpl implements foo.HelloService { LogService log; protected void setLog(LogService l) { log = l; } protected void unsetLog(LogService l) { log = null; } public void sayHello(String s) { log.log(LogService.LOG_INFO, "Hello " + s); } } OSGi Platform 48/42
  • Declarative Services o Declarative services component metadata: <?xml version="1.0" encoding="UTF-8"?> <component name="example.hello"> <implementation class="foo.impl.HelloImpl"/> <service> <provide interface="foo.HelloService"/> </service> <reference name="LOG" interface="org.osgi.service.log.LogService" bind="setLog" unbind="unsetLog" /> </component> OSGi Platform 49/42
  • 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
  • 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
  • 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
  • Questions? OSGi Platform 53/42