SlideShare uma empresa Scribd logo
1 de 32
Baixar para ler offline
Service Oriented Web Development with OSGi 
Carsten Ziegeler | cziegeler@apache.org 
1 
OSGi Community Event 2014
About 
cziegeler@apache.org @cziegeler 
• RnD Team at Adobe Research Switzerland 
• Member of the Apache Software Foundation 
• Apache Felix and Apache Sling (PMC and committer) 
• And other Apache projects 
• OSGi Core Platform and Enterprise Expert Groups 
• Member of the OSGi Board 
• Book / article author, technical reviewer, conference speaker 
2
OSGi Preconceptions 
No tooling ?!? 
3 
No POJOs 
Too slow 
Not suitable for 
the enterprise 
No dependency injection
4
The Next Big Thing 
5
Building Blocks 
§ Module aka Bundle 
§ Services 
§ Components 
6
Game Design 
public enum Level { 
EASY, 
MEDIUM, 
HARD 
} 
public interface GameController { 
Game startGame(final String name, 
final Level level); 
int nextGuess(final Game status, 
final int guess); 
int getMax(final Level level); 
7 
}
Implementation 
@Component 
public class GameControllerImpl implements GameController { 
8 
...
Configuration 
public @interface Config { 
int easy_max() default 10; 
int medium_max() default 50; 
int hard_max() default 100; 
} 
9
private Config configuration; 
@Activate 
protected void activate(final Config config) { 
this.configuration = config; 
10 
}
public int getMax(final Level level) { 
11 
int max = 0; 
switch (level) { 
case EASY : max = configuration.easy_max(); break; 
case MEDIUM : max = configuration.medium_max(); break; 
case HARD : max = configuration.hard_max(); break; 
} 
return max; 
}
Web? 
@Component( service = Servlet.class , 
property="osgi.http.whiteboard.servlet.pattern=/game") 
public class GameServlet extends HttpServlet { 
12
public class GameServlet extends HttpServlet { 
@FieldReference 
private GameController controller; 
13
14
15 
No POJOs 
Too slow 
Not suitable for 
the enterprise 
No dependency injection 
No tooling 
✔
Recipe 
§ OSGi Declarative Services (Compendium Chapter 112) 
§ + RFC 190 Declarative Services Enhancements (OSGi R6) 
§ + RFC 212 Field Injection for Declarative Services (OSGi R6) 
§ OSGi Whiteboard Service 
§ + RFC 189 (OSGi R6) 
§ OSGi Configuration Admin (Compendium Chapter 104) 
§ OSGi Metatype Service (Compendium Chapter 105) 
§ + RFC 208 Metatype Annotations 
16
Management 
17
Metatype 
18 
@ObjectClassDefinition( 
name = "Game Configuration", 
description = "The configuration for the guessing game.") 
public @interface Config { 
@AttributeDefinition(name="Easy", 
description="Maximum value for easy") 
int easy_max() default 10;
Metatype 
@Component 
@Designate( ocd = Config.class ) 
public class GameControllerImpl 
implements GameController { 
19
Component Container Interaction 
OSGi Service Registry 
Declarative 
Services Blueprint 
20 
iPojo, 
Dependency 
Manager, 
…. 
Framework API
Service Scopes 
• Singleton 
• Bundle 
• Prototype 
21
Servlets 
@Component( service = Servlet.class , 
scope=ServiceScope.PROTOTYPE, 
property="osgi.http.whiteboard.servlet.pattern=/game") 
public class GameServlet extends HttpServlet { 
public void init() {...} 
public void destroy() {...} 
22
Dynamics 
§ Lazy instantiation 
§ Reference policy and cardinality 
§ Reconfiguration 
23
Unary References 
@FieldReference 
private GameController controller; 
@FieldReference( 
cardinality=ReferenceCardinality.OPTIONAL 
policy=ReferencePolicy.DYNAMIC) 
private volatile GameStatistics stats; 
24
Multiple References 
@FieldReference( 
cardinality=ReferenceCardinality.MULTIPLE) 
private volatile List<Highscore> highscores; 
25
Multiple References 
@FieldReference 
private final Set<Highscore> highscores = 
new ConcurrentSkipListSet<Highscore>(); 
26
Reconfiguration 
private volatile Config configuration; 
@Activate 
@Modified 
protected void activate(final Config config) { 
this.configuration = config; 
} 
27
Web Contexts 
28 
Servlet Context 
/play 
Authentication 
Servlet B 
/foo 
Servlet A 
/game 
Servlet C 
/bar 
Servlet Filter 
Servlet Context 
/fooapp 
Authentication 
Servlet X 
/foo
Web Contexts 
@Component( service = Servlet.class , 
property={"osgi.http.whiteboard.servlet.pattern=/foo", 
"osgi.http.whiteboard.context.select=mygame"} 
public class ServletB extends HttpServlet { 
@Component( service = Servlet.class , 
property={"osgi.http.whiteboard.servlet.pattern=/bar", 
"osgi.http.whiteboard.context.select=game"} 
public class ServletC extends HttpServlet { 
29
Try it out today! 
§ HTTP Whiteboard Service 
§ Servlet contexts (grouping, authentication) 
§ Servlets 
§ Filters 
§ Listeners 
30
Try it out today! 
§ Declarative Services 
§ Easy too use 
§ Pojos 
§ DI with handling dynamics 
§ Tooling 
§ Open Source Solutions 
§ Building large scale enterprise apps 
31
QnA 
32

Mais conteúdo relacionado

Mais procurados

A Brief Introduce to WSGI
A Brief Introduce to WSGIA Brief Introduce to WSGI
A Brief Introduce to WSGI
Mingli Yuan
 
Apache Aries: A blueprint for developing with OSGi and JEE
Apache Aries: A blueprint for developing with OSGi and JEEApache Aries: A blueprint for developing with OSGi and JEE
Apache Aries: A blueprint for developing with OSGi and JEE
mahrwald
 

Mais procurados (19)

Use Case: Building OSGi Enterprise Applications (QCon 14)
Use Case: Building OSGi Enterprise Applications (QCon 14)Use Case: Building OSGi Enterprise Applications (QCon 14)
Use Case: Building OSGi Enterprise Applications (QCon 14)
 
What's cool in the new and updated OSGi Specs (EclipseCon 2014)
What's cool in the new and updated OSGi Specs (EclipseCon 2014)What's cool in the new and updated OSGi Specs (EclipseCon 2014)
What's cool in the new and updated OSGi Specs (EclipseCon 2014)
 
Managing an OSGi Framework with Apache Felix Web Console
Managing an OSGi Framework with  Apache Felix Web ConsoleManaging an OSGi Framework with  Apache Felix Web Console
Managing an OSGi Framework with Apache Felix Web Console
 
Nestjs MasterClass Slides
Nestjs MasterClass SlidesNestjs MasterClass Slides
Nestjs MasterClass Slides
 
What is the ServiceStack?
What is the ServiceStack?What is the ServiceStack?
What is the ServiceStack?
 
OSGi Cloud Ecosystems (EclipseCon 2013)
OSGi Cloud Ecosystems (EclipseCon 2013)OSGi Cloud Ecosystems (EclipseCon 2013)
OSGi Cloud Ecosystems (EclipseCon 2013)
 
Android Libs - Retrofit
Android Libs - RetrofitAndroid Libs - Retrofit
Android Libs - Retrofit
 
Solid NodeJS with TypeScript, Jest & NestJS
Solid NodeJS with TypeScript, Jest & NestJSSolid NodeJS with TypeScript, Jest & NestJS
Solid NodeJS with TypeScript, Jest & NestJS
 
Automated Application Management with SaltStack
Automated Application Management with SaltStackAutomated Application Management with SaltStack
Automated Application Management with SaltStack
 
Tales from the OSGi trenches
Tales from the OSGi trenchesTales from the OSGi trenches
Tales from the OSGi trenches
 
Durable functions
Durable functionsDurable functions
Durable functions
 
W-JAX 2011: OSGi with Apache Karaf
W-JAX 2011: OSGi with Apache KarafW-JAX 2011: OSGi with Apache Karaf
W-JAX 2011: OSGi with Apache Karaf
 
Generating cross platform .NET based azure IoTdevice
Generating cross platform .NET based azure IoTdeviceGenerating cross platform .NET based azure IoTdevice
Generating cross platform .NET based azure IoTdevice
 
A Brief Introduce to WSGI
A Brief Introduce to WSGIA Brief Introduce to WSGI
A Brief Introduce to WSGI
 
HashiCorp Vault Plugin Infrastructure
HashiCorp Vault Plugin InfrastructureHashiCorp Vault Plugin Infrastructure
HashiCorp Vault Plugin Infrastructure
 
잘 키운 모노리스 하나 열 마이크로서비스 안 부럽다
잘 키운 모노리스 하나 열 마이크로서비스 안 부럽다잘 키운 모노리스 하나 열 마이크로서비스 안 부럽다
잘 키운 모노리스 하나 열 마이크로서비스 안 부럽다
 
Java Play Restful JPA
Java Play Restful JPAJava Play Restful JPA
Java Play Restful JPA
 
The Web on OSGi: Here's How
The Web on OSGi: Here's HowThe Web on OSGi: Here's How
The Web on OSGi: Here's How
 
Apache Aries: A blueprint for developing with OSGi and JEE
Apache Aries: A blueprint for developing with OSGi and JEEApache Aries: A blueprint for developing with OSGi and JEE
Apache Aries: A blueprint for developing with OSGi and JEE
 

Semelhante a Service Oriented Web Development with OSGi - C Ziegeler

Networking and Data Access with Eqela
Networking and Data Access with EqelaNetworking and Data Access with Eqela
Networking and Data Access with Eqela
jobandesther
 

Semelhante a Service Oriented Web Development with OSGi - C Ziegeler (20)

OSGi Enterprise R6 specs are out! - David Bosschaert & Carsten Ziegeler
OSGi Enterprise R6 specs are out! - David Bosschaert & Carsten ZiegelerOSGi Enterprise R6 specs are out! - David Bosschaert & Carsten Ziegeler
OSGi Enterprise R6 specs are out! - David Bosschaert & Carsten Ziegeler
 
Maximize the power of OSGi
Maximize the power of OSGiMaximize the power of OSGi
Maximize the power of OSGi
 
Maximise the Power of OSGi - Carsten Ziegeler & David Bosschaert
Maximise the Power of OSGi - Carsten Ziegeler & David BosschaertMaximise the Power of OSGi - Carsten Ziegeler & David Bosschaert
Maximise the Power of OSGi - Carsten Ziegeler & David Bosschaert
 
Maximize the power of OSGi in AEM
Maximize the power of OSGi in AEM Maximize the power of OSGi in AEM
Maximize the power of OSGi in AEM
 
Super-NetOps Source of Truth
Super-NetOps Source of TruthSuper-NetOps Source of Truth
Super-NetOps Source of Truth
 
Expanding your impact with programmability in the data center
Expanding your impact with programmability in the data centerExpanding your impact with programmability in the data center
Expanding your impact with programmability in the data center
 
Full Stack Development With Node.Js And NoSQL (Nic Raboy & Arun Gupta)
Full Stack Development With Node.Js And NoSQL (Nic Raboy & Arun Gupta)Full Stack Development With Node.Js And NoSQL (Nic Raboy & Arun Gupta)
Full Stack Development With Node.Js And NoSQL (Nic Raboy & Arun Gupta)
 
Solving anything in VCL
Solving anything in VCLSolving anything in VCL
Solving anything in VCL
 
Gwt.create
Gwt.createGwt.create
Gwt.create
 
BeJUG Meetup - What's coming in the OSGi R7 Specification
BeJUG Meetup - What's coming in the OSGi R7 SpecificationBeJUG Meetup - What's coming in the OSGi R7 Specification
BeJUG Meetup - What's coming in the OSGi R7 Specification
 
Super-NetOps Source of Truth
Super-NetOps Source of TruthSuper-NetOps Source of Truth
Super-NetOps Source of Truth
 
Improve PostgreSQL replication with Oracle GoldenGate
Improve PostgreSQL replication with Oracle GoldenGateImprove PostgreSQL replication with Oracle GoldenGate
Improve PostgreSQL replication with Oracle GoldenGate
 
SharePoint for the .NET Developer
SharePoint for the .NET DeveloperSharePoint for the .NET Developer
SharePoint for the .NET Developer
 
Monitoring OSGi Applications with the Web Console
Monitoring OSGi Applications with the Web ConsoleMonitoring OSGi Applications with the Web Console
Monitoring OSGi Applications with the Web Console
 
Monitoring OSGi Applications with the Web Console
Monitoring OSGi Applications with the Web ConsoleMonitoring OSGi Applications with the Web Console
Monitoring OSGi Applications with the Web Console
 
Quick and Easy Development with Node.js and Couchbase Server
Quick and Easy Development with Node.js and Couchbase ServerQuick and Easy Development with Node.js and Couchbase Server
Quick and Easy Development with Node.js and Couchbase Server
 
Sprint 138
Sprint 138Sprint 138
Sprint 138
 
Networking and Data Access with Eqela
Networking and Data Access with EqelaNetworking and Data Access with Eqela
Networking and Data Access with Eqela
 
Future of Web Apps: Google Gears
Future of Web Apps: Google GearsFuture of Web Apps: Google Gears
Future of Web Apps: Google Gears
 
InterConnect2016: WebApp Architectures with Java and Node.js
InterConnect2016: WebApp Architectures with Java and Node.jsInterConnect2016: WebApp Architectures with Java and Node.js
InterConnect2016: WebApp Architectures with Java and Node.js
 

Mais de mfrancis

Migrating from PDE to Bndtools in Practice - Amit Kumar Mondal (Deutsche Tele...
Migrating from PDE to Bndtools in Practice - Amit Kumar Mondal (Deutsche Tele...Migrating from PDE to Bndtools in Practice - Amit Kumar Mondal (Deutsche Tele...
Migrating from PDE to Bndtools in Practice - Amit Kumar Mondal (Deutsche Tele...
mfrancis
 
How OSGi drives cross-sector energy management - Jörn Tümmler (SMA Solar Tech...
How OSGi drives cross-sector energy management - Jörn Tümmler (SMA Solar Tech...How OSGi drives cross-sector energy management - Jörn Tümmler (SMA Solar Tech...
How OSGi drives cross-sector energy management - Jörn Tümmler (SMA Solar Tech...
mfrancis
 
Improved developer productivity thanks to Maven and OSGi - Lukasz Dywicki (Co...
Improved developer productivity thanks to Maven and OSGi - Lukasz Dywicki (Co...Improved developer productivity thanks to Maven and OSGi - Lukasz Dywicki (Co...
Improved developer productivity thanks to Maven and OSGi - Lukasz Dywicki (Co...
mfrancis
 
Prototyping IoT systems with a hybrid OSGi & Node-RED platform - Bruce Jackso...
Prototyping IoT systems with a hybrid OSGi & Node-RED platform - Bruce Jackso...Prototyping IoT systems with a hybrid OSGi & Node-RED platform - Bruce Jackso...
Prototyping IoT systems with a hybrid OSGi & Node-RED platform - Bruce Jackso...
mfrancis
 

Mais de mfrancis (20)

Eclipse Modeling Framework and plain OSGi the easy way - Mark Hoffman (Data I...
Eclipse Modeling Framework and plain OSGi the easy way - Mark Hoffman (Data I...Eclipse Modeling Framework and plain OSGi the easy way - Mark Hoffman (Data I...
Eclipse Modeling Framework and plain OSGi the easy way - Mark Hoffman (Data I...
 
OSGi and Java 9+ - BJ Hargrave (IBM)
OSGi and Java 9+ - BJ Hargrave (IBM)OSGi and Java 9+ - BJ Hargrave (IBM)
OSGi and Java 9+ - BJ Hargrave (IBM)
 
Simplify Web UX Coding using OSGi Modularity Magic - Paul Fraser (A2Z Living)
Simplify Web UX Coding using OSGi Modularity Magic - Paul Fraser (A2Z Living)Simplify Web UX Coding using OSGi Modularity Magic - Paul Fraser (A2Z Living)
Simplify Web UX Coding using OSGi Modularity Magic - Paul Fraser (A2Z Living)
 
OSGi for the data centre - Connecting OSGi to Kubernetes - Frank Lyaruu
OSGi for the data centre - Connecting OSGi to Kubernetes - Frank LyaruuOSGi for the data centre - Connecting OSGi to Kubernetes - Frank Lyaruu
OSGi for the data centre - Connecting OSGi to Kubernetes - Frank Lyaruu
 
Remote Management and Monitoring of Distributed OSGi Applications - Tim Verbe...
Remote Management and Monitoring of Distributed OSGi Applications - Tim Verbe...Remote Management and Monitoring of Distributed OSGi Applications - Tim Verbe...
Remote Management and Monitoring of Distributed OSGi Applications - Tim Verbe...
 
OSGi with Docker - a powerful way to develop Java systems - Udo Hafermann (So...
OSGi with Docker - a powerful way to develop Java systems - Udo Hafermann (So...OSGi with Docker - a powerful way to develop Java systems - Udo Hafermann (So...
OSGi with Docker - a powerful way to develop Java systems - Udo Hafermann (So...
 
A real world use case with OSGi R7 - Jurgen Albert (Data In Motion Consulting...
A real world use case with OSGi R7 - Jurgen Albert (Data In Motion Consulting...A real world use case with OSGi R7 - Jurgen Albert (Data In Motion Consulting...
A real world use case with OSGi R7 - Jurgen Albert (Data In Motion Consulting...
 
OSGi Feature Model - Where Art Thou - David Bosschaert (Adobe)
OSGi Feature Model - Where Art Thou - David Bosschaert (Adobe)OSGi Feature Model - Where Art Thou - David Bosschaert (Adobe)
OSGi Feature Model - Where Art Thou - David Bosschaert (Adobe)
 
Migrating from PDE to Bndtools in Practice - Amit Kumar Mondal (Deutsche Tele...
Migrating from PDE to Bndtools in Practice - Amit Kumar Mondal (Deutsche Tele...Migrating from PDE to Bndtools in Practice - Amit Kumar Mondal (Deutsche Tele...
Migrating from PDE to Bndtools in Practice - Amit Kumar Mondal (Deutsche Tele...
 
OSGi CDI Integration Specification - Ray Augé (Liferay)
OSGi CDI Integration Specification - Ray Augé (Liferay)OSGi CDI Integration Specification - Ray Augé (Liferay)
OSGi CDI Integration Specification - Ray Augé (Liferay)
 
How OSGi drives cross-sector energy management - Jörn Tümmler (SMA Solar Tech...
How OSGi drives cross-sector energy management - Jörn Tümmler (SMA Solar Tech...How OSGi drives cross-sector energy management - Jörn Tümmler (SMA Solar Tech...
How OSGi drives cross-sector energy management - Jörn Tümmler (SMA Solar Tech...
 
Improved developer productivity thanks to Maven and OSGi - Lukasz Dywicki (Co...
Improved developer productivity thanks to Maven and OSGi - Lukasz Dywicki (Co...Improved developer productivity thanks to Maven and OSGi - Lukasz Dywicki (Co...
Improved developer productivity thanks to Maven and OSGi - Lukasz Dywicki (Co...
 
It Was Twenty Years Ago Today - Building an OSGi based Smart Home System - Ch...
It Was Twenty Years Ago Today - Building an OSGi based Smart Home System - Ch...It Was Twenty Years Ago Today - Building an OSGi based Smart Home System - Ch...
It Was Twenty Years Ago Today - Building an OSGi based Smart Home System - Ch...
 
Popular patterns revisited on OSGi - Christian Schneider (Adobe)
Popular patterns revisited on OSGi - Christian Schneider (Adobe)Popular patterns revisited on OSGi - Christian Schneider (Adobe)
Popular patterns revisited on OSGi - Christian Schneider (Adobe)
 
Integrating SLF4J and the new OSGi LogService 1.4 - BJ Hargrave (IBM)
Integrating SLF4J and the new OSGi LogService 1.4 - BJ Hargrave (IBM)Integrating SLF4J and the new OSGi LogService 1.4 - BJ Hargrave (IBM)
Integrating SLF4J and the new OSGi LogService 1.4 - BJ Hargrave (IBM)
 
OSG(a)i: because AI needs a runtime - Tim Verbelen (imec)
OSG(a)i: because AI needs a runtime - Tim Verbelen (imec)OSG(a)i: because AI needs a runtime - Tim Verbelen (imec)
OSG(a)i: because AI needs a runtime - Tim Verbelen (imec)
 
Flying to Jupiter with OSGi - Tony Walsh (ESA) & Hristo Indzhov (Telespazio V...
Flying to Jupiter with OSGi - Tony Walsh (ESA) & Hristo Indzhov (Telespazio V...Flying to Jupiter with OSGi - Tony Walsh (ESA) & Hristo Indzhov (Telespazio V...
Flying to Jupiter with OSGi - Tony Walsh (ESA) & Hristo Indzhov (Telespazio V...
 
MicroProfile, OSGi was meant for this - Ray Auge (Liferay)
MicroProfile, OSGi was meant for this - Ray Auge (Liferay)MicroProfile, OSGi was meant for this - Ray Auge (Liferay)
MicroProfile, OSGi was meant for this - Ray Auge (Liferay)
 
Prototyping IoT systems with a hybrid OSGi & Node-RED platform - Bruce Jackso...
Prototyping IoT systems with a hybrid OSGi & Node-RED platform - Bruce Jackso...Prototyping IoT systems with a hybrid OSGi & Node-RED platform - Bruce Jackso...
Prototyping IoT systems with a hybrid OSGi & Node-RED platform - Bruce Jackso...
 
How to connect your OSGi application - Dirk Fauth (Bosch)
How to connect your OSGi application - Dirk Fauth (Bosch)How to connect your OSGi application - Dirk Fauth (Bosch)
How to connect your OSGi application - Dirk Fauth (Bosch)
 

Último

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Último (20)

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 

Service Oriented Web Development with OSGi - C Ziegeler

  • 1. Service Oriented Web Development with OSGi Carsten Ziegeler | cziegeler@apache.org 1 OSGi Community Event 2014
  • 2. About cziegeler@apache.org @cziegeler • RnD Team at Adobe Research Switzerland • Member of the Apache Software Foundation • Apache Felix and Apache Sling (PMC and committer) • And other Apache projects • OSGi Core Platform and Enterprise Expert Groups • Member of the OSGi Board • Book / article author, technical reviewer, conference speaker 2
  • 3. OSGi Preconceptions No tooling ?!? 3 No POJOs Too slow Not suitable for the enterprise No dependency injection
  • 4. 4
  • 5. The Next Big Thing 5
  • 6. Building Blocks § Module aka Bundle § Services § Components 6
  • 7. Game Design public enum Level { EASY, MEDIUM, HARD } public interface GameController { Game startGame(final String name, final Level level); int nextGuess(final Game status, final int guess); int getMax(final Level level); 7 }
  • 8. Implementation @Component public class GameControllerImpl implements GameController { 8 ...
  • 9. Configuration public @interface Config { int easy_max() default 10; int medium_max() default 50; int hard_max() default 100; } 9
  • 10. private Config configuration; @Activate protected void activate(final Config config) { this.configuration = config; 10 }
  • 11. public int getMax(final Level level) { 11 int max = 0; switch (level) { case EASY : max = configuration.easy_max(); break; case MEDIUM : max = configuration.medium_max(); break; case HARD : max = configuration.hard_max(); break; } return max; }
  • 12. Web? @Component( service = Servlet.class , property="osgi.http.whiteboard.servlet.pattern=/game") public class GameServlet extends HttpServlet { 12
  • 13. public class GameServlet extends HttpServlet { @FieldReference private GameController controller; 13
  • 14. 14
  • 15. 15 No POJOs Too slow Not suitable for the enterprise No dependency injection No tooling ✔
  • 16. Recipe § OSGi Declarative Services (Compendium Chapter 112) § + RFC 190 Declarative Services Enhancements (OSGi R6) § + RFC 212 Field Injection for Declarative Services (OSGi R6) § OSGi Whiteboard Service § + RFC 189 (OSGi R6) § OSGi Configuration Admin (Compendium Chapter 104) § OSGi Metatype Service (Compendium Chapter 105) § + RFC 208 Metatype Annotations 16
  • 18. Metatype 18 @ObjectClassDefinition( name = "Game Configuration", description = "The configuration for the guessing game.") public @interface Config { @AttributeDefinition(name="Easy", description="Maximum value for easy") int easy_max() default 10;
  • 19. Metatype @Component @Designate( ocd = Config.class ) public class GameControllerImpl implements GameController { 19
  • 20. Component Container Interaction OSGi Service Registry Declarative Services Blueprint 20 iPojo, Dependency Manager, …. Framework API
  • 21. Service Scopes • Singleton • Bundle • Prototype 21
  • 22. Servlets @Component( service = Servlet.class , scope=ServiceScope.PROTOTYPE, property="osgi.http.whiteboard.servlet.pattern=/game") public class GameServlet extends HttpServlet { public void init() {...} public void destroy() {...} 22
  • 23. Dynamics § Lazy instantiation § Reference policy and cardinality § Reconfiguration 23
  • 24. Unary References @FieldReference private GameController controller; @FieldReference( cardinality=ReferenceCardinality.OPTIONAL policy=ReferencePolicy.DYNAMIC) private volatile GameStatistics stats; 24
  • 25. Multiple References @FieldReference( cardinality=ReferenceCardinality.MULTIPLE) private volatile List<Highscore> highscores; 25
  • 26. Multiple References @FieldReference private final Set<Highscore> highscores = new ConcurrentSkipListSet<Highscore>(); 26
  • 27. Reconfiguration private volatile Config configuration; @Activate @Modified protected void activate(final Config config) { this.configuration = config; } 27
  • 28. Web Contexts 28 Servlet Context /play Authentication Servlet B /foo Servlet A /game Servlet C /bar Servlet Filter Servlet Context /fooapp Authentication Servlet X /foo
  • 29. Web Contexts @Component( service = Servlet.class , property={"osgi.http.whiteboard.servlet.pattern=/foo", "osgi.http.whiteboard.context.select=mygame"} public class ServletB extends HttpServlet { @Component( service = Servlet.class , property={"osgi.http.whiteboard.servlet.pattern=/bar", "osgi.http.whiteboard.context.select=game"} public class ServletC extends HttpServlet { 29
  • 30. Try it out today! § HTTP Whiteboard Service § Servlet contexts (grouping, authentication) § Servlets § Filters § Listeners 30
  • 31. Try it out today! § Declarative Services § Easy too use § Pojos § DI with handling dynamics § Tooling § Open Source Solutions § Building large scale enterprise apps 31