SlideShare une entreprise Scribd logo
1  sur  32
GETTING MODULARWITH OSGI
Agenda
› How to make my Java more modular
› Discover and exploit OSGI
› Tools, tools, tools…
› Output
About me
Who: Andrii Krokhmalnyi
Domain: Java/Java EE
Company: EPAM Systems
Experience in OSGI: about 2 years
Modular design
› Separates functionality into distinct isolated sections (modules)
› Defines a standard interface for modules
› Adds ability to replace modules transparently for users of the system
› Improves scalability and robustness of the system
› Makes functional parts of the system reusable and easily updatable
› …But adds some extent of complexity in overall system orchestration
Modularity in Java: Service Provider Interface
META-INF/services/com.foo.logging.LogRenderer
com.foo.logging.impl.ConsoleLogRenderer
com.foo.service.MyService.java
public static void main(String[] args) {
ServiceLoader<LogRenderer> renderers =
ServiceLoader.load(LogRenderer.class);
for (LogRenderer renderer : renderers) {
...
}
Modularity in Java: OSGI
MANIFEST.MF
META-INF/MANIFEST.MF
Manifest-Version: 1.0
Bundle-SymbolicName: foo-service
Bundle-Activator: com.foo.service.Activator
Export-Package: com.foo.dao,com.foo.domain,com.foo.service
Import-Package: com.foo.logging;version="[2.0,3)"
image from http://wallpapersus.com/
Project Jigsaw
src/main/java/com/foo/service/module-info.java
module foo-service @ 1.2 {
requires jdk.base;
requires optional jdk.jaxp;
exports com.foo.bar;
permits foo-ui;
permits foo-console;
class com.foo.service.Main;
view dao {
exports com.foo.dao;
}
}
image from http://wallpapersgroup.net/
History & versioning
OSGI specification (version 4.3)
Framework Specification
FrameworkAPI
Start LevelAPI
Remote
Services
Bundle
WiringAPI
Additional
Services
Specifications
Security Layer
Module Layer
Life Cycle Layer
Service Layer
Core :: Container and bundles
image from http://www.osgi.org
OSGI Container
Class Loader #1
Bundle #1
Class Loader #2
Bundle #2
Class Loader #N
Bundle #N
(modules)
a regular jar archive with tweaked manifest
Core :: Bundles life-cycle
Core :: MANIFEST.MF headers
foo-service.jar/META-INF/MANIFEST.MF
...
Bundle-ManifestVersion: 2
Bundle-SymbolicName: com.foo.service
Bundle-Name: Foo Service
Bundle-Description: Foo Service Module
Bundle-Version: 1.0
Bundle-Activator: com.foo.service.BundleActivator
Require-Bundle: com.foo.logging
Export-Package: com.foo.domain,com.foo.dao,com.foo.service;uses:=“org.apache.log4j”
Import-Package: com.foo.logging;version=“[1.0,2)”,org.apache.log4j;version=“[2.0,3)”
DynamicImport-Package: *
...
Core :: MANIFEST.MF and Maven
pom.xml
<build><plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<configuration>
<instructions>
<Bundle-Activator>com.foo.service.BundleActivator</Bundle-Activator>
<Export-Package>com.foo.service</Export-Package>
<Import-Package>
com.foo.domain,
com.foo.dao,
*
</Import-Package>
<DynamicImport-Package>*</DynamicImport-Package>
<Require-Bundle>org.apache.commons.io</Require-Bundle>
</instructions>
</configuration>
</plugin>
</plugins></build>
OSGI Services :: Service producer
ServiceProducerBundleActivator.java
public class ServiceProducerBundleActivator implements BundleActivator {
private ServiceRegistration registration;
public void start(BundleContext context) throws Exception {
registration = context.registerService(CustomService.class.getName(),
new CustomServiceImpl(), null);
}
public void stop(BundleContext context) throws Exception {
registration.unregister();
}
}
OSGI Services :: Service consumer
ServiceConsumerBundleActivator.java
public class ServiceConsumerBundleActivator implements BundleActivator {
public void start(BundleContext context) throws Exception {
ServiceReference ref =
context.getServiceReference(CustomService.class.getName());
CustomService customService = (CustomService) context.getService(ref);
customService.customMethod();
...
}
}
OSGI Services :: Spring version
/META-INF/spring/spring-osgi.xml
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="..."
xmlns:osgi="http://www.springframework.org/schema/osgi" xsi:schemaLocation="...">
<osgi:service ref="customService" interface="com.foo.service.CustomService"/>
</beans>
Producer
/META-INF/spring/spring-osgi.xml
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="..."
xmlns:osgi="http://www.springframework.org/schema/osgi" xsi:schemaLocation="...">
<osgi:reference id="customService" interface="com.foo.service.CustomService"/>
</beans>
Consumer
WhereWAR becomesWAB
foo-web.war/META-INF/MANIFEST.MF
...
Bundle-ManifestVersion: 2
Bundle-SymbolicName: com.foo.web
Bundle-Version: 1.0
Bundle-Activator: com.foo.web.BundleActivator
Web-ContextPath: mainapp/foo
Webapp-Context: mainapp/foo
Bundle-ClassPath: WEB-INF/classes,.
Import-Package: com.foo.service;version=“[1.0,2)”,
com.foo.logging;version=“[1.0,2)”;resolution:="optional"
...
Compendium services
Compendium
OSGI Services
Preferences UserAdmin Monitor Admin
Log HTTP
DeviceAccess
Configuration
Admin
… and many more
OSGI and unit testing
Spring
DM
MockBundle
MockBundleContext
MockServiceRegistrationMockServiceReference
MockBundleActivator
OSGI and integration testing
CustomServiceIntegrationTest.java
@RunWith(PaxExam.class)
@ExamReactorStrategy(PerMethod.class)
public class CustomServiceIntegrationTest {
@Inject
CustomService customService;
@Configuration
public Option[] config() {
return options(mavenBundle("com.foo", "foo-service", "1.0"), junitBundles());
}
}
BND
image from http://freemarket.kiev.ua/
Compiled
classes
Instruction
file
OSGI
bundle
OSGI containers/frameworks
Apache Felix
36%
Equinox
37%
SpringSource
dm Server
8%
Knopflerfish
8%
Concierge
8%
ProSyst
3%
OSGI CONTAINERS POPULARITY
(BYVOTES AT STACKOVERFLOW.COM)
Overview of Apache Felix
Apache License 2.0
OSGI R4.2 compatible
Provides a web console
Provides a Maven plugin
Active development
Proved solution
Good documentation
Overview of Apache Karaf
Apache License 2.0
Supports both Felix and Equinox
Lightweight and extensible
Interactive shell console
Hot deployment
Native OS integration
Extra management tools
Active development
OSGI in real world
Positives
Negatives
Getting modular with OSGI

Contenu connexe

Tendances

XOOPS 2.5.x Operations Guide
XOOPS 2.5.x Operations GuideXOOPS 2.5.x Operations Guide
XOOPS 2.5.x Operations Guidexoopsproject
 
Linux Desktop Automation
Linux Desktop AutomationLinux Desktop Automation
Linux Desktop AutomationRui Lapa
 
Cocoon Blocks ApacheCon US 2005
Cocoon Blocks ApacheCon US 2005Cocoon Blocks ApacheCon US 2005
Cocoon Blocks ApacheCon US 2005Daniel Fagerstrom
 
Linux kernel driver tutorial vorlesung
Linux kernel driver tutorial vorlesungLinux kernel driver tutorial vorlesung
Linux kernel driver tutorial vorlesungdns -
 
What's New in LuaRocks - Lua Workshop 2014 - Hisham Muhammad
What's New in LuaRocks - Lua Workshop 2014 - Hisham MuhammadWhat's New in LuaRocks - Lua Workshop 2014 - Hisham Muhammad
What's New in LuaRocks - Lua Workshop 2014 - Hisham MuhammadHisham Muhammad
 
Using microsoft odbc and oracle gateway
Using microsoft odbc and oracle gatewayUsing microsoft odbc and oracle gateway
Using microsoft odbc and oracle gatewayAndy Liu
 
As7 web services - JUG Milan April 2012
As7 web services - JUG Milan April 2012As7 web services - JUG Milan April 2012
As7 web services - JUG Milan April 2012alepalin
 

Tendances (9)

XOOPS 2.5.x Operations Guide
XOOPS 2.5.x Operations GuideXOOPS 2.5.x Operations Guide
XOOPS 2.5.x Operations Guide
 
Linux Desktop Automation
Linux Desktop AutomationLinux Desktop Automation
Linux Desktop Automation
 
Cocoon Blocks ApacheCon US 2005
Cocoon Blocks ApacheCon US 2005Cocoon Blocks ApacheCon US 2005
Cocoon Blocks ApacheCon US 2005
 
Linux kernel driver tutorial vorlesung
Linux kernel driver tutorial vorlesungLinux kernel driver tutorial vorlesung
Linux kernel driver tutorial vorlesung
 
What's New in LuaRocks - Lua Workshop 2014 - Hisham Muhammad
What's New in LuaRocks - Lua Workshop 2014 - Hisham MuhammadWhat's New in LuaRocks - Lua Workshop 2014 - Hisham Muhammad
What's New in LuaRocks - Lua Workshop 2014 - Hisham Muhammad
 
Jsp Tutorial
Jsp TutorialJsp Tutorial
Jsp Tutorial
 
Using microsoft odbc and oracle gateway
Using microsoft odbc and oracle gatewayUsing microsoft odbc and oracle gateway
Using microsoft odbc and oracle gateway
 
Fosscon2013
Fosscon2013Fosscon2013
Fosscon2013
 
As7 web services - JUG Milan April 2012
As7 web services - JUG Milan April 2012As7 web services - JUG Milan April 2012
As7 web services - JUG Milan April 2012
 

En vedette

OSGi Community Event 2010 - Modular Applications on a Data Grid - A Case Stud...
OSGi Community Event 2010 - Modular Applications on a Data Grid - A Case Stud...OSGi Community Event 2010 - Modular Applications on a Data Grid - A Case Stud...
OSGi Community Event 2010 - Modular Applications on a Data Grid - A Case Stud...mfrancis
 
исследование корпоративной культуры компании билайн
исследование корпоративной культуры компании билайнисследование корпоративной культуры компании билайн
исследование корпоративной культуры компании билайнguest9144227
 
Kui Mina Oleksin Matemaatikaopetaja
Kui Mina Oleksin MatemaatikaopetajaKui Mina Oleksin Matemaatikaopetaja
Kui Mina Oleksin Matemaatikaopetajagueste7d648
 
De Veer Activitat2
De Veer Activitat2De Veer Activitat2
De Veer Activitat2powerveer
 
new acorn website
new acorn websitenew acorn website
new acorn websiteJoe Gilbert
 
OSGi & Java EE in GlassFish
OSGi & Java EE in GlassFishOSGi & Java EE in GlassFish
OSGi & Java EE in GlassFishSanjeeb Sahoo
 

En vedette (7)

OSGi Community Event 2010 - Modular Applications on a Data Grid - A Case Stud...
OSGi Community Event 2010 - Modular Applications on a Data Grid - A Case Stud...OSGi Community Event 2010 - Modular Applications on a Data Grid - A Case Stud...
OSGi Community Event 2010 - Modular Applications on a Data Grid - A Case Stud...
 
исследование корпоративной культуры компании билайн
исследование корпоративной культуры компании билайнисследование корпоративной культуры компании билайн
исследование корпоративной культуры компании билайн
 
проект
проектпроект
проект
 
Kui Mina Oleksin Matemaatikaopetaja
Kui Mina Oleksin MatemaatikaopetajaKui Mina Oleksin Matemaatikaopetaja
Kui Mina Oleksin Matemaatikaopetaja
 
De Veer Activitat2
De Veer Activitat2De Veer Activitat2
De Veer Activitat2
 
new acorn website
new acorn websitenew acorn website
new acorn website
 
OSGi & Java EE in GlassFish
OSGi & Java EE in GlassFishOSGi & Java EE in GlassFish
OSGi & Java EE in GlassFish
 

Similaire à Getting modular with OSGI

Modular Architectures using Micro Services
Modular Architectures using Micro ServicesModular Architectures using Micro Services
Modular Architectures using Micro ServicesMarcel Offermans
 
Os gi introduction made by Ly MInh Phuong-SOC team
Os gi introduction made by Ly MInh Phuong-SOC teamOs gi introduction made by Ly MInh Phuong-SOC team
Os gi introduction made by Ly MInh Phuong-SOC teamThuy_Dang
 
Frankenstein's IDE: NetBeans and OSGi
Frankenstein's IDE: NetBeans and OSGiFrankenstein's IDE: NetBeans and OSGi
Frankenstein's IDE: NetBeans and OSGiToni Epple
 
Travelling Light for the Long Haul - Ian Robinson
Travelling Light for the Long Haul -  Ian RobinsonTravelling Light for the Long Haul -  Ian Robinson
Travelling Light for the Long Haul - Ian Robinsonmfrancis
 
Travelling light for the long haul
Travelling light for the long haulTravelling light for the long haul
Travelling light for the long haulIan Robinson
 
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
 
Better Enterprise Integration With the WSO2 ESB 4.5.1
Better Enterprise Integration With the WSO2 ESB 4.5.1Better Enterprise Integration With the WSO2 ESB 4.5.1
Better Enterprise Integration With the WSO2 ESB 4.5.1WSO2
 
Managing Your Runtime With P2
Managing Your Runtime With P2Managing Your Runtime With P2
Managing Your Runtime With P2Pascal Rapicault
 
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
 
Workshop: Symfony2 Intruduction: (Controller, Routing, Model)
Workshop: Symfony2 Intruduction: (Controller, Routing, Model)Workshop: Symfony2 Intruduction: (Controller, Routing, Model)
Workshop: Symfony2 Intruduction: (Controller, Routing, Model)Antonio Peric-Mazar
 
How to build a custom stack with WSO2 carbon
How to build a custom stack with WSO2 carbon How to build a custom stack with WSO2 carbon
How to build a custom stack with WSO2 carbon WSO2
 
How to build a custom stack with wso2 carbon
How to build a custom stack with wso2 carbonHow to build a custom stack with wso2 carbon
How to build a custom stack with wso2 carbonShameera Rathnayaka
 
Osgi Webinar
Osgi WebinarOsgi Webinar
Osgi WebinarWSO2
 
Introduction to OSGi (Tokyo JUG)
Introduction to OSGi (Tokyo JUG)Introduction to OSGi (Tokyo JUG)
Introduction to OSGi (Tokyo JUG)njbartlett
 
L0016 - The Structure of an Eclipse Plug-in
L0016 - The Structure of an Eclipse Plug-inL0016 - The Structure of an Eclipse Plug-in
L0016 - The Structure of an Eclipse Plug-inTonny Madsen
 
Mageguru - magento custom module development
Mageguru -  magento custom module development Mageguru -  magento custom module development
Mageguru - magento custom module development Mage Guru
 
"Micro-frontends: Scalable and Modular Frontend in Parimatch Tech", Kyrylo Ai...
"Micro-frontends: Scalable and Modular Frontend in Parimatch Tech", Kyrylo Ai..."Micro-frontends: Scalable and Modular Frontend in Parimatch Tech", Kyrylo Ai...
"Micro-frontends: Scalable and Modular Frontend in Parimatch Tech", Kyrylo Ai...Fwdays
 

Similaire à Getting modular with OSGI (20)

Modular Architectures using Micro Services
Modular Architectures using Micro ServicesModular Architectures using Micro Services
Modular Architectures using Micro Services
 
Os gi introduction made by Ly MInh Phuong-SOC team
Os gi introduction made by Ly MInh Phuong-SOC teamOs gi introduction made by Ly MInh Phuong-SOC team
Os gi introduction made by Ly MInh Phuong-SOC team
 
Frankenstein's IDE: NetBeans and OSGi
Frankenstein's IDE: NetBeans and OSGiFrankenstein's IDE: NetBeans and OSGi
Frankenstein's IDE: NetBeans and OSGi
 
Travelling Light for the Long Haul - Ian Robinson
Travelling Light for the Long Haul -  Ian RobinsonTravelling Light for the Long Haul -  Ian Robinson
Travelling Light for the Long Haul - Ian Robinson
 
Travelling light for the long haul
Travelling light for the long haulTravelling light for the long haul
Travelling light for the long haul
 
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/)
 
Better Enterprise Integration With the WSO2 ESB 4.5.1
Better Enterprise Integration With the WSO2 ESB 4.5.1Better Enterprise Integration With the WSO2 ESB 4.5.1
Better Enterprise Integration With the WSO2 ESB 4.5.1
 
Managing Your Runtime With P2
Managing Your Runtime With P2Managing Your Runtime With P2
Managing Your Runtime With P2
 
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
 
Workshop: Symfony2 Intruduction: (Controller, Routing, Model)
Workshop: Symfony2 Intruduction: (Controller, Routing, Model)Workshop: Symfony2 Intruduction: (Controller, Routing, Model)
Workshop: Symfony2 Intruduction: (Controller, Routing, Model)
 
How to build a custom stack with WSO2 carbon
How to build a custom stack with WSO2 carbon How to build a custom stack with WSO2 carbon
How to build a custom stack with WSO2 carbon
 
How to build a custom stack with wso2 carbon
How to build a custom stack with wso2 carbonHow to build a custom stack with wso2 carbon
How to build a custom stack with wso2 carbon
 
Osgi Webinar
Osgi WebinarOsgi Webinar
Osgi Webinar
 
Introduction to OSGi (Tokyo JUG)
Introduction to OSGi (Tokyo JUG)Introduction to OSGi (Tokyo JUG)
Introduction to OSGi (Tokyo JUG)
 
L0016 - The Structure of an Eclipse Plug-in
L0016 - The Structure of an Eclipse Plug-inL0016 - The Structure of an Eclipse Plug-in
L0016 - The Structure of an Eclipse Plug-in
 
Enterprise service bus part 2
Enterprise service bus part 2Enterprise service bus part 2
Enterprise service bus part 2
 
Mageguru - magento custom module development
Mageguru -  magento custom module development Mageguru -  magento custom module development
Mageguru - magento custom module development
 
IJTC ServiceMix 4
IJTC   ServiceMix 4IJTC   ServiceMix 4
IJTC ServiceMix 4
 
"Micro-frontends: Scalable and Modular Frontend in Parimatch Tech", Kyrylo Ai...
"Micro-frontends: Scalable and Modular Frontend in Parimatch Tech", Kyrylo Ai..."Micro-frontends: Scalable and Modular Frontend in Parimatch Tech", Kyrylo Ai...
"Micro-frontends: Scalable and Modular Frontend in Parimatch Tech", Kyrylo Ai...
 
What's new in p2 (2009)?
What's new in p2 (2009)?What's new in p2 (2009)?
What's new in p2 (2009)?
 

Dernier

08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 

Dernier (20)

08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 

Getting modular with OSGI

  • 2. Agenda › How to make my Java more modular › Discover and exploit OSGI › Tools, tools, tools… › Output
  • 3. About me Who: Andrii Krokhmalnyi Domain: Java/Java EE Company: EPAM Systems Experience in OSGI: about 2 years
  • 4.
  • 5. Modular design › Separates functionality into distinct isolated sections (modules) › Defines a standard interface for modules › Adds ability to replace modules transparently for users of the system › Improves scalability and robustness of the system › Makes functional parts of the system reusable and easily updatable › …But adds some extent of complexity in overall system orchestration
  • 6. Modularity in Java: Service Provider Interface META-INF/services/com.foo.logging.LogRenderer com.foo.logging.impl.ConsoleLogRenderer com.foo.service.MyService.java public static void main(String[] args) { ServiceLoader<LogRenderer> renderers = ServiceLoader.load(LogRenderer.class); for (LogRenderer renderer : renderers) { ... }
  • 7. Modularity in Java: OSGI MANIFEST.MF META-INF/MANIFEST.MF Manifest-Version: 1.0 Bundle-SymbolicName: foo-service Bundle-Activator: com.foo.service.Activator Export-Package: com.foo.dao,com.foo.domain,com.foo.service Import-Package: com.foo.logging;version="[2.0,3)" image from http://wallpapersus.com/
  • 8. Project Jigsaw src/main/java/com/foo/service/module-info.java module foo-service @ 1.2 { requires jdk.base; requires optional jdk.jaxp; exports com.foo.bar; permits foo-ui; permits foo-console; class com.foo.service.Main; view dao { exports com.foo.dao; } } image from http://wallpapersgroup.net/
  • 9.
  • 11. OSGI specification (version 4.3) Framework Specification FrameworkAPI Start LevelAPI Remote Services Bundle WiringAPI Additional Services Specifications Security Layer Module Layer Life Cycle Layer Service Layer
  • 12. Core :: Container and bundles image from http://www.osgi.org OSGI Container Class Loader #1 Bundle #1 Class Loader #2 Bundle #2 Class Loader #N Bundle #N (modules) a regular jar archive with tweaked manifest
  • 13. Core :: Bundles life-cycle
  • 14. Core :: MANIFEST.MF headers foo-service.jar/META-INF/MANIFEST.MF ... Bundle-ManifestVersion: 2 Bundle-SymbolicName: com.foo.service Bundle-Name: Foo Service Bundle-Description: Foo Service Module Bundle-Version: 1.0 Bundle-Activator: com.foo.service.BundleActivator Require-Bundle: com.foo.logging Export-Package: com.foo.domain,com.foo.dao,com.foo.service;uses:=“org.apache.log4j” Import-Package: com.foo.logging;version=“[1.0,2)”,org.apache.log4j;version=“[2.0,3)” DynamicImport-Package: * ...
  • 15. Core :: MANIFEST.MF and Maven pom.xml <build><plugins> <plugin> <groupId>org.apache.felix</groupId> <artifactId>maven-bundle-plugin</artifactId> <configuration> <instructions> <Bundle-Activator>com.foo.service.BundleActivator</Bundle-Activator> <Export-Package>com.foo.service</Export-Package> <Import-Package> com.foo.domain, com.foo.dao, * </Import-Package> <DynamicImport-Package>*</DynamicImport-Package> <Require-Bundle>org.apache.commons.io</Require-Bundle> </instructions> </configuration> </plugin> </plugins></build>
  • 16. OSGI Services :: Service producer ServiceProducerBundleActivator.java public class ServiceProducerBundleActivator implements BundleActivator { private ServiceRegistration registration; public void start(BundleContext context) throws Exception { registration = context.registerService(CustomService.class.getName(), new CustomServiceImpl(), null); } public void stop(BundleContext context) throws Exception { registration.unregister(); } }
  • 17. OSGI Services :: Service consumer ServiceConsumerBundleActivator.java public class ServiceConsumerBundleActivator implements BundleActivator { public void start(BundleContext context) throws Exception { ServiceReference ref = context.getServiceReference(CustomService.class.getName()); CustomService customService = (CustomService) context.getService(ref); customService.customMethod(); ... } }
  • 18. OSGI Services :: Spring version /META-INF/spring/spring-osgi.xml <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="..." xmlns:osgi="http://www.springframework.org/schema/osgi" xsi:schemaLocation="..."> <osgi:service ref="customService" interface="com.foo.service.CustomService"/> </beans> Producer /META-INF/spring/spring-osgi.xml <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="..." xmlns:osgi="http://www.springframework.org/schema/osgi" xsi:schemaLocation="..."> <osgi:reference id="customService" interface="com.foo.service.CustomService"/> </beans> Consumer
  • 19. WhereWAR becomesWAB foo-web.war/META-INF/MANIFEST.MF ... Bundle-ManifestVersion: 2 Bundle-SymbolicName: com.foo.web Bundle-Version: 1.0 Bundle-Activator: com.foo.web.BundleActivator Web-ContextPath: mainapp/foo Webapp-Context: mainapp/foo Bundle-ClassPath: WEB-INF/classes,. Import-Package: com.foo.service;version=“[1.0,2)”, com.foo.logging;version=“[1.0,2)”;resolution:="optional" ...
  • 20. Compendium services Compendium OSGI Services Preferences UserAdmin Monitor Admin Log HTTP DeviceAccess Configuration Admin … and many more
  • 21. OSGI and unit testing Spring DM MockBundle MockBundleContext MockServiceRegistrationMockServiceReference MockBundleActivator
  • 22. OSGI and integration testing CustomServiceIntegrationTest.java @RunWith(PaxExam.class) @ExamReactorStrategy(PerMethod.class) public class CustomServiceIntegrationTest { @Inject CustomService customService; @Configuration public Option[] config() { return options(mavenBundle("com.foo", "foo-service", "1.0"), junitBundles()); } }
  • 23.
  • 25. OSGI containers/frameworks Apache Felix 36% Equinox 37% SpringSource dm Server 8% Knopflerfish 8% Concierge 8% ProSyst 3% OSGI CONTAINERS POPULARITY (BYVOTES AT STACKOVERFLOW.COM)
  • 26. Overview of Apache Felix Apache License 2.0 OSGI R4.2 compatible Provides a web console Provides a Maven plugin Active development Proved solution Good documentation
  • 27. Overview of Apache Karaf Apache License 2.0 Supports both Felix and Equinox Lightweight and extensible Interactive shell console Hot deployment Native OS integration Extra management tools Active development
  • 28. OSGI in real world
  • 29.

Notes de l'éditeur

  1. permits = friendly modules list (current module is accessible only for those)class = entry class
  2. Framework API:org.osgi.framework packageBundle Wiring API: for wiring bundles (requirements and capabilities), classes BundleRevision, BundleWiring, FrameworkWiringStart Level API:describes how to enable a management agent to control the relative starting and stopping order of bundles in an OSGi Service Platform (setting start level, in Karafosgi:bundle-level, osgi:start-level).Remote Services: setup of remote access for the services
  3. Class loading: “uses” marks packages that exported API use (method signatures, parent classes), so the framework can check if those don’t conflict with imported packagesif java.* =&gt; parentif in Import-Package =&gt; exportersearch in Require-Bundlesearch in Bundle-ClassPathif in DynamicImport-Package =&gt; wiring
  4. Web-ContextPath: OSGI 4.2 specWebapp-Context: PAX Web specific
  5. Device Access specification supports the coordination of automatic detection and attachment ofexisting devices on an OSGi Service Platform, facilitates hot-plugging and -unplugging of newdevices, and downloads and installs device drivers on demand.Preferences = system or user-specific data storageUser Admin = authentication/authorizationMonitor Admin = status variables get/set/reset from administrative bundles
  6. Management tools: configuration (property files), logging, security, etc