1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 2 <html xmlns="http://www.w3.org/1999/xhtml"> 3 <head> 4 <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type" /> 5 <title>How Resources are Created</title> 6 <meta name="generator" 7 content="amaya 8.1a, see http://www.w3.org/Amaya/" /> 8 <link href="styles.css" rel="stylesheet" type="text/css" /> 9 </head> 10 <body> 11 <h1>How Resources are Created 12 </h1> 13 <p>In the <code>MyApplication</code> 14 <a href="resources.html">example</a>, 15 the only 16 thing we need to 17 consider is 18 what our code does, not how objects are created from the <code>MyResource</code> 19 class and how the <code>respond</code> 20 method is invoked. However, the mechanisms behind all these things are 21 not magic - the <a href="deploying.html">adapter 22 code</a> is responsible for all of 23 this. Let us 24 turn the diagram of components on its side and investigate what happens 25 when a request is sent to the application from a user:</p> 26 <table class="layers" 27 style="width: 80%; text-align: left; margin-left: auto; margin-right: auto;" 28 border="0" cellpadding="5" cellspacing="0"> 29 <tbody> 30 <tr> 31 <th 32 style="border-width: 1px 1px 0px; text-align: center; vertical-align: middle; background-color: rgb(192, 192, 192); width: 30%; border-top-style: solid; border-left-style: solid;">Server 33 environment</th> 34 <th 35 style="border-width: 1px; text-align: center; vertical-align: middle; border-left-style: solid; border-top-style: solid; width: 30%; background-color: rgb(102, 203, 255);">Adapter 36 </th> 37 <th 38 style="text-align: center; vertical-align: middle; border-top-style: solid; border-left-style: solid; border-right-style: solid; border-top-width: 1px; border-left-width: 1px; border-right-width: 1px; background-color: rgb(193, 255, 102); width: 40%;">Application 39 </th> 40 </tr> 41 <tr> 42 <td 43 style="background-color: rgb(192, 192, 192); border-left-style: solid; border-left-width: 1px;" 44 align="undefined" valign="undefined"><span class="method">The request 45 is received and sent to 46 the adapter... </span></td> 47 <td 48 style="background-color: rgb(102, 203, 255); border-left-style: solid; border-left-width: 1px;" 49 align="undefined" valign="undefined"><span class="method">The adapter 50 creates a resource object 51 in the application... </span></td> 52 <td 53 style="background-color: rgb(193, 255, 102); border-left-style: solid; border-right-style: solid; border-left-width: 1px; border-right-width: 1px;" 54 align="undefined" valign="undefined"><span class="method">A resource 55 object is 56 created and initialised. </span></td> 57 </tr> 58 <tr> 59 <td 60 style="background-color: rgb(192, 192, 192); border-left-style: solid; border-bottom-style: solid; border-left-width: 1px; border-right-width: 1px; border-bottom-width: 1px;"><br /> 61 </td> 62 <td 63 style="background-color: rgb(102, 203, 255); border-left-style: solid; border-bottom-style: solid; border-left-width: 1px; border-bottom-width: 1px;" 64 align="undefined" valign="undefined"><span class="method">The adapter 65 calls the <code>respond</code> method on the new resource...</span></td> 66 <td 67 style="background-color: rgb(193, 255, 102); border-left-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-width: 1px; border-right-width: 1px; border-bottom-width: 1px;" 68 align="undefined" valign="undefined"><span class="method">The code 69 within the resource's <code>respond</code> method is executed. </span></td> 70 </tr> 71 </tbody> 72 </table> 73 <p>In more 74 complicated applications, there may 75 be a 76 need to create our own resource objects explicitly, but this is not 77 particularly interesting to think about at this point - see <a 78 href="paths-filesystem.html">"Treating the Path Like 79 a Filesystem"</a> for a 80 discussion of multiple resource objects.</p> 81 </body> 82 </html>