Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Simple REST with Dropwizard


Published on

A quick introduction on REST and Dropwizard for Bucharest Java User Group 5 -

  • I liked the slides but i request for more knowledge on how to use Mysql database and dropwizard interacting with a mobile client
    Are you sure you want to  Yes  No
    Your message goes here

Simple REST with Dropwizard

  1. 1. Simple REST with DropwizardIntro, Structure, Resources, Deployment Bucharest JUG #5 @ Cegeka
  2. 2. Andrei SavuFounder @ Axemblr.comApache Whirr PMC memberjclouds committerConnect with me on LinkedIn
  3. 3. DisclaimerHighly Technical, Opinionated Talk
  4. 4. REST(Representation State Transfer)Browser Analogy: Fetch representation of thecurrent state of a resource (page)Makes extensive use of HTTP semantics
  5. 5. Resource & RepresentationResource = the real thingRepresentation = server responses"A request interacts with a resource andreceives a representation."
  6. 6. REST VerbsMatch HTTP semantics:● GET : read resources, safe, cache friendly● POST : update resources, create● PUT : replace entire resource, atomic● DELETE : delete entire resource, atomic● HEAD● PATCH
  7. 7. REST Batch OperationsA request can act on a single resource or aclass of resources.E.g.POST /todos/1 {email,}POST /todos?email=x {email:}
  8. 8. REST TransportHTTPWith representations as JSON or XMLNegotiation with Accept & Content-TypeheadersSupports caching, If-Modified-Since queries
  9. 9. Architectures #1 Web UI Database API
  10. 10. Architectures #2 Web UI API Database Mobile
  11. 11. Architectures #3 Web UI Database Internal API Platform Queues APIs Mobile Other
  12. 12. DropwizardThanks Yammer (Coda Hale) for making itopen source!Framework for JVM-based backend services"Dropwizard has out-of-the-box support for sophisticated configuration,application metrics, logging, operational tools, and much more, allowing youand your team to ship a production-quality HTTP+JSON web service in theshortest time possible."
  13. 13. Components● Jetty for HTTP● Jersey for REST● Jackson for JSON● Metrics for metrics● And: guava, logback, hibernate validator, jersey client libraries, jdbi, freemarker
  14. 14. Demo ApplicationStructure, Configuration, Deployment
  15. 15. Specification"A simple todo list sample application implemented usingDropwizard as the core framework with a simple UI thatconsumes the REST API based on twitter bootstrap,backbone.js, jquery and jasmine."
  16. 16. REST EndpointsGET /todos | GET /todos/{id}POST /todosPUT /todos/{id}DELETE /todos | DELETE /todos/{id}
  17. 17. Resources: Todo List● id : assigned by server on creation (Read Only)● created : assigned on creation● email: owner email address● items: list of items
  18. 18. Resources: Todo Item● title: a text description of what need to be done● created: date time assigned on creation● finished: date time assigned when the item was finished
  19. 19. To the IDE!Structure, Configuration, Testing
  20. 20. Production ConfigurationDedicated repository with restricted access.Cool tool: etckeeper (debian)
  21. 21. Deployment: Start SimpleRun tests on the local machineFabric / CapistranoSupervisor / UpstartMonitGanglia / Nagios / Cloudwatch / SNS
  22. 22. Deployment: AutomateContinuous IntegrationPuppet / Chef1-step deployment from a specific branchAbility to rebuild from a vanilla OS installLeverage cloud infrastructure for Dev & QA
  23. 23. Deployment: ContinuousHigh quality test suite (unit + live + smoke)Continuous Deployment PipelineAll new code is deployed to multipleenvironments and production.OpenAgile Timisoara anyone?
  24. 24. Resources● Demo code:● All about Dropwizard:● API Grove: API management:
  25. 25. Thanks!