SlideShare a Scribd company logo
OSGI Modularity
Pubudu Dissanayake
The What and Why of OSGI
What do you mean by “Modularity” ?
the logical decomposition of a large
system into smaller collaborating pieces
Widely accepted specification which introduces a standard way of
building dynamic, modular systems with Java.
What is OSGi?
Why OSGI ?
Java’s modularity limitations
● Low-level code visibility control
Java’s modularity limitations Cont..
● Error-Prone Classpath concept
The classpath pays no attention to code versions - it returns first version it finds.
Class Path Hell !
Typical Java Application
● Runtime vs Compile time difference.
○ Flat, single classpath.
Java’s modularity limitations Cont..
● No standard way of building a modular system.
○ Class loader based techniques.
● If you need to add new functionality or update existing functionality, JVM needed to be restarted.
● Can you update a part(can be a JAR file) of a running Java application?
● Java lacks dynamism
Can OSGI help you ?
● Allow us to understand the system easily
● Allow us to develop module by module
● Allow us to reuse developed modules
● ClassNotFoundException when starting your application
● Execution time error due to wrong version of dependent library
● Packaging an application as logically independent JAR files and deploying only those pieces
you need for a given installation.
● Packaging an application as logically independent JAR files, declaring which code is accessible
from each JAR file, and having this visibility enforced.
“Yes !! ” Still not convinced ??
Next level of Modularity
An Architectural overview of OSGI
OSGI Framework
As of now, there are 3 implementations
● Apache Felix
● Eclipse Equinox
● Knopflerfish
Module Layer Lifecycle Layer
Service Layer
OSGI Modularity
● Is how OSGI refers to its specific realization of the module concept
● Is a jar file with extra Meta-data. bundles typically aren’t entire application
packaged into single jar file.
● Is more powerful than a jar file because it can explicitly declare visibility of its
packages. Thus it extends normal access modifies association with java
Bundle
The Bundle role in physical modularity
● Is to determine module membership
● Given class is a member of a bundle if it’s contained in the bundle jar
● Bundle jar is a container of bundle metadata -- Manifest
Bundle role in logical Modularity
● Is to logically encapsulate member classes. what does this mean ?
○ Visibility of the code
Defining Bundle with metadata
● Human-readable information—Optional information intended purely as an aid to humans who
are using the bundle
● Bundle identification —Required information to identify a bundle
● Code visibility —Required information for defining which code is internally visible and which
internal code is externally visible
● Human-readable information
Bundle-Name: Simple Paint API
Bundle-Description: Public API for a simple paint program.
Bundle-DocURL: http://www.manning.com/osgi-in-action/
Bundle-Category: example, library
Bundle-Vendor: OSGi in Action
Bundle-ContactAddress: 1234 Main Street, USA
Bundle-Copyright: OSGi in Action
Bundle identification
● For example, Bundle-Name seems like it could be a form of bundle identification
It isn’t.
unique bundle identifier was proposed to maintain backward compatibility it’s called
Bundle-SymbolicName: org.foo.shape
● only intended for the OSGi framework to help uniquely identify a bundle.
A bundle is uniquely identified by its Bundle-SymbolicName and Bundle-Version.
Bundle-SymbolicName: org.foo.shape
Bundle-Version: 2.0.0
OSGI Version Number format
● major – Changes for an incompatible update for both a consumer and a provider of an API.
● minor – Changes for a backward compatible update for a consumer but not for a provider.
● micro – A change that does not affect the API, for example, a typo in a comment
● Qualifier - e.g. 1.2.0.alpha
Code visibility
● Internal bundle class path—The code forming the bundle
● Exported internal code—Explicitly exposed code from the bundle class path for sharing with
other bundles
● Imported external code—External code on which the bundle class path code depends
Recap
If the JAR file has a Main-Class
java -jar app.jar
If not,
java -cp app.jar org.foo.Main
Bundle-ClassPath
The Bundle-ClassPath specifies where to load classes from from the bundle.
Bundle-ClassPath: .
Loading from nested JARs (whether packed or unpacked):
Bundle-ClassPath: foo.jar,other.jar,classes
Export - Package
Export-Package : A comma-separated list of internal bundle packages to
expose for sharing with other bundles
Export-Package: org.foo.shape
Export-Package: org.foo.shape,org.foo.other
Export-Package: org.foo.shape; org.foo.other; version="2.0.0"
Import-Package
Import-Package :
A comma-separated list of packages needed by internal bundle code from other bundles.
Import-Package: org.foo.shape
there’s NO relationship among nested packages.
Import-Package: org.foo.shape,org.foo.shape.other
Import-Package: org.osgi.framework; version="1.3.0"
Version range ??
Version Range
Import-Package: org.osgi.framework; version="[1.3.0,2.0.0)"
“Depending on packages, not bundles.”
Class-search order
● If the class is from a package starting with java. ,the parent class loader is asked for the class. If
the class is found, it’s used. If there is no such class, the search ends with an exception.
● If the class is from a package imported by the bundle, the framework asks the exporting bundle
for the class. If the class is found, it’s used. If there is no such class, the search ends with an
exception.
● The bundle class path is searched for the class. If it’s found, it’s used. If there is
no such class, the search ends with an exception.
That’s it! We’ve finished the introduction to bundle metadata
Example ..
Paint Example ….
Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.foo.shape.circle
Bundle-Version: 2.0.0
Bundle-Name: Circle Implementation
Import-Package: javax.swing, org.foo.shape;
version="2.0.0"
Export-Package: org.foo.shape.circle; version="
2.0.0"
Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.foo.paint
Bundle-Version: 2.0.0
Bundle-Name: Simple Paint Program
Import-Package: javax.swing, org.foo.shape; org.foo.shape.
circle;
org.foo.shape.square; org.foo.shape.triangle; version="2.0.0"
Bundle dependency resolution - Resolving dependencies
automatically
Transitive Dependencies
Transitive Bundle-resolution Wiring
Multiple Matching Package Providers
● Framework favors the highest matching version
● Sound simple enough ? What if both bundles export same version ?
● framework chooses between candidates based on the order in
which they are installed in the framework.
Priority of Dependency
● Highest priority is given to already-resolved candidates, where multiple matches of resolved
candidates are sorted according to version and then installation order.
● Next priority is given to unresolved candidates, where multiple matches of unresolved
candidates are sorted according to version and the installation order.
Ensuring Consistency
What went wrong ?
Inner vs Inner bundle dependencies
Reviewing the benefits of the modular program
Summary
References
● http://moi.vonos.net/java/osgi-classloaders/
● http://blog.osgi.org/2011/05/what-you-should-know-about-class.html
● OSGi in Action: Creating Modular Applications in Java by: Richard Hall,
Karl Pauls, Stuart McCulloch, David Savage (01 May 2011)
Thank You :)

More Related Content

What's hot

Java
JavaJava
1
11
Features of java
Features of javaFeatures of java
Features of java
laratechnologies
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
Levent YILDIZ
 
Introducing Java 7
Introducing Java 7Introducing Java 7
Introducing Java 7
Markus Eisele
 
Unit of competency
Unit of competencyUnit of competency
Unit of competency
loidasacueza
 
Java 9
Java 9Java 9
Introduction to java technology
Introduction to java technologyIntroduction to java technology
Introduction to java technology
Indika Munaweera Kankanamge
 
Introduction to Java Programming
Introduction to Java Programming Introduction to Java Programming
Introduction to Java Programming
Saravanakumar R
 
Groovy features
Groovy featuresGroovy features
Groovy features
Ramakrishna kapa
 
Java and its features
Java and its featuresJava and its features
Java and its features
Pydi Nikhil
 
Basic of Java
Basic of JavaBasic of Java
Basic of Java
Ajeet Kumar Verma
 
Classes and Objects
Classes and ObjectsClasses and Objects
Classes and Objects
vmadan89
 
Java programming(unit 1)
Java programming(unit 1)Java programming(unit 1)
Java programming(unit 1)
SURBHI SAROHA
 
History of java'
History of java'History of java'
History of java'
deepthisujithra
 
9 crucial Java Design Principles you cannot miss
9 crucial Java Design Principles you cannot miss9 crucial Java Design Principles you cannot miss
9 crucial Java Design Principles you cannot miss
Mark Papis
 
Features of JAVA Programming Language.
Features of JAVA Programming Language.Features of JAVA Programming Language.
Features of JAVA Programming Language.
Bhautik Jethva
 
OSGi and Java 9+
OSGi and Java 9+OSGi and Java 9+
OSGi and Java 9+
bjhargrave
 
Java programming language
Java programming languageJava programming language
Java programming language
SubhashKumar329
 
01slide
01slide01slide

What's hot (20)

Java
JavaJava
Java
 
1
11
1
 
Features of java
Features of javaFeatures of java
Features of java
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
 
Introducing Java 7
Introducing Java 7Introducing Java 7
Introducing Java 7
 
Unit of competency
Unit of competencyUnit of competency
Unit of competency
 
Java 9
Java 9Java 9
Java 9
 
Introduction to java technology
Introduction to java technologyIntroduction to java technology
Introduction to java technology
 
Introduction to Java Programming
Introduction to Java Programming Introduction to Java Programming
Introduction to Java Programming
 
Groovy features
Groovy featuresGroovy features
Groovy features
 
Java and its features
Java and its featuresJava and its features
Java and its features
 
Basic of Java
Basic of JavaBasic of Java
Basic of Java
 
Classes and Objects
Classes and ObjectsClasses and Objects
Classes and Objects
 
Java programming(unit 1)
Java programming(unit 1)Java programming(unit 1)
Java programming(unit 1)
 
History of java'
History of java'History of java'
History of java'
 
9 crucial Java Design Principles you cannot miss
9 crucial Java Design Principles you cannot miss9 crucial Java Design Principles you cannot miss
9 crucial Java Design Principles you cannot miss
 
Features of JAVA Programming Language.
Features of JAVA Programming Language.Features of JAVA Programming Language.
Features of JAVA Programming Language.
 
OSGi and Java 9+
OSGi and Java 9+OSGi and Java 9+
OSGi and Java 9+
 
Java programming language
Java programming languageJava programming language
Java programming language
 
01slide
01slide01slide
01slide
 

Viewers also liked

Perl WAF Overview, with mod_perl - Hokkaido.pm#7 #hokkaidopm
Perl WAF Overview, with mod_perl - Hokkaido.pm#7 #hokkaidopmPerl WAF Overview, with mod_perl - Hokkaido.pm#7 #hokkaidopm
Perl WAF Overview, with mod_perl - Hokkaido.pm#7 #hokkaidopm
鉄次 尾形
 
クリップボード監視と外部コマンド実行 #chibapm
クリップボード監視と外部コマンド実行 #chibapmクリップボード監視と外部コマンド実行 #chibapm
クリップボード監視と外部コマンド実行 #chibapm
鉄次 尾形
 
Capacitors
CapacitorsCapacitors
Capacitors
Sathish Bala
 
Consumer Mobile Insights Research 2013
Consumer Mobile Insights Research 2013Consumer Mobile Insights Research 2013
Consumer Mobile Insights Research 2013
Kris Bruynson
 
Social 2014 predictions
Social 2014 predictionsSocial 2014 predictions
Social 2014 predictions
Kris Bruynson
 
Koti
KotiKoti
Mobile
MobileMobile
Koti us20110318373 a1[1]
Koti us20110318373 a1[1]Koti us20110318373 a1[1]
Koti us20110318373 a1[1]
Sogang University
 
札幌でテンプレート #hokkaidopm
札幌でテンプレート #hokkaidopm札幌でテンプレート #hokkaidopm
札幌でテンプレート #hokkaidopm
鉄次 尾形
 
Games::* - Perlで 「ゲーム」しよう #hokkaidopm
Games::* - Perlで 「ゲーム」しよう #hokkaidopmGames::* - Perlで 「ゲーム」しよう #hokkaidopm
Games::* - Perlで 「ゲーム」しよう #hokkaidopm
鉄次 尾形
 
Woodland brand short
Woodland brand shortWoodland brand short
Woodland brand short
Kris Bruynson
 
設定ファイルに使われそうなデータ形式
設定ファイルに使われそうなデータ形式設定ファイルに使われそうなデータ形式
設定ファイルに使われそうなデータ形式
鉄次 尾形
 
PerlのTwitterモジュールの紹介 #twtr_hack
PerlのTwitterモジュールの紹介 #twtr_hackPerlのTwitterモジュールの紹介 #twtr_hack
PerlのTwitterモジュールの紹介 #twtr_hack
鉄次 尾形
 
Site Mockups
Site MockupsSite Mockups
Site Mockups
Kris Bruynson
 

Viewers also liked (14)

Perl WAF Overview, with mod_perl - Hokkaido.pm#7 #hokkaidopm
Perl WAF Overview, with mod_perl - Hokkaido.pm#7 #hokkaidopmPerl WAF Overview, with mod_perl - Hokkaido.pm#7 #hokkaidopm
Perl WAF Overview, with mod_perl - Hokkaido.pm#7 #hokkaidopm
 
クリップボード監視と外部コマンド実行 #chibapm
クリップボード監視と外部コマンド実行 #chibapmクリップボード監視と外部コマンド実行 #chibapm
クリップボード監視と外部コマンド実行 #chibapm
 
Capacitors
CapacitorsCapacitors
Capacitors
 
Consumer Mobile Insights Research 2013
Consumer Mobile Insights Research 2013Consumer Mobile Insights Research 2013
Consumer Mobile Insights Research 2013
 
Social 2014 predictions
Social 2014 predictionsSocial 2014 predictions
Social 2014 predictions
 
Koti
KotiKoti
Koti
 
Mobile
MobileMobile
Mobile
 
Koti us20110318373 a1[1]
Koti us20110318373 a1[1]Koti us20110318373 a1[1]
Koti us20110318373 a1[1]
 
札幌でテンプレート #hokkaidopm
札幌でテンプレート #hokkaidopm札幌でテンプレート #hokkaidopm
札幌でテンプレート #hokkaidopm
 
Games::* - Perlで 「ゲーム」しよう #hokkaidopm
Games::* - Perlで 「ゲーム」しよう #hokkaidopmGames::* - Perlで 「ゲーム」しよう #hokkaidopm
Games::* - Perlで 「ゲーム」しよう #hokkaidopm
 
Woodland brand short
Woodland brand shortWoodland brand short
Woodland brand short
 
設定ファイルに使われそうなデータ形式
設定ファイルに使われそうなデータ形式設定ファイルに使われそうなデータ形式
設定ファイルに使われそうなデータ形式
 
PerlのTwitterモジュールの紹介 #twtr_hack
PerlのTwitterモジュールの紹介 #twtr_hackPerlのTwitterモジュールの紹介 #twtr_hack
PerlのTwitterモジュールの紹介 #twtr_hack
 
Site Mockups
Site MockupsSite Mockups
Site Mockups
 

Similar to OSGI Modularity

Modular Java
Modular JavaModular Java
Modular Java
Martin Toshev
 
Java Core | Java 8 and OSGi Modularisation | Tim Ellison & Neil Bartlett
Java Core | Java 8 and OSGi Modularisation | Tim Ellison & Neil BartlettJava Core | Java 8 and OSGi Modularisation | Tim Ellison & Neil Bartlett
Java Core | Java 8 and OSGi Modularisation | Tim Ellison & Neil Bartlett
JAX London
 
Modularity of the Java Platform (OSGi, Jigsaw and Penrose)
Modularity of the Java Platform (OSGi, Jigsaw and Penrose)Modularity of the Java Platform (OSGi, Jigsaw and Penrose)
Modularity of the Java Platform (OSGi, Jigsaw and Penrose)
Martin Toshev
 
Intro To OSGi
Intro To OSGiIntro To OSGi
Intro To OSGi
Stephan Janssen
 
Tuscany : Applying OSGi After The Fact
Tuscany : Applying  OSGi After The FactTuscany : Applying  OSGi After The Fact
Tuscany : Applying OSGi After The Fact
Luciano Resende
 
Modularity of The Java Platform Javaday (http://javaday.org.ua/)
Modularity of The Java Platform Javaday (http://javaday.org.ua/)Modularity of The Java Platform Javaday (http://javaday.org.ua/)
Modularity of The Java Platform Javaday (http://javaday.org.ua/)
Martin Toshev
 
OpenJDK Penrose Presentation (JavaOne 2012)
OpenJDK Penrose Presentation (JavaOne 2012)OpenJDK Penrose Presentation (JavaOne 2012)
OpenJDK Penrose Presentation (JavaOne 2012)
David Bosschaert
 
Introduction to OSGi - Part-1
Introduction to OSGi - Part-1Introduction to OSGi - Part-1
Introduction to OSGi - Part-1
kshanth2101
 
Java Tech & Tools | OSGi Best Practices | Emily Jiang
Java Tech & Tools | OSGi Best Practices | Emily JiangJava Tech & Tools | OSGi Best Practices | Emily Jiang
Java Tech & Tools | OSGi Best Practices | Emily Jiang
JAX London
 
Java 9 / Jigsaw - AJUG/VJUG session
Java 9 / Jigsaw - AJUG/VJUG  sessionJava 9 / Jigsaw - AJUG/VJUG  session
Java 9 / Jigsaw - AJUG/VJUG session
Mani Sarkar
 
java basic .pdf
java basic .pdfjava basic .pdf
java basic .pdf
Satish More
 
OSGi & Blueprint
OSGi & BlueprintOSGi & Blueprint
OSGi & Blueprint
Kara Satish Kumar
 
OSGi Service Platform Release 4 Overview - BJ Hargrave, IBM & Peter Kriens, a...
OSGi Service Platform Release 4 Overview - BJ Hargrave, IBM & Peter Kriens, a...OSGi Service Platform Release 4 Overview - BJ Hargrave, IBM & Peter Kriens, a...
OSGi Service Platform Release 4 Overview - BJ Hargrave, IBM & Peter Kriens, a...
mfrancis
 
OSGi Enablement For Apache Tuscany
OSGi Enablement For Apache TuscanyOSGi Enablement For Apache Tuscany
OSGi Enablement For Apache Tuscany
Raymond Feng
 
OSGi Training for Carbon Developers
OSGi Training for Carbon DevelopersOSGi Training for Carbon Developers
OSGi Training for Carbon Developers
Aruna Karunarathna
 
Java 9 New Features
Java 9 New FeaturesJava 9 New Features
Java 9 New Features
Ali BAKAN
 
Best Practices for Enterprise OSGi Applications - Emily Jiang
Best Practices for Enterprise OSGi Applications - Emily JiangBest Practices for Enterprise OSGi Applications - Emily Jiang
Best Practices for Enterprise OSGi Applications - Emily Jiang
mfrancis
 
Java 9: Deep Dive into Modularity and Dealing with Migration Issues
Java 9: Deep Dive into Modularity and Dealing with Migration IssuesJava 9: Deep Dive into Modularity and Dealing with Migration Issues
Java 9: Deep Dive into Modularity and Dealing with Migration Issues
GlobalLogic Ukraine
 
As7 jbug j_boss_modules_yang yong
As7 jbug j_boss_modules_yang yongAs7 jbug j_boss_modules_yang yong
As7 jbug j_boss_modules_yang yong
jbossug
 
Making Applications Work Together In Eclipse
Making Applications Work Together In EclipseMaking Applications Work Together In Eclipse
Making Applications Work Together In Eclipse
Kaniska Mandal
 

Similar to OSGI Modularity (20)

Modular Java
Modular JavaModular Java
Modular Java
 
Java Core | Java 8 and OSGi Modularisation | Tim Ellison & Neil Bartlett
Java Core | Java 8 and OSGi Modularisation | Tim Ellison & Neil BartlettJava Core | Java 8 and OSGi Modularisation | Tim Ellison & Neil Bartlett
Java Core | Java 8 and OSGi Modularisation | Tim Ellison & Neil Bartlett
 
Modularity of the Java Platform (OSGi, Jigsaw and Penrose)
Modularity of the Java Platform (OSGi, Jigsaw and Penrose)Modularity of the Java Platform (OSGi, Jigsaw and Penrose)
Modularity of the Java Platform (OSGi, Jigsaw and Penrose)
 
Intro To OSGi
Intro To OSGiIntro To OSGi
Intro To OSGi
 
Tuscany : Applying OSGi After The Fact
Tuscany : Applying  OSGi After The FactTuscany : Applying  OSGi After The Fact
Tuscany : Applying OSGi After The Fact
 
Modularity of The Java Platform Javaday (http://javaday.org.ua/)
Modularity of The Java Platform Javaday (http://javaday.org.ua/)Modularity of The Java Platform Javaday (http://javaday.org.ua/)
Modularity of The Java Platform Javaday (http://javaday.org.ua/)
 
OpenJDK Penrose Presentation (JavaOne 2012)
OpenJDK Penrose Presentation (JavaOne 2012)OpenJDK Penrose Presentation (JavaOne 2012)
OpenJDK Penrose Presentation (JavaOne 2012)
 
Introduction to OSGi - Part-1
Introduction to OSGi - Part-1Introduction to OSGi - Part-1
Introduction to OSGi - Part-1
 
Java Tech & Tools | OSGi Best Practices | Emily Jiang
Java Tech & Tools | OSGi Best Practices | Emily JiangJava Tech & Tools | OSGi Best Practices | Emily Jiang
Java Tech & Tools | OSGi Best Practices | Emily Jiang
 
Java 9 / Jigsaw - AJUG/VJUG session
Java 9 / Jigsaw - AJUG/VJUG  sessionJava 9 / Jigsaw - AJUG/VJUG  session
Java 9 / Jigsaw - AJUG/VJUG session
 
java basic .pdf
java basic .pdfjava basic .pdf
java basic .pdf
 
OSGi & Blueprint
OSGi & BlueprintOSGi & Blueprint
OSGi & Blueprint
 
OSGi Service Platform Release 4 Overview - BJ Hargrave, IBM & Peter Kriens, a...
OSGi Service Platform Release 4 Overview - BJ Hargrave, IBM & Peter Kriens, a...OSGi Service Platform Release 4 Overview - BJ Hargrave, IBM & Peter Kriens, a...
OSGi Service Platform Release 4 Overview - BJ Hargrave, IBM & Peter Kriens, a...
 
OSGi Enablement For Apache Tuscany
OSGi Enablement For Apache TuscanyOSGi Enablement For Apache Tuscany
OSGi Enablement For Apache Tuscany
 
OSGi Training for Carbon Developers
OSGi Training for Carbon DevelopersOSGi Training for Carbon Developers
OSGi Training for Carbon Developers
 
Java 9 New Features
Java 9 New FeaturesJava 9 New Features
Java 9 New Features
 
Best Practices for Enterprise OSGi Applications - Emily Jiang
Best Practices for Enterprise OSGi Applications - Emily JiangBest Practices for Enterprise OSGi Applications - Emily Jiang
Best Practices for Enterprise OSGi Applications - Emily Jiang
 
Java 9: Deep Dive into Modularity and Dealing with Migration Issues
Java 9: Deep Dive into Modularity and Dealing with Migration IssuesJava 9: Deep Dive into Modularity and Dealing with Migration Issues
Java 9: Deep Dive into Modularity and Dealing with Migration Issues
 
As7 jbug j_boss_modules_yang yong
As7 jbug j_boss_modules_yang yongAs7 jbug j_boss_modules_yang yong
As7 jbug j_boss_modules_yang yong
 
Making Applications Work Together In Eclipse
Making Applications Work Together In EclipseMaking Applications Work Together In Eclipse
Making Applications Work Together In Eclipse
 

Recently uploaded

How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?
ToXSL Technologies
 
How to write a program in any programming language
How to write a program in any programming languageHow to write a program in any programming language
How to write a program in any programming language
Rakesh Kumar R
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
Drona Infotech
 
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
mz5nrf0n
 
GreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-JurisicGreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-Jurisic
Green Software Development
 
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
XfilesPro
 
Webinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for EmbeddedWebinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for Embedded
ICS
 
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, FactsALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
Green Software Development
 
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian CompaniesE-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
Quickdice ERP
 
E-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet DynamicsE-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet Dynamics
Hornet Dynamics
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j
 
Energy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina JonuziEnergy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina Jonuzi
Green Software Development
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
Aftab Hussain
 
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdfTop Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
VALiNTRY360
 
Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
Octavian Nadolu
 
SQL Accounting Software Brochure Malaysia
SQL Accounting Software Brochure MalaysiaSQL Accounting Software Brochure Malaysia
SQL Accounting Software Brochure Malaysia
GohKiangHock
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke
 
Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
Sven Peters
 
UI5con 2024 - Bring Your Own Design System
UI5con 2024 - Bring Your Own Design SystemUI5con 2024 - Bring Your Own Design System
UI5con 2024 - Bring Your Own Design System
Peter Muessig
 

Recently uploaded (20)

How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?
 
How to write a program in any programming language
How to write a program in any programming languageHow to write a program in any programming language
How to write a program in any programming language
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
 
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
 
GreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-JurisicGreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-Jurisic
 
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
 
Webinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for EmbeddedWebinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for Embedded
 
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, FactsALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
 
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian CompaniesE-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
 
E-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet DynamicsE-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet Dynamics
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
 
Energy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina JonuziEnergy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina Jonuzi
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
 
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdfTop Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
 
Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
 
SQL Accounting Software Brochure Malaysia
SQL Accounting Software Brochure MalaysiaSQL Accounting Software Brochure Malaysia
SQL Accounting Software Brochure Malaysia
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
 
Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
 
UI5con 2024 - Bring Your Own Design System
UI5con 2024 - Bring Your Own Design SystemUI5con 2024 - Bring Your Own Design System
UI5con 2024 - Bring Your Own Design System
 

OSGI Modularity

  • 2.
  • 3. The What and Why of OSGI What do you mean by “Modularity” ? the logical decomposition of a large system into smaller collaborating pieces Widely accepted specification which introduces a standard way of building dynamic, modular systems with Java. What is OSGi?
  • 4. Why OSGI ? Java’s modularity limitations ● Low-level code visibility control
  • 5. Java’s modularity limitations Cont.. ● Error-Prone Classpath concept The classpath pays no attention to code versions - it returns first version it finds. Class Path Hell !
  • 6.
  • 8. ● Runtime vs Compile time difference. ○ Flat, single classpath. Java’s modularity limitations Cont.. ● No standard way of building a modular system. ○ Class loader based techniques. ● If you need to add new functionality or update existing functionality, JVM needed to be restarted. ● Can you update a part(can be a JAR file) of a running Java application? ● Java lacks dynamism
  • 9. Can OSGI help you ? ● Allow us to understand the system easily ● Allow us to develop module by module ● Allow us to reuse developed modules ● ClassNotFoundException when starting your application ● Execution time error due to wrong version of dependent library ● Packaging an application as logically independent JAR files and deploying only those pieces you need for a given installation. ● Packaging an application as logically independent JAR files, declaring which code is accessible from each JAR file, and having this visibility enforced. “Yes !! ” Still not convinced ??
  • 10. Next level of Modularity
  • 12. OSGI Framework As of now, there are 3 implementations ● Apache Felix ● Eclipse Equinox ● Knopflerfish Module Layer Lifecycle Layer Service Layer
  • 13. OSGI Modularity ● Is how OSGI refers to its specific realization of the module concept ● Is a jar file with extra Meta-data. bundles typically aren’t entire application packaged into single jar file. ● Is more powerful than a jar file because it can explicitly declare visibility of its packages. Thus it extends normal access modifies association with java Bundle
  • 14. The Bundle role in physical modularity ● Is to determine module membership ● Given class is a member of a bundle if it’s contained in the bundle jar ● Bundle jar is a container of bundle metadata -- Manifest
  • 15. Bundle role in logical Modularity ● Is to logically encapsulate member classes. what does this mean ? ○ Visibility of the code
  • 16. Defining Bundle with metadata ● Human-readable information—Optional information intended purely as an aid to humans who are using the bundle ● Bundle identification —Required information to identify a bundle ● Code visibility —Required information for defining which code is internally visible and which internal code is externally visible ● Human-readable information Bundle-Name: Simple Paint API Bundle-Description: Public API for a simple paint program. Bundle-DocURL: http://www.manning.com/osgi-in-action/ Bundle-Category: example, library Bundle-Vendor: OSGi in Action Bundle-ContactAddress: 1234 Main Street, USA Bundle-Copyright: OSGi in Action
  • 17. Bundle identification ● For example, Bundle-Name seems like it could be a form of bundle identification It isn’t. unique bundle identifier was proposed to maintain backward compatibility it’s called Bundle-SymbolicName: org.foo.shape ● only intended for the OSGi framework to help uniquely identify a bundle. A bundle is uniquely identified by its Bundle-SymbolicName and Bundle-Version. Bundle-SymbolicName: org.foo.shape Bundle-Version: 2.0.0
  • 18. OSGI Version Number format ● major – Changes for an incompatible update for both a consumer and a provider of an API. ● minor – Changes for a backward compatible update for a consumer but not for a provider. ● micro – A change that does not affect the API, for example, a typo in a comment ● Qualifier - e.g. 1.2.0.alpha
  • 19. Code visibility ● Internal bundle class path—The code forming the bundle ● Exported internal code—Explicitly exposed code from the bundle class path for sharing with other bundles ● Imported external code—External code on which the bundle class path code depends Recap If the JAR file has a Main-Class java -jar app.jar If not, java -cp app.jar org.foo.Main
  • 20.
  • 21. Bundle-ClassPath The Bundle-ClassPath specifies where to load classes from from the bundle. Bundle-ClassPath: . Loading from nested JARs (whether packed or unpacked): Bundle-ClassPath: foo.jar,other.jar,classes
  • 22. Export - Package Export-Package : A comma-separated list of internal bundle packages to expose for sharing with other bundles Export-Package: org.foo.shape Export-Package: org.foo.shape,org.foo.other Export-Package: org.foo.shape; org.foo.other; version="2.0.0"
  • 23. Import-Package Import-Package : A comma-separated list of packages needed by internal bundle code from other bundles. Import-Package: org.foo.shape there’s NO relationship among nested packages. Import-Package: org.foo.shape,org.foo.shape.other Import-Package: org.osgi.framework; version="1.3.0" Version range ??
  • 24. Version Range Import-Package: org.osgi.framework; version="[1.3.0,2.0.0)" “Depending on packages, not bundles.”
  • 25. Class-search order ● If the class is from a package starting with java. ,the parent class loader is asked for the class. If the class is found, it’s used. If there is no such class, the search ends with an exception. ● If the class is from a package imported by the bundle, the framework asks the exporting bundle for the class. If the class is found, it’s used. If there is no such class, the search ends with an exception. ● The bundle class path is searched for the class. If it’s found, it’s used. If there is no such class, the search ends with an exception. That’s it! We’ve finished the introduction to bundle metadata
  • 27. Paint Example …. Bundle-ManifestVersion: 2 Bundle-SymbolicName: org.foo.shape.circle Bundle-Version: 2.0.0 Bundle-Name: Circle Implementation Import-Package: javax.swing, org.foo.shape; version="2.0.0" Export-Package: org.foo.shape.circle; version=" 2.0.0" Bundle-ManifestVersion: 2 Bundle-SymbolicName: org.foo.paint Bundle-Version: 2.0.0 Bundle-Name: Simple Paint Program Import-Package: javax.swing, org.foo.shape; org.foo.shape. circle; org.foo.shape.square; org.foo.shape.triangle; version="2.0.0"
  • 28. Bundle dependency resolution - Resolving dependencies automatically Transitive Dependencies
  • 30. Multiple Matching Package Providers ● Framework favors the highest matching version ● Sound simple enough ? What if both bundles export same version ? ● framework chooses between candidates based on the order in which they are installed in the framework.
  • 31. Priority of Dependency ● Highest priority is given to already-resolved candidates, where multiple matches of resolved candidates are sorted according to version and then installation order. ● Next priority is given to unresolved candidates, where multiple matches of unresolved candidates are sorted according to version and the installation order.
  • 33. Inner vs Inner bundle dependencies
  • 34.
  • 35. Reviewing the benefits of the modular program
  • 37. References ● http://moi.vonos.net/java/osgi-classloaders/ ● http://blog.osgi.org/2011/05/what-you-should-know-about-class.html ● OSGi in Action: Creating Modular Applications in Java by: Richard Hall, Karl Pauls, Stuart McCulloch, David Savage (01 May 2011)