SlideShare ist ein Scribd-Unternehmen logo
1 von 16
Downloaden Sie, um offline zu lesen
Java9 Modules
Tom Schindl <tom.schindl@bestsolution.at>
Twitter: @tomsontom
Blog: http://tomsondev.bestsolution.at
Website: http://www.bestsolution.at
(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0
About Tom
‣ CTO BestSolution.at Systemhaus GmbH
‣ Eclipse Committer
‣ e4
‣ Platform
‣ EMF
‣ Project lead
‣ e(fx)clipse
‣ Twitter: @tomsontom
‣ Blog: tomsondev.bestsolution.at
‣ Corporate: http://bestsolution.at
(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0
Targets of Java9 Modulesystem
‣ Split up rt.jar in smaller junks
‣ Avoids further introduction of cross-references
‣ Allows smaller Java-Runtimes (eg for IoT-Devices, …)
‣ Restrict Access to internal APIs (eg com.sun.misc.Unsafe)
‣ Allow developers to adopt it for their code as well
(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0
Java9 Modules vs OSGi
‣ The Implementation
‣ OSGi Module System is built upon classloaders
‣ Java9 Module System is implemented at the VM Level
(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0
Java9 Modules vs OSGi
‣ The Implementation
‣ OSGi Module System is built upon classloaders
‣ Java9 Module System is implemented at the VM Level
OSGi
foo-1.0.0
(BundleLoaderClassLoader@f1)
bar-1.0.0
(BundleLoaderClassLoader@b1)
(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0
Java9 Modules vs OSGi
‣ The Implementation
‣ OSGi Module System is built upon classloaders
‣ Java9 Module System is implemented at the VM Level
OSGi
foo-1.0.0
(BundleLoaderClassLoader@f1)
bar-1.0.0
(BundleLoaderClassLoader@b1)
Java9
foo-1.0.0
(AppClassloader@A1)
bar-1.0.0
(AppClassloader@A1)
(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0
Java9 Modules vs OSGi
‣ Dependency definition
‣ OSGi uses custom MANIFEST.MF entries Require-Bundle and
Import-Package
‣ Java9 uses module-info.java and directive requires
(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0
Java9 Modules vs OSGi
‣ Dependency definition
‣ OSGi uses custom MANIFEST.MF entries Require-Bundle and
Import-Package
‣ Java9 uses module-info.java and directive requires
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-SymbolicName: bar
Require-Bundle: foo
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-SymbolicName: bar
Import-Package: foo
OSGi
(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0
Java9 Modules vs OSGi
‣ Dependency definition
‣ OSGi uses custom MANIFEST.MF entries Require-Bundle and
Import-Package
‣ Java9 uses module-info.java and directive requires
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-SymbolicName: bar
Require-Bundle: foo
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-SymbolicName: bar
Import-Package: foo
OSGi
module bar {
requires foo;
}
Java9
(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0
Java9 Modules vs OSGi
‣ Access Restrictions
‣ OSGi uses custom MANIFEST.MF entry Export-Package
‣ Java9 use module-info.java and directive exports
(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0
Java9 Modules vs OSGi
‣ Access Restrictions
‣ OSGi uses custom MANIFEST.MF entry Export-Package
‣ Java9 use module-info.java and directive exports
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-SymbolicName: foo
Export-Package: foo
OSGi
(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0
Java9 Modules vs OSGi
‣ Access Restrictions
‣ OSGi uses custom MANIFEST.MF entry Export-Package
‣ Java9 use module-info.java and directive exports
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-SymbolicName: foo
Export-Package: foo
OSGi
module foo {
exports foo;
}
Java9
(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0
Java9 Modules vs OSGi
‣ Services
‣ OSGi has eg Declarative Service Components and the
BundleContext to lookup
(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0
Java9 Modules vs OSGi
‣ Services
‣ OSGi has eg Declarative Service Components and the
BundleContext to lookup
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-SymbolicName: bar
Require-Bundle: foo
Service-Component: OSGI-INF/mycomponent.xml
<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0">
<implementation class="bar.BarService"/>
<service>
<provide interface="foo.Service"/>
</service>
</scr:component>
Provider
(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0
Java9 Modules vs OSGi
‣ Services
‣ OSGi has eg Declarative Service Components and the
BundleContext to lookup
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-SymbolicName: bar
Require-Bundle: foo
Service-Component: OSGI-INF/mycomponent.xml
<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0">
<implementation class="bar.BarService"/>
<service>
<provide interface="foo.Service"/>
</service>
</scr:component>
Provider
BundleContext ctx = getContext(cl);
ServiceReference<Service> ref = 

ctx.getServiceReference(Service.class);
Service s = ctx.getService(ref);
Consumer
(c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0
Java9 Modules vs OSGi
‣ Service
‣ Java9 uses module-info.java and ServiceLoader for the
lookup
module bar {
requires foo;
provides foo.Service with bar.BarService;
}
Provider
module foo {
requires foo;
uses foo.Service;
}
Consumer
ServiceLoader<GreetService> l =
ServiceLoader.load(Service.class);
Service s = l.iterator().next();

Weitere ähnliche Inhalte

Ähnlich wie Democamp - Munich - Java9

Railo Presentation Railo 3.1
Railo Presentation Railo 3.1Railo Presentation Railo 3.1
Railo Presentation Railo 3.1
Rhinofly
 
Dependency management with Composer
Dependency management with ComposerDependency management with Composer
Dependency management with Composer
Jason Grimes
 
Osgi Webinar
Osgi WebinarOsgi Webinar
Osgi Webinar
WSO2
 
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
 
Asp net mvc
Asp net mvcAsp net mvc
Asp net mvc
bgrynko
 

Ähnlich wie Democamp - Munich - Java9 (20)

E(fx)clipse eclipse con
E(fx)clipse   eclipse conE(fx)clipse   eclipse con
E(fx)clipse eclipse con
 
ColdFusion .NET integration - Adobe Max 2006
ColdFusion .NET integration - Adobe Max 2006ColdFusion .NET integration - Adobe Max 2006
ColdFusion .NET integration - Adobe Max 2006
 
Railo Presentation Railo 3.1
Railo Presentation Railo 3.1Railo Presentation Railo 3.1
Railo Presentation Railo 3.1
 
Dependency management with Composer
Dependency management with ComposerDependency management with Composer
Dependency management with Composer
 
Cocoon Blocks ApacheCon US 2005
Cocoon Blocks ApacheCon US 2005Cocoon Blocks ApacheCon US 2005
Cocoon Blocks ApacheCon US 2005
 
Java fx smart code econ
Java fx smart code econJava fx smart code econ
Java fx smart code econ
 
Introduction to OSGGi
Introduction to OSGGiIntroduction to OSGGi
Introduction to OSGGi
 
OSGi Enablement For Apache Tuscany
OSGi Enablement For Apache TuscanyOSGi Enablement For Apache Tuscany
OSGi Enablement For Apache Tuscany
 
Window Shopping Browser - Bug Hunting in 2012
Window Shopping Browser - Bug Hunting in 2012Window Shopping Browser - Bug Hunting in 2012
Window Shopping Browser - Bug Hunting in 2012
 
Cross Context Scripting attacks & exploitation
Cross Context Scripting attacks & exploitationCross Context Scripting attacks & exploitation
Cross Context Scripting attacks & exploitation
 
Евгений Бова: "Modularity in Java: introduction to Jigsaw through the prism o...
Евгений Бова: "Modularity in Java: introduction to Jigsaw through the prism o...Евгений Бова: "Modularity in Java: introduction to Jigsaw through the prism o...
Евгений Бова: "Modularity in Java: introduction to Jigsaw through the prism o...
 
Osgi Webinar
Osgi WebinarOsgi Webinar
Osgi Webinar
 
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
 
KSS Session and Tech Talk-2019 on IOT.pptx
KSS Session and Tech Talk-2019 on IOT.pptxKSS Session and Tech Talk-2019 on IOT.pptx
KSS Session and Tech Talk-2019 on IOT.pptx
 
Asp net mvc
Asp net mvcAsp net mvc
Asp net mvc
 
Know thy code
Know thy codeKnow thy code
Know thy code
 
CodeShip
CodeShipCodeShip
CodeShip
 
Scaleable PHP Applications in Kubernetes
Scaleable PHP Applications in KubernetesScaleable PHP Applications in Kubernetes
Scaleable PHP Applications in Kubernetes
 
Acceptance testing in php with Codeception - Techmeetup Edinburgh
Acceptance testing in php with Codeception - Techmeetup EdinburghAcceptance testing in php with Codeception - Techmeetup Edinburgh
Acceptance testing in php with Codeception - Techmeetup Edinburgh
 
PHP Dependency Management with Composer
PHP Dependency Management with ComposerPHP Dependency Management with Composer
PHP Dependency Management with Composer
 

Kürzlich hochgeladen

AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
VictorSzoltysek
 
+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
 

Kürzlich hochgeladen (20)

%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
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...
 
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
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
+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...
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
SHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions PresentationSHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions Presentation
 
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 

Democamp - Munich - Java9

  • 1. Java9 Modules Tom Schindl <tom.schindl@bestsolution.at> Twitter: @tomsontom Blog: http://tomsondev.bestsolution.at Website: http://www.bestsolution.at
  • 2. (c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0 About Tom ‣ CTO BestSolution.at Systemhaus GmbH ‣ Eclipse Committer ‣ e4 ‣ Platform ‣ EMF ‣ Project lead ‣ e(fx)clipse ‣ Twitter: @tomsontom ‣ Blog: tomsondev.bestsolution.at ‣ Corporate: http://bestsolution.at
  • 3. (c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0 Targets of Java9 Modulesystem ‣ Split up rt.jar in smaller junks ‣ Avoids further introduction of cross-references ‣ Allows smaller Java-Runtimes (eg for IoT-Devices, …) ‣ Restrict Access to internal APIs (eg com.sun.misc.Unsafe) ‣ Allow developers to adopt it for their code as well
  • 4. (c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0 Java9 Modules vs OSGi ‣ The Implementation ‣ OSGi Module System is built upon classloaders ‣ Java9 Module System is implemented at the VM Level
  • 5. (c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0 Java9 Modules vs OSGi ‣ The Implementation ‣ OSGi Module System is built upon classloaders ‣ Java9 Module System is implemented at the VM Level OSGi foo-1.0.0 (BundleLoaderClassLoader@f1) bar-1.0.0 (BundleLoaderClassLoader@b1)
  • 6. (c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0 Java9 Modules vs OSGi ‣ The Implementation ‣ OSGi Module System is built upon classloaders ‣ Java9 Module System is implemented at the VM Level OSGi foo-1.0.0 (BundleLoaderClassLoader@f1) bar-1.0.0 (BundleLoaderClassLoader@b1) Java9 foo-1.0.0 (AppClassloader@A1) bar-1.0.0 (AppClassloader@A1)
  • 7. (c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0 Java9 Modules vs OSGi ‣ Dependency definition ‣ OSGi uses custom MANIFEST.MF entries Require-Bundle and Import-Package ‣ Java9 uses module-info.java and directive requires
  • 8. (c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0 Java9 Modules vs OSGi ‣ Dependency definition ‣ OSGi uses custom MANIFEST.MF entries Require-Bundle and Import-Package ‣ Java9 uses module-info.java and directive requires Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-SymbolicName: bar Require-Bundle: foo Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-SymbolicName: bar Import-Package: foo OSGi
  • 9. (c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0 Java9 Modules vs OSGi ‣ Dependency definition ‣ OSGi uses custom MANIFEST.MF entries Require-Bundle and Import-Package ‣ Java9 uses module-info.java and directive requires Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-SymbolicName: bar Require-Bundle: foo Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-SymbolicName: bar Import-Package: foo OSGi module bar { requires foo; } Java9
  • 10. (c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0 Java9 Modules vs OSGi ‣ Access Restrictions ‣ OSGi uses custom MANIFEST.MF entry Export-Package ‣ Java9 use module-info.java and directive exports
  • 11. (c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0 Java9 Modules vs OSGi ‣ Access Restrictions ‣ OSGi uses custom MANIFEST.MF entry Export-Package ‣ Java9 use module-info.java and directive exports Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-SymbolicName: foo Export-Package: foo OSGi
  • 12. (c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0 Java9 Modules vs OSGi ‣ Access Restrictions ‣ OSGi uses custom MANIFEST.MF entry Export-Package ‣ Java9 use module-info.java and directive exports Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-SymbolicName: foo Export-Package: foo OSGi module foo { exports foo; } Java9
  • 13. (c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0 Java9 Modules vs OSGi ‣ Services ‣ OSGi has eg Declarative Service Components and the BundleContext to lookup
  • 14. (c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0 Java9 Modules vs OSGi ‣ Services ‣ OSGi has eg Declarative Service Components and the BundleContext to lookup Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-SymbolicName: bar Require-Bundle: foo Service-Component: OSGI-INF/mycomponent.xml <?xml version="1.0" encoding="UTF-8"?> <scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0"> <implementation class="bar.BarService"/> <service> <provide interface="foo.Service"/> </service> </scr:component> Provider
  • 15. (c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0 Java9 Modules vs OSGi ‣ Services ‣ OSGi has eg Declarative Service Components and the BundleContext to lookup Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-SymbolicName: bar Require-Bundle: foo Service-Component: OSGI-INF/mycomponent.xml <?xml version="1.0" encoding="UTF-8"?> <scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0"> <implementation class="bar.BarService"/> <service> <provide interface="foo.Service"/> </service> </scr:component> Provider BundleContext ctx = getContext(cl); ServiceReference<Service> ref = 
 ctx.getServiceReference(Service.class); Service s = ctx.getService(ref); Consumer
  • 16. (c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0 Java9 Modules vs OSGi ‣ Service ‣ Java9 uses module-info.java and ServiceLoader for the lookup module bar { requires foo; provides foo.Service with bar.BarService; } Provider module foo { requires foo; uses foo.Service; } Consumer ServiceLoader<GreetService> l = ServiceLoader.load(Service.class); Service s = l.iterator().next();