SlideShare a Scribd company logo
1 of 38
Download to read offline
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 (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鉄次 尾形
 
Consumer Mobile Insights Research 2013
Consumer Mobile Insights Research 2013Consumer Mobile Insights Research 2013
Consumer Mobile Insights Research 2013Kris Bruynson
 
Social 2014 predictions
Social 2014 predictionsSocial 2014 predictions
Social 2014 predictionsKris Bruynson
 
札幌でテンプレート #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 shortKris Bruynson
 
設定ファイルに使われそうなデータ形式
設定ファイルに使われそうなデータ形式設定ファイルに使われそうなデータ形式
設定ファイルに使われそうなデータ形式鉄次 尾形
 
PerlのTwitterモジュールの紹介 #twtr_hack
PerlのTwitterモジュールの紹介 #twtr_hackPerlのTwitterモジュールの紹介 #twtr_hack
PerlのTwitterモジュールの紹介 #twtr_hack鉄次 尾形
 

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: A Guide to Modular Programming with OSGI Bundles

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 BartlettJAX 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
 
Tuscany : Applying OSGi After The Fact
Tuscany : Applying  OSGi After The FactTuscany : Applying  OSGi After The Fact
Tuscany : Applying OSGi After The FactLuciano 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-1kshanth2101
 
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 JiangJAX London
 
Java 9 / Jigsaw - AJUG/VJUG session
Java 9 / Jigsaw - AJUG/VJUG  sessionJava 9 / Jigsaw - AJUG/VJUG  session
Java 9 / Jigsaw - AJUG/VJUG sessionMani Sarkar
 
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 TuscanyRaymond Feng
 
OSGi Training for Carbon Developers
OSGi Training for Carbon DevelopersOSGi Training for Carbon Developers
OSGi Training for Carbon DevelopersAruna Karunarathna
 
Java 9 New Features
Java 9 New FeaturesJava 9 New Features
Java 9 New FeaturesAli 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 Jiangmfrancis
 
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 IssuesGlobalLogic 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 yongjbossug
 
Making Applications Work Together In Eclipse
Making Applications Work Together In EclipseMaking Applications Work Together In Eclipse
Making Applications Work Together In EclipseKaniska Mandal
 

Similar to OSGI Modularity: A Guide to Modular Programming with OSGI Bundles (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

Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceanilsa9823
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 

Recently uploaded (20)

Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 

OSGI Modularity: A Guide to Modular Programming with OSGI Bundles

  • 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)