org.restlet.resource.ServerResource
Base class for server-side resources. It acts as a wrapper to a given call, including the incoming {@link Request} and the outgoing {@link Response}.
It's life cycle is managed by a {@link Finder} created either explicitly ormore likely implicitly when your {@link ServerResource} subclass is attachedto a {@link Filter} or a {@link Router} via the {@link Filter#setNext(Class)}or {@link Router#attach(String,Class)} methods for example. Afterinstantiation using the default constructor, the final {@link #init(Context,Request,Response)} method is invoked, setting thecontext, request and response. You can intercept this by overriding the {@link #doInit()} method. Then, if the response status is still a success,the {@link #handle()} method is invoked to actually handle the call. Finally,the final {@link #release()} method is invoked to do the necessary clean-up,which you can intercept by overriding the {@link #doRelease()} method. Duringthis life cycle, if any exception is caught, then the {@link #doCatch(Throwable)} method is invoked.
Note that when an annotated method manually sets the response entity, if this entity is available then it will be preserved and the result of the annotated method ignored.
In addition, there are two ways to declare representation variants, one is based on the {@link #getVariants()} method and another one on the annotatedmethods. Both approaches can't however be used at the same time for now.
Concurrency note: contrary to the {@link org.restlet.Uniform} class and itsmain {@link Restlet} subclass where a single instance can handle severalcalls concurrently, one instance of {@link ServerResource} is created foreach call handled and accessed by only one thread at a time.
@author Jerome Louvel