• Like
  • Save
Hydras And Hypermedia
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

Hydras And Hypermedia

  • 1,533 views
Published

Do you know what your enterprise apps get up to in their time off? Fighting fantasy, pick-your-path, hypermedia-driven, RESTful Web application adventures--of course. …

Do you know what your enterprise apps get up to in their time off? Fighting fantasy, pick-your-path, hypermedia-driven, RESTful Web application adventures--of course.

In this dungeon delve I'll show how we can use hypermedia-driven Web applications to model rich workflows. We'll tackle the many-headed Hydra of HATEOAS, the “Hypermedia as the Engine of Application State” monster; level up through the Web services maturity heuristic; and meet the dwarves with grudges. As we explore the ruins of the enterprise BPM landscape, we'll learn how to model business processes as domain application protocols, implement them in terms of resource lifecycles, and advertise them using HTTP idioms, media types and link relation values.

ABOUT IAN ROBINSON
Ian is a principal consultant with ThoughtWorks, where he helps clients create sustainable service-oriented development capabilities that align business and IT from inception through to operation.

Published in Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
  • watch this talk at

    http://skillsmatter.com/podcast/ajax-ria/hydra-and-hypermedia/zx-489
    Are you sure you want to
    Your message goes here
No Downloads

Views

Total Views
1,533
On SlideShare
0
From Embeds
0
Number of Embeds
2

Actions

Shares
Downloads
0
Comments
1
Likes
2

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Hydras  and  Hypermedia   Ian  Robinson   http://ianSrobinson.com   @ianSrobinson   ianSrobinson@gmail.com  
  • 2. Your  friendly  neighbourhood  enterprise  
  • 3. Meet  the  apps   ERP   DMS  
  • 4. And  their  alter  egos…   Wired  Erp   Dungeon  Master  
  • 5. Fighting  Fantasy  
  • 6. Pick  your  path  to  adventure  
  • 7. The  goal…   Find   and   Defeat   E0920ba0'df0e-42a1-b304-a312c834fd62     tyrannical  Lich-­‐Uuid   the  
  • 8. The  plan…   until  goal  achieved    while  healthy      fight    |  flee    |  without  retracing  steps      |  north      |  east      |  west      |  south    |  investigate    |  retrace  steps  
  • 9. Once  upon  a  time…   POST /quests Host: dms Content-Type: application/prs.dms+xml Content-Length: ... <difficulty>intermediate</difficulty> HTTP/1.1 201 Created Content-Type: application/prs.dms+xml Location: http://dms/quests/1/locations/1 Content-Length: ... <location> <title>Entrance</title> <summary> Your adventure begins as you descend a rope into a rubble-strewn hall. The air is cold and dank. </summary> <dimensions> <north-south>20</north-south> <east-west>20</east-west> </dimensions> <link rel="http://dms/north" type="application/prs.dms+xml" href="/quests/1/locations/2"/> <link rel="http://dms/east" type="application/prs.dms+xml" href="/quests/1/locations/3"/> <link rel="http://dms/west" type="application/prs.dms+xml" href="/quests/1/locations/4"/> </location>
  • 10. Heading  north…   GET /quests/1/locations/2 HTTP/1.1 Host: dms HTTP/1.1 303 See Other Content-Type: application/prs.dms+xml Location: http://dms/quests/1/encounters/1 Content-Length: ... <link rel="related" type="application/prs.dms+xml" href="/quests/1/encounters/1"/>
  • 11. When  frameworks  go  bad…   GET /quests/1/encounters/1 HTTP/1.1 Host: dms HTTP/1.1 200 OK Content-Type: application/prs.dms+xml Content-Length: ... <encounter> <title>Skeleton!</title> <summary> From out of the shadows lurches a skeleton brandishing a scimitar. </summary> <model> <instance rel="http://dms/attack"> <intention> <attack> <weapon/> <strategy/> </attack> </intention> </instance> <submission resource="/quests/1/encounters/1/fight" method="POST" mediatype="application/prs.dms+xml"/> </model> <model> <instance rel="http://dms/flee"> <intention> <flee/> </intention> </instance> <submission resource="/quests/1/encounters/1/flight" method="POST" mediatype="application/prs.dms+xml"/> </model> </encounter>
  • 12. Hacker…   POST /quests/1/encounters/1/fight HTTP/1.1 Host: dms Content-Type: application/prs.dms+xml Content-Length: ... <intention> <attack> <weapon>sword</weapon> <strategy>slash</strategy> </attack> </intention> HTTP/1.1 201 Created Content-Type: application/prs.dms+xml Location: http://dms/quests/1/encounters/1/outcomes/1 Content-Length: ... <outcome> <title>Success</title> <summary> The skeleton shatters and its scimitar clatters to the ground. Searching the fragments, you find a silver key. </summary> <items> <link type="application/prd.dms+xml" href="/quests/1/objects/1">silver key</link> </items> <link rel="next" type="application/prs.dms+xml" href="/quests/1/locations/2"/> </outcome>
  • 13. Stone  door   GET /quests/1/locations/2 HTTP/1.1 Host: dms HTTP/1.1 200 OK Content-Type: application/prs.dms+xml ETag: "FEC6956217C1" Content-Length: ... <location> <title>Stone door</title> <summary> The hall narrows, and you follow a low passage to a stone door with a deeply recessed keyhole. </summary> <dimensions> <north-south>15</north-south> <east-west>5</east-west> </dimensions> <link rel="http://dms/south" type="application/prs.dms+xml" href="/quests/1/locations/1"/> <model> <instance rel="http://dms/action"> <intention> <unlock> <key/> </unlock> </intention> </instance> <submission resource="/quests/1/locations/2" method="POST" mediatype="application/prs.dms+xml"/> </model> </location>
  • 14. But  we’ve  got  a  key…   POST /quests/1/locations/2 HTTP/1.1 Host: dms If-Match: "FEC6956217C1" Content-Type: application/prs.dms+xml Content-Length: ... <intention> <unlock> <key>http://dms/quests/1/objects/1</key> </unlock> </intention> HTTP/1.1 412 Precondition Failed
  • 15. What’s  going  on?   GET /quests/1/locations/2 HTTP/1.1 Host: dms If-None-Match: "FEC6956217C1" HTTP/1.1 200 OK Content-Type: application/prs.dms+xml ETag: "6809E4D87D43" Content-Length: ... <location> <title>Stone door</title> <summary> You're standing in front of a stone door with a deeply recessed keyhole. Electricity crackles around the keyhole. </summary> <dimensions> <north-south>15</north-south> <east-west>5</east-west> </dimensions> <link rel="http://dms/south" type="application/prs.dms+xml" href="/quests/1/locations/1"/> <model> <instance rel="http://dms/action"> <intention> <unlock> <key/> </unlock> </intention> </instance> <submission resource="/quests/1/locations/2" method="POST" mediatype="application/prs.dms+xml"/> </model> </location>
  • 16. Wait…   GET /quests/1/locations/2 HTTP/1.1 Host: dms If-None-Match: "6809E4D87D43" HTTP/1.1 304 Not Modified
  • 17. Wait…   GET /quests/1/locations/2 HTTP/1.1 Host: dms If-None-Match: "6809E4D87D43" HTTP/1.1 200 OK Content-Type: application/prs.dms+xml ETag: "871CDA1C9935" Content-Length: ... <location> <title>Stone door</title> <summary> You're standing in front of a stone door with a deeply recessed keyhole. </summary> <dimensions> <north-south>15</north-south> <east-west>5</east-west> </dimensions> <link rel="http://dms/south" type="application/prs.dms+xml" href="/quests/1/locations/1"/> <model> <instance rel="http://dms/action"> <intention> <unlock> <key/> </unlock> </intention> </instance> <submission resource="/quests/1/locations/2" method="POST" mediatype="application/prs.dms+xml"/> </model> </location>
  • 18. Now!   POST /quests/1/locations/2 HTTP/1.1 Host: dms If-Match: "871CDA1C9935" Content-Type: application/prs.dms+xml Content-Length: ... <intention> <unlock> <key>http://dms/quests/1/objects/1</key> </unlock> </intention> HTTP/1.1 201 Created Content-Type: application/prs.dms+xml Location: http://dms/quests/1/locations/2/outcomes/1 Content-Length: ... <outcome> <title>Success</title> <summary> The key turns in the lock and the door grinds open. Beyond, a flight of steep steps lead down into the darkness. A blast of warm, fetid air issues from below, followed by an inhuman shriek. </summary> <link rel="related" type="application/prs.dms+xml" href="/quests/1/locations/2"/> <link rel="http://dms/north" type="application/prs.dms+xml" href="/quests/1/locations/5"/> <link rel="http://dms/south" type="application/prs.dms+xml" href="/quests/1/locations/1"/> </outcome>
  • 19. Leonard  Richardson's  Web  service  maturity  heuristic   What?   Why?   How?   Spreads  complexity   URIs   Divide  and  conquer   around   Refactor   (Do  the  same  things   Reduces  complexity   HTTP   in  the  same  way)   Describe  special   Makes  complexity   Hypermedia   behaviour  in  a   learnable   standard  way   http://www.crummy.com/writing/  
  • 20. HATEOAS  –  the  riddle  of  the  Sphinx   Hypermedia   as   the   Engine   of   Application   State  
  • 21. Some  definitions…   Application  protocol   Application  state   Photo  taken  from  Twissie’s  Flickr  stream  under  the  Creative  Commons  licence  
  • 22. Application  protocol  state  machine   GET POST exploring confronting entrance skeleton POST GET investigating triumphant door POST standing at top of steps
  • 23. Reality  intermission   request quote quote requested place order goods ordered cancel order fulfill order order order completed cancelled
  • 24. Hypermedia  systems  transform  application  state   <encounter> <title>Skeleton!</title> <summary> From out of the shadows lurches a skeleton brandishing a scimitar. </summary> <model> <instance rel="http://dms/attack"> <intention> <attack> <outcome> <weapon/> <title>Success</title> <strategy/> <summary> </attack> The skeleton shatters and its scimitar clatters to the ground. </intention> Searching the fragments, you find a silver key. </instance> </summary> <submission resource="/quests/1/encounters/1" <items> method="POST" mediatype="application/prs.dms+xml"/> <link type="application/prd.dms+xml" </model> href="/quests/1/objects/1">silver key</a:link> <model> </items> <instance rel="http://dms/flee"> <link rel="next" type="application/prs.dms+xml" <intention> href="/quests/1/locations/2"/> <flee/> </outcome></intention> </instance> <submission resource="/quests/1/encounters/1" method="POST" mediatype="application/prs.dms+xml"/> </model> </encounter> POST /quests/1/encounters/1 HTTP/1.1 GET /quests/1/encounters/1 HTTP/1.1 <intention> <attack> <weapon>sword</weapon> <strategy>slash</strategy> </attack> </intention>
  • 25. Anatomy  of  a  hypermedia  control     <link rel="http://dms/north" type="application/prs.dms+xml" href="/quests/1/locations/2" /> Semantic  context   WHY  access  the  linked   resource?   Interpretation   WHAT  form  does  the   linked  resource  take?   Address   WHERE  does  the   linked  resource   reside?  
  • 26. Media  type  is  a  key  into  an  interpretative  scheme   Schemas   Hypermedia  controls   Processing  model   Link  relations  
  • 27. Archaeology  of  an  application  protocol   Why?   How?   What?   Link  relations   HTTP  idioms   Media  types  
  • 28. Manipulate  resources  using  HTTP  idioms   <submission resource="/quests/1/locations/2" method="POST" mediatype="application/prs.dms+xml"/> OPTIONS /quests/1/locations/2 HTTP/1.1 Host: dms HTTP/1.1 200 OK Allow: GET, POST HTTP/1.1 200 OK Content-Type: application/prs.dms+xml ETag: "871CDA1C9935" Content-Length: ... HTTP/1.1 303 See Other Content-Type: application/prs.dms+xml Location: http://dms/quests/1/encounters/1 Content-Length: ...
  • 29. Down  in  the  dungeons…   http://dms/quests/1/locations/2 http://dms/quests/1/encounters/1 http://dms/quests/1/encounters/1/outcomes/1 guarded by involves Location Skeleton Encounter dead- guarded unguarded undead dead unresolved resolving resolved resolved by modifies affects Outcome Intention determined determines declared
  • 30. Design  and  implementation  guidelines  
  • 31. Equipping  the  client   Capability   Description   HTTP  client   Implement  HTTP  idioms  (eg.  conditional  GET).   Parse/  assemble  hypermedia  representations;   Media  type  handlers   surface  hypermedia  controls.   Evaluate  semantic   Understand  semantic  context  for  controls  in   context   relation  to  client  goal.   Choose  and  activate   Decide  on  next  transition  based  on  goal,   control   application  state  and  available  transitions.   Cache   Client-­‐side  caching,  including  revalidation  
  • 32. Hypermedia  and  Systems  Architecture   How  to  GET  a  Cup  of  Coffee   http://www.infoq.com/articles/webber-­‐rest-­‐workflow   Jim  Webber   Savas  Parastatidis   Ian  Robinson   Photos  taken  from  ElDave’s  Flickr  stream  under  the  Creative  Commons  licence  
  • 33. Thank  you   http://ianSrobinson.com   @ianSrobinson   ianSrobinson@gmail.com