SlideShare a Scribd company logo
Dropwizard (DW) Guts
=
Jetty
• Webserver and javax.Servlet container
• DW adds InstrumentedHandler
• DW register a Servlet which which wraps
JerseyContainer containing all your
Resources & ResourceMethods
• Wired in AbstractServerFactory
InstrumentedHandler
• Jetty Handler
• Handlers are chained together to process
request, generating a response
• Provides instrumentation around request
types, response code, and inflight status
Jersey Resource & ResourceMethod
Questions?
• What pre & post processing happens before
calling your ResourceMethod?
• How do you define that?
• How are arguments obtained to called your
method?
WebApplicationImpl
Contains a set of resources, each referenced by an absolute URI template
• Maintains a set of tuples <Path, Rule>
• Path matches request, Rule is applied
• Rule has a RequestDispatcher
• Rule has an instance of Resource, or constructs it
(depends on whether resource is added as singleton)
• Rule delegates to RequestDispatcher passing
resource and context
RequestDispatcher
public interface RequestDispatcher {
public void dispatch(Object resource, HttpContext context);
}
RequestDispatcher maybe chained together, “Decorating” functionality
How does DW chain dispatchers?
• Always: OptionalRequestDispatcher (if response == optional.absent -> return 404, else return 200 + body)
• @CacheControl: CacheControlledRequestDispatcher(add caching header)
• Instrumentation
• @Timed: TimedRequestDispatcher (time the rest of dispatch chain)
• @Metered: MeteredRequestDispatcher (meter thruput)
• @ExceptionMetered: ExceptionMeteredRequestDispatcher (meter exceptions)
• Always: *Invoker (extract args from HttpContext, reflectlively call ResourceMethod)
RequestDispatcher
• One root RequestDispatcher per
ResourceMethod
• ResourceMethod created once at initialization
• Every request to a ResourceMethod is
dispatched to the dispatcher, providing an
instance of the resource & HttpContext
TimedRequestDispatcher: @Timed
RequestDispatcher Impls
Metric Registry
• Singleton, per JVM
• All metrics are created and registered here
• Codahale.Metrics
@Timed, @Metered what do I get?
• Registers and captures metrics for your
annotated ResourceMethod
• Metrics collected determined by annotation
• Even without ResourceMethod annotations,
you get JVM and Jetty metrics because of
Dropwizard
@Timed instantaneous view
Metrics over time?
• You need a time series DB (Graphite)
• You need a graphing frontend (Graphite)
• You need to ship your data to the DB, you
have to configure a GraphiteReporter: background
thread periodically sending metrics to graphite
Graphite Sample
Extra: Graphite, Metrics
• Default, Reporter ships all metrics to Graphite
• Metrics are per JVM, Graphite can aggregate
• Custom metrics without annotations
• Graphite has an API, so custom dashboards
What is a Provider?
An interface used by a framework, where
various impls can be plugged in at runtime to
customize your experience
It’s as Jersey as Taylor Ham
Providers
• ResourceMethodDispatchProvider
• InjectableProvider
• InjectableValuesProvider
• MessageBodyReader
• MessageBodyWriter
ResourceMethodDispatchProvider
& Adapter
//Responsibility is creating a RequestDispatcher
public interface ResourceMethodDispatchProvider {
RequestDispatcher create(AbstractResourceMethod abstractResourceMethod);
}
//Responsibility is daisy chaining adapters
public interface ResourceMethodDispatchAdapter {
ResourceMethodDispatchProvider
adapt(ResourceMethodDispatchProvider provider);
}
ResourceMethodDispatchProvider
Default Jersey
ResourceMethodDispatchProviders
ResourceMethodDispatcherFactory, which is a ResourceMethodDispatchProvider
• Set of default ResourceMethodDispatchProviders which are iterated in order, calling create
• Provider can’t create RequestDispatcher, return null
• Continue until non null RequestDispatcher returned: *Invoker
//void return & params
[0] = {com.sun.jersey.server.impl.model.method.dispatch.VoidVoidDispatchProvider@5061}
//void return, params are HttpRequestContext.class, HttpResponseContext.class
[1] = {com.sun.jersey.server.impl.model.method.dispatch.HttpReqResDispatchProvider@5062}
//Consumes mimelist is multipart form-data
[2] = {com.sun.jersey.server.impl.model.method.dispatch.MultipartFormDispatchProvider@5063}
//Non GET, delegates to AbstractResourceMethodDispatchProvider
[3] = {com.sun.jersey.server.impl.model.method.dispatch.FormDispatchProvider@5064}
//Delegates to AbstractResourceMethodDispatchProvider
[4] = {com.sun.jersey.server.impl.model.method.dispatch.EntityParamDispatchProvider@5065}
AbstractResourceMethodDispatchProvider
Impls are required to create a InjectableValuesProvider from the
ResourceMethod which will be used to generate the argument list from the
HttpContext
Args are built by the InjectableValuesProvider by using it’s
List<AbstractHttpContextInjectable> to transform to to an array of
objects, by extracting a Typed object from the HttpContext
The a List<AbstractHttpContextInjectable> is generated by examining
each Parameter of the ResourceMethod, for each parameter the list of
InjectableProvider(s) in InjectableProviderFactory are examined
to see if the InjectableProvider can produce an Injectable. The first one
able to produce an Injectable is used
MessageBodyReader/Writer
• JacksonMessageBodyProvider from Jackson
• Enables using Jackson to parse request entities into
objects and generate response entities from objects
• Supports Jackson & JAXB annotations in that order
• Wired in AbstractServerFactory
Ad

Recommended

PDF
Spring Data JPA
Cheng Ta Yeh
 
PDF
Apply Bold, Italic and Underline to Selected Text in a RichtextBox using Visu...
Daniel DotNet
 
PDF
Android Jetpack Compose - Turkey 2021
Nelson Glauber Leal
 
PDF
An introduction to React.js
Emanuele DelBono
 
PDF
Overview Of JDBC
Mindfire Solutions
 
PDF
Webinar: Introducción a Angular
Arsys
 
PPTX
Sql(structured query language)
Ishucs
 
PDF
Spring Data JPA from 0-100 in 60 minutes
VMware Tanzu
 
PPTX
JSON: The Basics
Jeff Fox
 
PPTX
8. sql
khoahuy82
 
PPTX
Introduction to React JS for beginners | Namespace IT
namespaceit
 
PPTX
Spring boot
Pradeep Shanmugam
 
PPTX
React hooks
Assaf Gannon
 
PDF
Dropwizard
Scott Leberknight
 
PDF
Introdução ao JavaFX
Nécio de Lima Veras
 
DOCX
Java codes
Hussain Sherwani
 
PDF
CommitConf 2023 - Spring Framework 6 y Spring Boot 3
Iván López Martín
 
PDF
8 introduction to_java_script
Vijay Kalyan
 
PDF
Spring boot introduction
Rasheed Waraich
 
PDF
Spring boot jpa
Hamid Ghorbani
 
PDF
Android 3.1 - Portland Code Camp 2011
sullis
 
PPTX
Java Microservices with DropWizard
Bruno Buger
 
PDF
Dropwizard at Yammer
Jamie Furness
 
PDF
Fault tolerant microservices - LJC Skills Matter 4thNov2014
Christopher Batey
 
PPTX
Microservices/dropwizard
FKM Naimul Huda, PMP
 
PDF
Dropwizard and Groovy
tomaslin
 
PPTX
Dropwizard Introduction
Anthony Chen
 

More Related Content

What's hot (14)

PPTX
Sql(structured query language)
Ishucs
 
PDF
Spring Data JPA from 0-100 in 60 minutes
VMware Tanzu
 
PPTX
JSON: The Basics
Jeff Fox
 
PPTX
8. sql
khoahuy82
 
PPTX
Introduction to React JS for beginners | Namespace IT
namespaceit
 
PPTX
Spring boot
Pradeep Shanmugam
 
PPTX
React hooks
Assaf Gannon
 
PDF
Dropwizard
Scott Leberknight
 
PDF
Introdução ao JavaFX
Nécio de Lima Veras
 
DOCX
Java codes
Hussain Sherwani
 
PDF
CommitConf 2023 - Spring Framework 6 y Spring Boot 3
Iván López Martín
 
PDF
8 introduction to_java_script
Vijay Kalyan
 
PDF
Spring boot introduction
Rasheed Waraich
 
PDF
Spring boot jpa
Hamid Ghorbani
 
Sql(structured query language)
Ishucs
 
Spring Data JPA from 0-100 in 60 minutes
VMware Tanzu
 
JSON: The Basics
Jeff Fox
 
8. sql
khoahuy82
 
Introduction to React JS for beginners | Namespace IT
namespaceit
 
Spring boot
Pradeep Shanmugam
 
React hooks
Assaf Gannon
 
Dropwizard
Scott Leberknight
 
Introdução ao JavaFX
Nécio de Lima Veras
 
Java codes
Hussain Sherwani
 
CommitConf 2023 - Spring Framework 6 y Spring Boot 3
Iván López Martín
 
8 introduction to_java_script
Vijay Kalyan
 
Spring boot introduction
Rasheed Waraich
 
Spring boot jpa
Hamid Ghorbani
 

Viewers also liked (15)

PDF
Android 3.1 - Portland Code Camp 2011
sullis
 
PPTX
Java Microservices with DropWizard
Bruno Buger
 
PDF
Dropwizard at Yammer
Jamie Furness
 
PDF
Fault tolerant microservices - LJC Skills Matter 4thNov2014
Christopher Batey
 
PPTX
Microservices/dropwizard
FKM Naimul Huda, PMP
 
PDF
Dropwizard and Groovy
tomaslin
 
PPTX
Dropwizard Introduction
Anthony Chen
 
PDF
Metrics by coda hale : to know your app’ health
Izzet Mustafaiev
 
PDF
Production Ready Web Services with Dropwizard
sullis
 
PDF
Microservices Architecture
Izzet Mustafaiev
 
PDF
Simple REST-APIs with Dropwizard and Swagger
LeanIX GmbH
 
PDF
Java application monitoring with Dropwizard Metrics and graphite
Roberto Franchini
 
PDF
DockerCon SF 2015: Enabling Microservices @Orbitz
Docker, Inc.
 
PDF
Patterns of resilience
Uwe Friedrichsen
 
Android 3.1 - Portland Code Camp 2011
sullis
 
Java Microservices with DropWizard
Bruno Buger
 
Dropwizard at Yammer
Jamie Furness
 
Fault tolerant microservices - LJC Skills Matter 4thNov2014
Christopher Batey
 
Microservices/dropwizard
FKM Naimul Huda, PMP
 
Dropwizard and Groovy
tomaslin
 
Dropwizard Introduction
Anthony Chen
 
Metrics by coda hale : to know your app’ health
Izzet Mustafaiev
 
Production Ready Web Services with Dropwizard
sullis
 
Microservices Architecture
Izzet Mustafaiev
 
Simple REST-APIs with Dropwizard and Swagger
LeanIX GmbH
 
Java application monitoring with Dropwizard Metrics and graphite
Roberto Franchini
 
DockerCon SF 2015: Enabling Microservices @Orbitz
Docker, Inc.
 
Patterns of resilience
Uwe Friedrichsen
 
Ad

Similar to Dropwizard Internals (20)

PPTX
J2EE : Java servlet and its types, environment
joearunraja2
 
PPT
Web Technologies -- Servlets 4 unit slides
Sasidhar Kothuru
 
PPTX
Java Servlets
Emprovise
 
PPTX
SCWCD : The servlet model : CHAP : 2
Ben Abdallah Helmi
 
PPT
Servlets
Sasidhar Kothuru
 
PPTX
SCWCD : The servlet model CHAP : 2
Ben Abdallah Helmi
 
PDF
Dynamic content generation
Eleonora Ciceri
 
PPTX
JAVA SERVLETS acts as a middle layer between a request coming from a web brow...
ssuser4f7d71
 
PPTX
21CS642 Module 4_1 Servlets PPT.pptx VI SEM CSE Students
VENKATESHBHAT25
 
PPTX
Rails Request & Middlewares
Santosh Wadghule
 
PPT
Lecture 2
Ahmed Madkor
 
PPT
JAVA Servlets
deepak kumar
 
PDF
Java Servlet Programming under Ubuntu Linux by Tushar B Kute
Tushar B Kute
 
PPT
Servlet.ppt
MouDhara1
 
PPT
Servlet.ppt
kstalin2
 
PPT
Servlet1.ppt
KhushalChoudhary14
 
PPTX
SERVIET
sathish sak
 
PPT
Servlet (1) also contains code to create it.ppt
juhishrivastava25
 
PDF
Managing user's data with Spring Session
David Gómez García
 
J2EE : Java servlet and its types, environment
joearunraja2
 
Web Technologies -- Servlets 4 unit slides
Sasidhar Kothuru
 
Java Servlets
Emprovise
 
SCWCD : The servlet model : CHAP : 2
Ben Abdallah Helmi
 
SCWCD : The servlet model CHAP : 2
Ben Abdallah Helmi
 
Dynamic content generation
Eleonora Ciceri
 
JAVA SERVLETS acts as a middle layer between a request coming from a web brow...
ssuser4f7d71
 
21CS642 Module 4_1 Servlets PPT.pptx VI SEM CSE Students
VENKATESHBHAT25
 
Rails Request & Middlewares
Santosh Wadghule
 
Lecture 2
Ahmed Madkor
 
JAVA Servlets
deepak kumar
 
Java Servlet Programming under Ubuntu Linux by Tushar B Kute
Tushar B Kute
 
Servlet.ppt
MouDhara1
 
Servlet.ppt
kstalin2
 
Servlet1.ppt
KhushalChoudhary14
 
SERVIET
sathish sak
 
Servlet (1) also contains code to create it.ppt
juhishrivastava25
 
Managing user's data with Spring Session
David Gómez García
 
Ad

Recently uploaded (20)

PDF
Why Every Growing Business Needs a Staff Augmentation Company IN USA.pdf
mary rojas
 
PPTX
Threat Modeling a Batch Job Framework - Teri Radichel - AWS re:Inforce 2025
2nd Sight Lab
 
PDF
A Guide to Telemedicine Software Development.pdf
Olivero Bozzelli
 
PPTX
Simplify Insurance Regulations with Compliance Management Software
Insurance Tech Services
 
DOCX
Best AI-Powered Wearable Tech for Remote Health Monitoring in 2025
SEOLIFT - SEO Company London
 
PDF
Y - Recursion The Hard Way GopherCon EU 2025
Eleanor McHugh
 
PDF
From Data Preparation to Inference: How Alluxio Speeds Up AI
Alluxio, Inc.
 
PPTX
arctitecture application system design os dsa
za241967
 
PDF
University Campus Navigation for All - Peak of Data & AI
Safe Software
 
PPT
Complete Guideliness to Build an Effective Maintenance Plan.ppt
QualityzeInc1
 
PDF
How Automation in Claims Handling Streamlined Operations
Insurance Tech Services
 
PPTX
Foundations of Marketo Engage - Programs, Campaigns & Beyond - June 2025
BradBedford3
 
PDF
Sysinfo OST to PST Converter Infographic
SysInfo Tools
 
PDF
Best Practice for LLM Serving in the Cloud
Alluxio, Inc.
 
PDF
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
arabelatso
 
PPTX
declaration of Variables and constants.pptx
meemee7378
 
PPTX
Top Time Tracking Solutions for Accountants
oliviareed320
 
PDF
Introduction to Agile Frameworks for Product Managers.pdf
Ali Vahed
 
PDF
Building Geospatial Data Warehouse for GIS by GIS with FME
Safe Software
 
PDF
On-Device AI: Is It Time to Go All-In, or Do We Still Need the Cloud?
Hassan Abid
 
Why Every Growing Business Needs a Staff Augmentation Company IN USA.pdf
mary rojas
 
Threat Modeling a Batch Job Framework - Teri Radichel - AWS re:Inforce 2025
2nd Sight Lab
 
A Guide to Telemedicine Software Development.pdf
Olivero Bozzelli
 
Simplify Insurance Regulations with Compliance Management Software
Insurance Tech Services
 
Best AI-Powered Wearable Tech for Remote Health Monitoring in 2025
SEOLIFT - SEO Company London
 
Y - Recursion The Hard Way GopherCon EU 2025
Eleanor McHugh
 
From Data Preparation to Inference: How Alluxio Speeds Up AI
Alluxio, Inc.
 
arctitecture application system design os dsa
za241967
 
University Campus Navigation for All - Peak of Data & AI
Safe Software
 
Complete Guideliness to Build an Effective Maintenance Plan.ppt
QualityzeInc1
 
How Automation in Claims Handling Streamlined Operations
Insurance Tech Services
 
Foundations of Marketo Engage - Programs, Campaigns & Beyond - June 2025
BradBedford3
 
Sysinfo OST to PST Converter Infographic
SysInfo Tools
 
Best Practice for LLM Serving in the Cloud
Alluxio, Inc.
 
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
arabelatso
 
declaration of Variables and constants.pptx
meemee7378
 
Top Time Tracking Solutions for Accountants
oliviareed320
 
Introduction to Agile Frameworks for Product Managers.pdf
Ali Vahed
 
Building Geospatial Data Warehouse for GIS by GIS with FME
Safe Software
 
On-Device AI: Is It Time to Go All-In, or Do We Still Need the Cloud?
Hassan Abid
 

Dropwizard Internals

  • 2. Jetty • Webserver and javax.Servlet container • DW adds InstrumentedHandler • DW register a Servlet which which wraps JerseyContainer containing all your Resources & ResourceMethods • Wired in AbstractServerFactory
  • 3. InstrumentedHandler • Jetty Handler • Handlers are chained together to process request, generating a response • Provides instrumentation around request types, response code, and inflight status
  • 4. Jersey Resource & ResourceMethod
  • 5. Questions? • What pre & post processing happens before calling your ResourceMethod? • How do you define that? • How are arguments obtained to called your method?
  • 6. WebApplicationImpl Contains a set of resources, each referenced by an absolute URI template • Maintains a set of tuples <Path, Rule> • Path matches request, Rule is applied • Rule has a RequestDispatcher • Rule has an instance of Resource, or constructs it (depends on whether resource is added as singleton) • Rule delegates to RequestDispatcher passing resource and context
  • 7. RequestDispatcher public interface RequestDispatcher { public void dispatch(Object resource, HttpContext context); } RequestDispatcher maybe chained together, “Decorating” functionality
  • 8. How does DW chain dispatchers? • Always: OptionalRequestDispatcher (if response == optional.absent -> return 404, else return 200 + body) • @CacheControl: CacheControlledRequestDispatcher(add caching header) • Instrumentation • @Timed: TimedRequestDispatcher (time the rest of dispatch chain) • @Metered: MeteredRequestDispatcher (meter thruput) • @ExceptionMetered: ExceptionMeteredRequestDispatcher (meter exceptions) • Always: *Invoker (extract args from HttpContext, reflectlively call ResourceMethod)
  • 9. RequestDispatcher • One root RequestDispatcher per ResourceMethod • ResourceMethod created once at initialization • Every request to a ResourceMethod is dispatched to the dispatcher, providing an instance of the resource & HttpContext
  • 12. Metric Registry • Singleton, per JVM • All metrics are created and registered here • Codahale.Metrics
  • 13. @Timed, @Metered what do I get? • Registers and captures metrics for your annotated ResourceMethod • Metrics collected determined by annotation • Even without ResourceMethod annotations, you get JVM and Jetty metrics because of Dropwizard
  • 15. Metrics over time? • You need a time series DB (Graphite) • You need a graphing frontend (Graphite) • You need to ship your data to the DB, you have to configure a GraphiteReporter: background thread periodically sending metrics to graphite
  • 17. Extra: Graphite, Metrics • Default, Reporter ships all metrics to Graphite • Metrics are per JVM, Graphite can aggregate • Custom metrics without annotations • Graphite has an API, so custom dashboards
  • 18. What is a Provider? An interface used by a framework, where various impls can be plugged in at runtime to customize your experience It’s as Jersey as Taylor Ham
  • 19. Providers • ResourceMethodDispatchProvider • InjectableProvider • InjectableValuesProvider • MessageBodyReader • MessageBodyWriter
  • 20. ResourceMethodDispatchProvider & Adapter //Responsibility is creating a RequestDispatcher public interface ResourceMethodDispatchProvider { RequestDispatcher create(AbstractResourceMethod abstractResourceMethod); } //Responsibility is daisy chaining adapters public interface ResourceMethodDispatchAdapter { ResourceMethodDispatchProvider adapt(ResourceMethodDispatchProvider provider); }
  • 22. Default Jersey ResourceMethodDispatchProviders ResourceMethodDispatcherFactory, which is a ResourceMethodDispatchProvider • Set of default ResourceMethodDispatchProviders which are iterated in order, calling create • Provider can’t create RequestDispatcher, return null • Continue until non null RequestDispatcher returned: *Invoker //void return & params [0] = {com.sun.jersey.server.impl.model.method.dispatch.VoidVoidDispatchProvider@5061} //void return, params are HttpRequestContext.class, HttpResponseContext.class [1] = {com.sun.jersey.server.impl.model.method.dispatch.HttpReqResDispatchProvider@5062} //Consumes mimelist is multipart form-data [2] = {com.sun.jersey.server.impl.model.method.dispatch.MultipartFormDispatchProvider@5063} //Non GET, delegates to AbstractResourceMethodDispatchProvider [3] = {com.sun.jersey.server.impl.model.method.dispatch.FormDispatchProvider@5064} //Delegates to AbstractResourceMethodDispatchProvider [4] = {com.sun.jersey.server.impl.model.method.dispatch.EntityParamDispatchProvider@5065}
  • 23. AbstractResourceMethodDispatchProvider Impls are required to create a InjectableValuesProvider from the ResourceMethod which will be used to generate the argument list from the HttpContext Args are built by the InjectableValuesProvider by using it’s List<AbstractHttpContextInjectable> to transform to to an array of objects, by extracting a Typed object from the HttpContext The a List<AbstractHttpContextInjectable> is generated by examining each Parameter of the ResourceMethod, for each parameter the list of InjectableProvider(s) in InjectableProviderFactory are examined to see if the InjectableProvider can produce an Injectable. The first one able to produce an Injectable is used
  • 24. MessageBodyReader/Writer • JacksonMessageBodyProvider from Jackson • Enables using Jackson to parse request entities into objects and generate response entities from objects • Supports Jackson & JAXB annotations in that order • Wired in AbstractServerFactory