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