Package org.restlet.resource
Class Finder
java.lang.Object
org.restlet.Restlet
org.restlet.resource.Finder
- All Implemented Interfaces:
Uniform
- Direct Known Subclasses:
Directory
Restlet that can find the target server resource that will effectively handle
incoming calls. By default, based on a given
Once the target has been created, the call is automatically dispatched to the
Once the call is handled, the
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.
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.
- Author:
- Jerome Louvel
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreate(Class<? extends ServerResource> targetClass, Request request, Response response) Creates a new instance of a givenServerResourcesubclass.Creates a new instance of theServerResourcesubclass designated by the "targetClass" property.static FindercreateFinder(Class<? extends ServerResource> targetClass, Class<? extends Finder> finderClass, Context context, Logger logger) Creates a new finder instance based on the "targetClass" property.Finds the targetServerResourceif available.Class<? extends ServerResource>Returns the target resource class which must be either a subclass ofServerResource.voidHandles a call.voidsetTargetClass(Class<? extends ServerResource> targetClass) Sets the target resource class which must be a subclass ofServerResource.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
-
Constructor Details
-
Finder
public Finder()Constructor. -
Finder
Constructor.- Parameters:
context- The context.
-
Finder
Constructor.- Parameters:
context- The context.targetClass- The targetServerResourcesubclass.
-
-
Method Details
-
createFinder
public 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.- 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.
-
create
public ServerResource create(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 targetServerResourcesubclass.request- The request to handle.response- The response to update.- Returns:
- The created resource or null.
-
create
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.
-
find
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.
-
getTargetClass
Returns the target resource class which must be either a subclass ofServerResource.- Returns:
- the target Handler class.
-
handle
Handles a call. -
setTargetClass
Sets the target resource class which must be a subclass ofServerResource.- Parameters:
targetClass- The target resource class. It must be a subclass ofServerResource.
-
toString
-