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

More Related Content

Viewers also liked (13)

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

Similar to Dropwizard Internals (20)

PDF
RESTEasy
Massimiliano Dessì
 
PDF
May 2010 - RestEasy
JBug Italy
 
PDF
RESTful Web Services with Jersey
Scott Leberknight
 
PPTX
JAX-RS 2.0 and OData
Anil Allewar
 
PPT
Using Java to implement RESTful Web Services: JAX-RS
Katrien Verbert
 
PPTX
6 Months Industrial Training in Spring Framework
Arcadian Learning
 
PDF
Spring Boot
Shubham Aggarwal
 
ODP
JUDCON India 2014 Java EE 7 talk
Vijay Nair
 
PPTX
JAX-RS. Developing RESTful APIs with Java
Jerry Kurian
 
PPTX
Overview of RESTful web services
nbuddharaju
 
PDF
Building Next-Gen Web Applications with the Spring 3 Web Stack
Jeremy Grelle
 
PPTX
Spring Web Presentation 123143242341234234
horiadobrin
 
KEY
JAX-RS 2.0 New Features
Jan Algermissen
 
PDF
Eclipse Day India 2015 - Rest with Java (jax rs) and jersey
Eclipse Day India
 
PDF
Rest with java (jax rs) and jersey and swagger
Kumaraswamy M
 
PDF
Spring 4 Web App
Rossen Stoyanchev
 
PDF
Ratpack Web Framework
Daniel Woods
 
PDF
Rest web service
Hamid Ghorbani
 
PDF
Lo nuevo en Spring 3.0
David Motta Baldarrago
 
PDF
RESTful Web services using JAX-RS
Arun Gupta
 
May 2010 - RestEasy
JBug Italy
 
RESTful Web Services with Jersey
Scott Leberknight
 
JAX-RS 2.0 and OData
Anil Allewar
 
Using Java to implement RESTful Web Services: JAX-RS
Katrien Verbert
 
6 Months Industrial Training in Spring Framework
Arcadian Learning
 
Spring Boot
Shubham Aggarwal
 
JUDCON India 2014 Java EE 7 talk
Vijay Nair
 
JAX-RS. Developing RESTful APIs with Java
Jerry Kurian
 
Overview of RESTful web services
nbuddharaju
 
Building Next-Gen Web Applications with the Spring 3 Web Stack
Jeremy Grelle
 
Spring Web Presentation 123143242341234234
horiadobrin
 
JAX-RS 2.0 New Features
Jan Algermissen
 
Eclipse Day India 2015 - Rest with Java (jax rs) and jersey
Eclipse Day India
 
Rest with java (jax rs) and jersey and swagger
Kumaraswamy M
 
Spring 4 Web App
Rossen Stoyanchev
 
Ratpack Web Framework
Daniel Woods
 
Rest web service
Hamid Ghorbani
 
Lo nuevo en Spring 3.0
David Motta Baldarrago
 
RESTful Web services using JAX-RS
Arun Gupta
 
Ad

Recently uploaded (20)

PPTX
Tally software_Introduction_Presentation
AditiBansal54083
 
PPTX
Agentic Automation Journey Session 1/5: Context Grounding and Autopilot for E...
klpathrudu
 
PDF
IDM Crack with Internet Download Manager 6.42 Build 43 with Patch Latest 2025
bashirkhan333g
 
PDF
Download Canva Pro 2025 PC Crack Full Latest Version
bashirkhan333g
 
PDF
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
PPTX
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
PPTX
Home Care Tools: Benefits, features and more
Third Rock Techkno
 
PDF
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 
PDF
How to Hire AI Developers_ Step-by-Step Guide in 2025.pdf
DianApps Technologies
 
PDF
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
PDF
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
PPTX
Change Common Properties in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
PPTX
AEM User Group: India Chapter Kickoff Meeting
jennaf3
 
PDF
Build It, Buy It, or Already Got It? Make Smarter Martech Decisions
bbedford2
 
PDF
The 5 Reasons for IT Maintenance - Arna Softech
Arna Softech
 
PPTX
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
PDF
Automate Cybersecurity Tasks with Python
VICTOR MAESTRE RAMIREZ
 
PPTX
Homogeneity of Variance Test Options IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Tally software_Introduction_Presentation
AditiBansal54083
 
Agentic Automation Journey Session 1/5: Context Grounding and Autopilot for E...
klpathrudu
 
IDM Crack with Internet Download Manager 6.42 Build 43 with Patch Latest 2025
bashirkhan333g
 
Download Canva Pro 2025 PC Crack Full Latest Version
bashirkhan333g
 
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
Home Care Tools: Benefits, features and more
Third Rock Techkno
 
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 
How to Hire AI Developers_ Step-by-Step Guide in 2025.pdf
DianApps Technologies
 
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
Change Common Properties in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
AEM User Group: India Chapter Kickoff Meeting
jennaf3
 
Build It, Buy It, or Already Got It? Make Smarter Martech Decisions
bbedford2
 
The 5 Reasons for IT Maintenance - Arna Softech
Arna Softech
 
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
Automate Cybersecurity Tasks with Python
VICTOR MAESTRE RAMIREZ
 
Homogeneity of Variance Test Options IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Ad

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