|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.restlet.Restlet
org.restlet.resource.Finder
public class Finder
Restlet that can find the target server resource that will effectively handle
incoming calls. By default, based on a given ServerResource
subclass
available via the getTargetClass()
method, it automatically
instantiates for each incoming call the target resource class using its
default constructor and invoking the
Resource.init(Context, Request, Response)
method.
Once the target has been created, the call is automatically dispatched to the
ServerResource.handle()
method.
Once the call is handled, the Resource.release()
method is
invoked to permit clean-up actions.
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 in member variables.
Constructor Summary | |
---|---|
Finder()
Constructor. |
|
Finder(Context context)
Constructor. |
|
Finder(Context context,
Class<? extends ServerResource> targetClass)
Constructor. |
Method Summary | |
---|---|
ServerResource |
create(Class<? extends ServerResource> targetClass,
Request request,
Response response)
Creates a new instance of a given ServerResource subclass. |
ServerResource |
create(Request request,
Response response)
Creates a new instance of the ServerResource subclass designated
by the "targetClass" property. |
static Finder |
createFinder(Class<? extends ServerResource> targetClass,
Class<? extends Finder> finderClass,
Context context,
Logger logger)
Creates a new finder instance based on the "targetClass" property. |
ServerResource |
find(Request request,
Response response)
Finds the target ServerResource if available. |
Class<? extends ServerResource> |
getTargetClass()
Returns the target resource class which must be either a subclass of ServerResource . |
void |
handle(Request request,
Response response)
Handles a call. |
void |
setTargetClass(Class<? extends ServerResource> targetClass)
Sets the target resource class which must be a subclass of ServerResource . |
String |
toString()
|
Methods inherited from class org.restlet.Restlet |
---|
createFinder, finalize, getApplication, getAuthor, getContext, getDescription, getFinderClass, getLogger, getName, getOwner, handle, handle, handle, isStarted, isStopped, setAuthor, setContext, setDescription, setFinderClass, setName, setOwner, start, stop |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Finder()
public Finder(Context context)
context
- The context.public Finder(Context context, Class<? extends ServerResource> targetClass)
context
- The context.targetClass
- The target ServerResource
subclass.Method Detail |
---|
public static Finder createFinder(Class<? extends ServerResource> targetClass, Class<? extends Finder> finderClass, Context context, Logger logger)
targetClass
- The target Resource class to attach.finderClass
- The optional finder class to instantiate.logger
- The logger.
public ServerResource create(Class<? extends ServerResource> targetClass, Request request, Response response)
ServerResource
subclass. Note
that Error
and RuntimeException
thrown by
ServerResource
constructors are re-thrown by this method. Other
exception are caught and logged.
request
- The request to handle.response
- The response to update.
public ServerResource create(Request request, Response response)
ServerResource
subclass designated
by the "targetClass" property. The default behavior is to invoke the
create(Class, Request, Response)
with the "targetClass" property
as a parameter.
request
- The request to handle.response
- The response to update.
public ServerResource find(Request request, Response response)
ServerResource
if available. The default
behavior is to invoke the create(Request, Response)
method.
request
- The request to handle.response
- The response to update.
public Class<? extends ServerResource> getTargetClass()
ServerResource
.
public void handle(Request request, Response response)
handle
in interface Uniform
handle
in class Restlet
request
- The request to handle.response
- The response to update.public void setTargetClass(Class<? extends ServerResource> targetClass)
ServerResource
.
targetClass
- The target resource class. It must be a subclass of
ServerResource
.public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |