In the MyApplication
example,
the only
thing we need to
consider is
what our code does, not how objects are created from the MyResource
class and how the respond
method is invoked. However, the mechanisms behind all these things are
not magic - the adapter
code is responsible for all of
this. Let us
turn the diagram of components on its side and investigate what happens
when a request is sent to the application from a user:
Server environment | Adapter | Application |
---|---|---|
The request is received and sent to the adapter... | The adapter creates a resource object in the application... | A resource object is created and initialised. |
The adapter
calls the respond method on the new resource... |
The code
within the resource's respond method is executed. |
In more complicated applications, there may be a need to create our own resource objects explicitly, but this is not particularly interesting to think about at this point - see "Treating the Path Like a Filesystem" for a discussion of multiple resource objects.