Package org.restlet.resource
Class Finder
- java.lang.Object
- 
- org.restlet.Restlet
- 
- org.restlet.resource.Finder
 
 
- 
- All Implemented Interfaces:
- Uniform
 - Direct Known Subclasses:
- Directory
 
 public class Finder extends Restlet Restlet that can find the target server resource that will effectively handle incoming calls. By default, based on a givenServerResourcesubclass available via thegetTargetClass()method, it automatically instantiates for each incoming call the target resource class using its default constructor and invoking theResource.init(Context, Request, Response)method.
 
 Once the target has been created, the call is automatically dispatched to theServerResource.handle()method.
 
 Once the call is handled, theResource.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.- Author:
- Jerome Louvel
 
- 
- 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ServerResourcecreate(java.lang.Class<? extends ServerResource> targetClass, Request request, Response response)Creates a new instance of a givenServerResourcesubclass.ServerResourcecreate(Request request, Response response)Creates a new instance of theServerResourcesubclass designated by the "targetClass" property.static FindercreateFinder(java.lang.Class<? extends ServerResource> targetClass, java.lang.Class<? extends Finder> finderClass, Context context, java.util.logging.Logger logger)Creates a new finder instance based on the "targetClass" property.ServerResourcefind(Request request, Response response)Finds the targetServerResourceif available.java.lang.Class<? extends ServerResource>getTargetClass()Returns the target resource class which must be either a subclass ofServerResource.voidhandle(Request request, Response response)Handles a call.voidsetTargetClass(java.lang.Class<? extends ServerResource> targetClass)Sets the target resource class which must be a subclass ofServerResource.java.lang.StringtoString()- 
Methods inherited from class org.restlet.RestletcreateFinder, finalize, getApplication, getAuthor, getContext, getDescription, getFinderClass, getLogger, getName, getOwner, handle, handle, handle, isStarted, isStopped, setAuthor, setContext, setDescription, setFinderClass, setName, setOwner, start, stop
 
- 
 
- 
- 
- 
Constructor Detail- 
Finderpublic Finder() Constructor.
 - 
Finderpublic Finder(Context context) Constructor.- Parameters:
- context- The context.
 
 - 
Finderpublic Finder(Context context, java.lang.Class<? extends ServerResource> targetClass) Constructor.- Parameters:
- context- The context.
- targetClass- The target- ServerResourcesubclass.
 
 
- 
 - 
Method Detail- 
createFinderpublic static Finder createFinder(java.lang.Class<? extends ServerResource> targetClass, java.lang.Class<? extends Finder> finderClass, Context context, java.util.logging.Logger logger) Creates a new finder instance based on the "targetClass" property.- Parameters:
- targetClass- The target Resource class to attach.
- finderClass- The optional finder class to instantiate.
- context- The current Context.
- logger- The logger.
- Returns:
- The new finder instance.
 
 - 
createpublic ServerResource create(java.lang.Class<? extends ServerResource> targetClass, Request request, Response response) Creates a new instance of a givenServerResourcesubclass. Note thatErrorandRuntimeExceptionthrown byServerResourceconstructors are re-thrown by this method. Other exception are caught and logged.- Parameters:
- targetClass- The target- ServerResourcesubclass.
- request- The request to handle.
- response- The response to update.
- Returns:
- The created resource or null.
 
 - 
createpublic ServerResource create(Request request, Response response) Creates a new instance of theServerResourcesubclass designated by the "targetClass" property. The default behavior is to invoke thecreate(Class, Request, Response)with the "targetClass" property as a parameter.- Parameters:
- request- The request to handle.
- response- The response to update.
- Returns:
- The created resource or null.
 
 - 
findpublic ServerResource find(Request request, Response response) Finds the targetServerResourceif available. The default behavior is to invoke thecreate(Request, Response)method.- Parameters:
- request- The request to handle.
- response- The response to update.
- Returns:
- The target resource if available or null.
 
 - 
getTargetClasspublic java.lang.Class<? extends ServerResource> getTargetClass() Returns the target resource class which must be either a subclass ofServerResource.- Returns:
- the target Handler class.
 
 - 
setTargetClasspublic void setTargetClass(java.lang.Class<? extends ServerResource> targetClass) Sets the target resource class which must be a subclass ofServerResource.- Parameters:
- targetClass- The target resource class. It must be a subclass of- ServerResource.
 
 - 
toStringpublic java.lang.String toString() - Overrides:
- toStringin class- java.lang.Object
 
 
- 
 
-