Simple REST with Dropwizard

19,513
-1

Published on

A quick introduction on REST and Dropwizard for Bucharest Java User Group 5 - http://bjug.ro/

1 Comment
14 Likes
Statistics
Notes
  • I liked the slides but i request for more knowledge on how to use Mysql database and dropwizard interacting with a mobile client
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total Views
19,513
On Slideshare
0
From Embeds
0
Number of Embeds
7
Actions
Shares
0
Downloads
150
Comments
1
Likes
14
Embeds 0
No embeds

No notes for slide

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, new@example.com}POST /todos?email=x {email: other@x.com}
  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, freemarkerhttp://dropwizard.codahale.com/getting-started/
  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."https://github.com/bucharest-jug/dropwizard-todo
  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: https://github.com/bucharest-jug/dropwizard-todo● All about Dropwizard: http://dropwizard.codahale.com/● API Grove: API management: http://apigrove.net/
  25. 25. Thanks!asavu@apache.org
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×