org.restlet
Class Application

java.lang.Object
  extended by org.restlet.Uniform
      extended by org.restlet.Restlet
          extended by org.restlet.Application

public class Application
extends Restlet

Restlet that can be attached to one or more VirtualHosts. Applications are guaranteed to receive calls with their base reference set relatively to the VirtualHost that served them. This class is both a descriptor able to create the root Restlet and the actual Restlet that can be attached to one or more VirtualHost instances.

Applications also have many useful Services associated. They are available as properties that can be eventually overriden:

Author:
Jerome Louvel (contact@noelios.com)

Constructor Summary
Application()
          Constructor.
Application(Context parentContext)
          Constructor.
 
Method Summary
 Restlet createRoot()
          Creates a root Restlet that will receive all incoming calls.
 String getAuthor()
          Returns the author(s).
 ConnectorService getConnectorService()
          Returns the connector service.
 ConverterService getConverterService()
          Deprecated. Since 1.1 with no replacement as it doesn't fit well with content negotiation. Most users prefer to handle those conversion in Resource subclasses.
static Application getCurrent()
          This variable is stored internally as a thread local variable and updated each time a call enters an application.
 DecoderService getDecoderService()
          Returns the decoder service, enabled by default.
 String getDescription()
          Returns the description.
 MetadataService getMetadataService()
          Returns the metadata service.
 String getName()
          Returns the display name.
 String getOwner()
          Returns the owner(s).
 Restlet getRoot()
          Returns the root Restlet.
 StatusService getStatusService()
          Returns the status service, enabled by default.
 TunnelService getTunnelService()
          Returns the tunnel service, enabled by default.
 void handle(Request request, Response response)
          Handles a call.
 void setAuthor(String author)
          Sets the author(s).
 void setConnectorService(ConnectorService connectorService)
          Sets the connector service.
 void setConverterService(ConverterService converterService)
          Deprecated. Since 1.1 with no replacement as it doesn't fit well with content negotiation. Most users prefer to handle those conversion in Resource subclasses.
static void setCurrent(Application application)
          Sets the context to associated with the current thread.
 void setDecoderService(DecoderService decoderService)
          Sets the decoder service.
 void setDescription(String description)
          Sets the description.
 void setMetadataService(MetadataService metadataService)
          Sets the metadata service.
 void setName(String name)
          Sets the display name.
 void setOwner(String owner)
          Sets the owner(s).
 void setRoot(Restlet root)
          Sets the root Restlet.
 void setStatusService(StatusService statusService)
          Sets the status service.
 void setTunnelService(TunnelService tunnelService)
          Sets the tunnel service.
 void start()
          Starts the Restlet.
 void stop()
          Stops the Restlet.
 
Methods inherited from class org.restlet.Restlet
getApplication, getContext, getLogger, init, isStarted, isStopped, setContext
 
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

Application

public Application()
Constructor. Note that usage of this constructor is not recommended as your application won't have access to the parent component context. For example, no dispatching will be possible as it requires access to the component's client connectors.


Application

public Application(Context parentContext)
Constructor.

Parameters:
parentContext - The parent context. Typically the component's context.
Method Detail

getCurrent

public static Application getCurrent()
This variable is stored internally as a thread local variable and updated each time a call enters an application.

Returns:
The current context.

setCurrent

public static void setCurrent(Application application)
Sets the context to associated with the current thread.

Parameters:
application - The thread's context.

createRoot

public Restlet createRoot()
Creates a root Restlet that will receive all incoming calls. In general, instances of Router, Filter or Handler classes will be used as initial application Restlet. The default implementation returns null by default. This method is intended to be overriden by subclasses.

Returns:
The root Restlet.

getAuthor

public String getAuthor()
Returns the author(s).

Returns:
The author(s).

getConnectorService

public ConnectorService getConnectorService()
Returns the connector service. Creates a new instance if no one has been set.

Returns:
The connector service.

getConverterService

@Deprecated
public ConverterService getConverterService()
Deprecated. Since 1.1 with no replacement as it doesn't fit well with content negotiation. Most users prefer to handle those conversion in Resource subclasses.

Returns the converter service. Creates a new instance if no one has been set.

Returns:
The converter service.

getDecoderService

public DecoderService getDecoderService()
Returns the decoder service, enabled by default. Creates a new instance if no one has been set.

Returns:
The decoderservice.

getDescription

public String getDescription()
Returns the description.

Returns:
The description

getMetadataService

public MetadataService getMetadataService()
Returns the metadata service. Creates a new instance if no one has been set.

Returns:
The metadata service.

getName

public String getName()
Returns the display name.

Returns:
The display name.

getOwner

public String getOwner()
Returns the owner(s).

Returns:
The owner(s).

getRoot

public Restlet getRoot()
Returns the root Restlet. Invokes the createRoot() method if no root has been set, and stores the Restlet created for future uses.

Returns:
The root Restlet.

getStatusService

public StatusService getStatusService()
Returns the status service, enabled by default. Creates a new instance if no one has been set.

Returns:
The status service.

getTunnelService

public TunnelService getTunnelService()
Returns the tunnel service, enabled by default. Creates a new instance if no one has been set.

Returns:
The tunnel service.

handle

public void handle(Request request,
                   Response response)
Description copied from class: Restlet
Handles a call. The default behavior is to call the (now deprecated) Restlet.init(Request, Response) method. In next version, Restlet.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.

Overrides:
handle in class Restlet
Parameters:
request - The request to handle.
response - The response to update.

setAuthor

public void setAuthor(String author)
Sets the author(s).

Parameters:
author - The author(s).

setConnectorService

public void setConnectorService(ConnectorService connectorService)
Sets the connector service.

Parameters:
connectorService - The connector service.

setConverterService

@Deprecated
public void setConverterService(ConverterService converterService)
Deprecated. Since 1.1 with no replacement as it doesn't fit well with content negotiation. Most users prefer to handle those conversion in Resource subclasses.

Sets the converter service.

Parameters:
converterService - The converter service.

setDecoderService

public void setDecoderService(DecoderService decoderService)
Sets the decoder service.

Parameters:
decoderService - The decoder service.

setDescription

public void setDescription(String description)
Sets the description.

Parameters:
description - The description.

setMetadataService

public void setMetadataService(MetadataService metadataService)
Sets the metadata service.

Parameters:
metadataService - The metadata service.

setName

public void setName(String name)
Sets the display name.

Parameters:
name - The display name.

setOwner

public void setOwner(String owner)
Sets the owner(s).

Parameters:
owner - The owner(s).

setRoot

public void setRoot(Restlet root)
Sets the root Restlet.

Parameters:
root - The root Restlet.

setStatusService

public void setStatusService(StatusService statusService)
Sets the status service.

Parameters:
statusService - The status service.

setTunnelService

public void setTunnelService(TunnelService tunnelService)
Sets the tunnel service.

Parameters:
tunnelService - The tunnel service.

start

public void start()
           throws Exception
Description copied from class: Restlet
Starts the Restlet.

Overrides:
start in class Restlet
Throws:
Exception

stop

public void stop()
          throws Exception
Description copied from class: Restlet
Stops the Restlet.

Overrides:
stop in class Restlet
Throws:
Exception


Copyright © 2005-2008 Noelios Consulting.