org.restlet.engine

## Class TemplateDispatcher

- java.lang.Object
- - org.restlet.Restlet
  - - org.restlet.Connector
    - - org.restlet.Client
      - - org.restlet.engine.TemplateDispatcher

All Implemented Interfaces:
  Uniform

Direct Known Subclasses:
  ChildClientDispatcher, ComponentClientDispatcher, ComponentServerDispatcher

    public class TemplateDispatcher
    extends Client

Base call dispatcher capable of resolving target resource URI templates. Concurrency note: instances of this class or its subclasses can be invoked by several threads at the same time and therefore must be thread-safe. You should be especially careful when storing state as member variables.

Author:
  Jerome Louvel

### Constructor Summary

Constructors
Constructor and Description
`TemplateDispatcher(Context context)` Constructor.

### Method Summary

Methods
`protected void` `doHandle(Request request, Response response)` Actually handles the call.
`Context` `getContext()` Returns the context.
`void` `handle(Request request, Response response)` Handles the call after resolving any URI template on the request's target resource reference.
`void` `setContext(Context context)` Sets the context.

### Methods inherited from class org.restlet.Client

`getConnectTimeout, handle, handle, handle, isAvailable, setConnectTimeout, start, stop`

### Methods inherited from class org.restlet.Connector

`getProtocols, setProtocols`

### Methods inherited from class org.restlet.Restlet

`finalize, getApplication, getAuthor, getDescription, getLogger, getName, getOwner, isStarted, isStopped, setAuthor, setDescription, setName, setOwner`

### Methods inherited from class java.lang.Object

`clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### TemplateDispatcher

    public TemplateDispatcher(Context context)

Constructor.

Parameters:
  `context` - The context.

### Method Detail

#### doHandle

    protected void doHandle(Request request,
                Response response)

Actually handles the call. Since this method only sets the request's original reference (`Request.getOriginalRef()` with the the targeted one, it must be overridden by subclasses.

Parameters:
  `request` - The request to handle.
  `response` - The response to update.

#### getContext

    public Context getContext()

Returns the context. Override default behavior from `Restlet`.

Overrides:
  `getContext` in class `Restlet`
Returns:
  The context.

#### handle

    public void handle(Request request,
              Response response)

Handles the call after resolving any URI template on the request's target resource reference.

Specified by:
  `handle` in interface `Uniform`
Overrides:
  `handle` in class `Client`
Parameters:
  `request` - The request to handle.
  `response` - The response to update.

#### setContext

    public void setContext(Context context)

Sets the context. Override default behavior from `Restlet`.

Overrides:
  `setContext` in class `Restlet`
Parameters:
  `context` - The context to set.