Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Introduction to Dropwizard: REST & HTTP Made Easy

Introduction to Dropwizard: REST & HTTP Made Easy

Tech talk given @ FullContact on 6/20/2013

6df0f0cdde29041510e787ac49f0e930?s=128

Michael Rose

June 20, 2013
Tweet

Transcript

  1. Introduction to Dropwizard REST & HTTP made easy Thursday, June

    20, 13
  2. Lightweight collection of best-of-breed, stable, mature libraries for building REST

    HTTP services & applications Dropwizard Thursday, June 20, 13
  3. “Dropwizard, as a project, exists exclusively to reduce the transactional

    cost of introducing a new service into a production environment.” Thursday, June 20, 13
  4. Sane logging defaults, ops-friendly config, runtime health checks, default metrics

    Operationally sound Thursday, June 20, 13
  5. 10 minutes of work, great docs, rapid development Low barrier

    to entry Thursday, June 20, 13
  6. Many common use cases covered Batteries included Thursday, June 20,

    13
  7. •dropwizard-auth for OAuth, Basic auth, custom •dropwizard-jdbi for JDBI DAO

    access •dropwizard-hibernate - Hibernate ORM •dropwizard-views - Freemarker, Mustache •dropwizard-guice (Hubspot) - Guice injection •dropwizard-extras (DataSift) - Kafka, HBase goodies Batteries included Thursday, June 20, 13
  8. The Details Thursday, June 20, 13

  9. Core Libraries Thursday, June 20, 13

  10. •Jetty for HTTP servin'. Core Libraries Thursday, June 20, 13

  11. •Jetty for HTTP servin'. •Jersey for REST modelin'. Core Libraries

    Thursday, June 20, 13
  12. •Jetty for HTTP servin'. •Jersey for REST modelin'. •Jackson for

    JSON parsin' and generatin'. Core Libraries Thursday, June 20, 13
  13. •Jetty for HTTP servin'. •Jersey for REST modelin'. •Jackson for

    JSON parsin' and generatin'. •Logback for loggin'. Core Libraries Thursday, June 20, 13
  14. •Jetty for HTTP servin'. •Jersey for REST modelin'. •Jackson for

    JSON parsin' and generatin'. •Logback for loggin'. •Hibernate Validator for validatin'. Core Libraries Thursday, June 20, 13
  15. •Jetty for HTTP servin'. •Jersey for REST modelin'. •Jackson for

    JSON parsin' and generatin'. •Logback for loggin'. •Hibernate Validator for validatin'. •Metrics for figurin' out what your application is doin' in production. Core Libraries Thursday, June 20, 13
  16. •Jetty for HTTP servin'. •Jersey for REST modelin'. •Jackson for

    JSON parsin' and generatin'. •Logback for loggin'. •Hibernate Validator for validatin'. •Metrics for figurin' out what your application is doin' in production. •SnakeYAML for YAML parsin' and configuratin'. Core Libraries Thursday, June 20, 13
  17. •Jetty for HTTP servin'. •Jersey for REST modelin'. •Jackson for

    JSON parsin' and generatin'. •Logback for loggin'. •Hibernate Validator for validatin'. •Metrics for figurin' out what your application is doin' in production. •SnakeYAML for YAML parsin' and configuratin'. •JDBI and Hibernate for databasin'. Core Libraries Thursday, June 20, 13
  18. •Jetty for HTTP servin'. •Jersey for REST modelin'. •Jackson for

    JSON parsin' and generatin'. •Logback for loggin'. •Hibernate Validator for validatin'. •Metrics for figurin' out what your application is doin' in production. •SnakeYAML for YAML parsin' and configuratin'. •JDBI and Hibernate for databasin'. •Liquibase for migratin'. Core Libraries Thursday, June 20, 13
  19. this is usually good Dropwizard is opinionated Thursday, June 20,

    13
  20. Code organization Thursday, June 20, 13

  21. Sane recommendations for layout Code organization Thursday, June 20, 13

  22. Sane recommendations for layout Code organization Thursday, June 20, 13

  23. Sane recommendations for layout Code organization Across 3 maven/gradle subprojects*

    Thursday, June 20, 13
  24. Sane recommendations for layout Code organization Across 3 maven/gradle subprojects*

    project-api Thursday, June 20, 13
  25. Sane recommendations for layout Code organization Across 3 maven/gradle subprojects*

    project-api project-client Thursday, June 20, 13
  26. Sane recommendations for layout Code organization Across 3 maven/gradle subprojects*

    project-api project-client project-service Thursday, June 20, 13
  27. Sane recommendations for layout Code organization Across 3 maven/gradle subprojects*

    project-api project-client project-service api service service service service service service service client Thursday, June 20, 13
  28. Sane recommendations for layout Code organization Across 3 maven/gradle subprojects*

    project-api project-client project-service POJOs api service service service service service service service client Thursday, June 20, 13
  29. Sane recommendations for layout Code organization Across 3 maven/gradle subprojects*

    project-api project-client project-service POJOs Jersey Resources api service service service service service service service client Thursday, June 20, 13
  30. Sane recommendations for layout Code organization Across 3 maven/gradle subprojects*

    project-api project-client project-service POJOs Jersey Resources api service service service service service service service client Your App Thursday, June 20, 13
  31. Sane recommendations for layout Code organization Across 3 maven/gradle subprojects*

    project-api project-client project-service POJOs Jersey Resources api service service service service service service service client Your App DAOs Thursday, June 20, 13
  32. Sane recommendations for layout Code organization Across 3 maven/gradle subprojects*

    project-api project-client project-service POJOs Jersey Resources api service service service service service service service client Your App DAOs Representations go in api so they can be used in the client package too Thursday, June 20, 13
  33. Sane recommendations for layout Code organization Across 3 maven/gradle subprojects*

    project-api project-client project-service POJOs Jersey Resources * - If you’re just doing a quick web service, just throw it all in one project if you even make a client api service service service service service service service client Your App DAOs Representations go in api so they can be used in the client package too Thursday, June 20, 13
  34. Jersey (1.x) Thursday, June 20, 13

  35. @Path specifies the relative path for a resource class or

    method. @GET, @PUT, @POST, @DELETE and @HEAD specify the HTTP request type of a resource. @Produces specifies the response Internet media types (used for content negotiation). @Consumes specifies the accepted request Internet media types. @PathParam binds the method parameter to a path segment. @QueryParam binds the method parameter to the value of an HTTP query parameter. more.. Jersey is the reference implementation of JAX-RS, spec for making RESTful webservices Class & method annotations Thursday, June 20, 13
  36. Example: Result: [] .. automatic JSON serialization GET /v1/resource Thursday,

    June 20, 13
  37. Lets build a service hands on! Thursday, June 20, 13

  38. git clone git@github.com:fullcontact/dropwizard-techtalk.git I’ve prepared a skeleton project It’s Maven

    & Groovy based Aw yeah, who doesn’t love Groovy? Thursday, June 20, 13