org.restlet
Class Restlet

java.lang.Object
  extended by org.restlet.Uniform
      extended by org.restlet.Restlet
Direct Known Subclasses:
Application, Component, Connector, Filter, Finder, Redirector, Router, WrapperRestlet

public class Restlet
extends Uniform

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.

Author:
Jerome Louvel

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
 Application getApplication()
          Returns the parent application if it exists, or null.
 Context getContext()
          Returns the context.
 java.util.logging.Logger getLogger()
          Returns the context's logger.
 void handle(Request request, Response response)
          Handles a call.
protected  void init(Request request, Response response)
          Deprecated. Instead, make sure that you call the handle(Request, Response) method from your Restlet superclass.
 boolean isStarted()
          Indicates if the Restlet is started.
 boolean isStopped()
          Indicates if the Restlet is stopped.
 void setContext(Context context)
          Sets the context.
 void start()
          Starts the Restlet.
 void stop()
          Stops the Restlet.
 
Methods inherited from class org.restlet.Uniform
delete, delete, get, get, handle, head, head, options, options, post, post, put, put
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Restlet

public Restlet()
Constructor with null context.


Restlet

public 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.

Parameters:
context - The context of the Restlet.
See Also:
Context.createChildContext()
Method Detail

getApplication

public Application getApplication()
Returns the parent application if it exists, or null.

Returns:
The parent application if it exists, or null.

getContext

public Context getContext()
Returns the context.

Returns:
The context.

getLogger

public java.util.logging.Logger getLogger()
Returns the context's logger.

Returns:
The context's logger.

handle

public void handle(Request request,
                   Response response)
Handles a call. The default behavior is to call the (now deprecated) init(Request, Response) method. In next version, init(Request, Response) will be removed and its logic directly added to this method instead.

Subclasses overriding this method should make sure that they call super.handle(request, response) before adding their own logic.

Specified by:
handle in class Uniform
Parameters:
request - The request to handle.
response - The response to update.

init

@Deprecated
protected void init(Request request,
                               Response response)
Deprecated. Instead, make sure that you call the handle(Request, Response) method from your Restlet superclass.

Initialize the Restlet by setting the current context using the 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.

Parameters:
request - The request to handle.
response - The response to update.

isStarted

public boolean isStarted()
Indicates if the Restlet is started.

Returns:
True if the Restlet is started.

isStopped

public boolean isStopped()
Indicates if the Restlet is stopped.

Returns:
True if the Restlet is stopped.

setContext

public void setContext(Context context)
Sets the context.

Parameters:
context - The context.

start

public void start()
           throws java.lang.Exception
Starts the Restlet.

Throws:
java.lang.Exception

stop

public void stop()
          throws java.lang.Exception
Stops the Restlet.

Throws:
java.lang.Exception


Copyright © 2005-2008 Noelios Technologies.