|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.restlet.Restlet
public abstract class Restlet
Uniform class that provides a context and life cycle support. It has many
subclasses that focus on specific ways to process calls. The context property
is typically provided by a parent Component as a way to encapsulate access to
shared features such as logging and client connectors.
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 | |
---|---|
Restlet()
Constructor with null context. |
|
Restlet(Context context)
Constructor with the Restlet's context which can be the parent's application context, but shouldn't be the parent Component's context for security reasons. |
Method Summary | |
---|---|
Finder |
createFinder(Class<? extends ServerResource> resourceClass)
Creates a new finder instance based on the "targetClass" property. |
protected void |
finalize()
Attempts to stop() the Restlet if it is still started. |
Application |
getApplication()
Returns the parent application if it exists, or null. |
String |
getAuthor()
Returns the author(s). |
Context |
getContext()
Returns the context. |
String |
getDescription()
Returns the description. |
Class<? extends Finder> |
getFinderClass()
Returns the finder class used to instantiate resource classes. |
Logger |
getLogger()
Returns the context's logger. |
String |
getName()
Returns the display name. |
String |
getOwner()
Returns the owner(s). |
Response |
handle(Request request)
Handles a call. |
void |
handle(Request request,
Response response)
Handles a call. |
void |
handle(Request request,
Response response,
Uniform onResponseCallback)
Handles a call. |
void |
handle(Request request,
Uniform onReceivedCallback)
Handles a call. |
boolean |
isStarted()
Indicates if the Restlet is started. |
boolean |
isStopped()
Indicates if the Restlet is stopped. |
void |
setAuthor(String author)
Sets the author(s). |
void |
setContext(Context context)
Sets the context. |
void |
setDescription(String description)
Sets the description. |
void |
setFinderClass(Class<? extends Finder> finderClass)
Sets the finder class to instantiate. |
void |
setName(String name)
Sets the display name. |
void |
setOwner(String owner)
Sets the owner(s). |
void |
start()
Starts the Restlet. |
void |
stop()
Stops the Restlet. |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Restlet()
public Restlet(Context context)
context
- The context of the Restlet.Context.createChildContext()
Method Detail |
---|
public Finder createFinder(Class<? extends ServerResource> resourceClass)
createFinder(Class)
method is
invoked if available, otherwise the
Finder.createFinder(Class, Class, Context, Logger)
method is called with the Finder
class as
parameter.
resourceClass
- The target ServerResource
class
to find.
Finder.createFinder(Class, Class, Context,
Logger)
protected void finalize() throws Throwable
stop()
the Restlet if it is still started.
finalize
in class Object
Throwable
public Application getApplication()
public String getAuthor()
public Context getContext()
public String getDescription()
public Class<? extends Finder> getFinderClass()
Finder
class. This
property is leveraged by Application.setOutboundRoot(Class)
and
Application.setInboundRoot(Class)
methods.
public Logger getLogger()
public String getName()
public String getOwner()
public final Response handle(Request request)
Response
object and then invokes
handle(Request, Response)
.
request
- The request to handle.
public void handle(Request request, Response response)
Context.setCurrent(Context)
method and by attempting to start it, unless it was already started. If
an exception is thrown during the start action, then the response status
is set to Status.SERVER_ERROR_INTERNAL
.
Subclasses overriding this method should make sure that they call super.handle(request, response) before adding their own logic.
handle
in interface Uniform
request
- The request to handle.response
- The response to update.public final void handle(Request request, Response response, Uniform onResponseCallback)
request
- The request to handle.response
- The response to update.onResponseCallback
- The callback invoked upon response reception.public final void handle(Request request, Uniform onReceivedCallback)
request
- The request to handle.onReceivedCallback
- The callback invoked upon request reception.public boolean isStarted()
public boolean isStopped()
public void setAuthor(String author)
author
- The author(s).public void setContext(Context context)
context
- The context.public void setDescription(String description)
description
- The description.public void setFinderClass(Class<? extends Finder> finderClass)
Application.setOutboundRoot(Class)
and
Application.setInboundRoot(Class)
methods.
finderClass
- The finder class to instantiate.public void setName(String name)
name
- The display name.public void setOwner(String owner)
owner
- The owner(s).public void start() throws Exception
Exception
public void stop() throws Exception
Exception
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |