Package org.restlet
Class Application
java.lang.Object
org.restlet.Restlet
org.restlet.Application
- All Implemented Interfaces:
Uniform
Restlet managing a coherent set of resources and services. Applications are
guaranteed to receive calls with their base reference set relatively to the
Applications also have many useful services associated. Most are enabled by default and are available as properties that can be eventually overridden:
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. Most are enabled by default and are available as properties that can be eventually overridden:
- "connectorService" to declare necessary client and server connectors.
- "converterService" to convert between regular objects and representations.
- "decoderService" to automatically decode or uncompress received entities.
- "encoderService" to automatically encode or compress sent entities (disabled by default).
- "metadataService" to provide access to metadata and their associated extension names.
- "rangeService" to automatically exposes ranges of response entities.
- "statusService" to provide common representations for exception status.
- "taskService" to run tasks asynchronously (disabled by default).
- "tunnelService" to tunnel method names or client preferences via query parameters.
- Author:
- Jerome Louvel
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionCreates a inbound root Restlet that will receive all incoming calls.Creates a outbound root Restlet that will receive all outgoing calls from ClientResource.Returns the connector service.Returns the content negotiation service.Returns the converter service.static ApplicationThis variable is stored internally as a thread local variable and updated each time a call enters an application.Returns the decoder service.Returns the encoder service.Returns the inbound root Restlet.Returns the metadata service.Returns the outbound root Restlet.Returns the range service.Returns the role associated to the given name.getRoles()Returns the modifiable list of roles.Returns the modifiable list of services.Returns the status service.Returns the tunnel service.voidHandles a call.booleanIndicates if the debugging mode is enabled.voidsetConnectorService(ConnectorService connectorService) Sets the connector service.voidsetConnegService(ConnegService connegService) Sets the content negotiation service.voidsetContext(Context context) Sets the context.voidsetConverterService(ConverterService converterService) Sets the converter service.static voidsetCurrent(Application application) Sets the context associated with the current thread.voidsetDebugging(boolean debugging) Indicates if the debugging mode is enabled.voidsetDecoderService(DecoderService decoderService) Sets the decoder service.voidsetEncoderService(EncoderService encoderService) Sets the encoder service.voidsetInboundRoot(Class<? extends ServerResource> inboundRootClass) Sets the inbound root Resource class.voidsetInboundRoot(Restlet inboundRoot) Sets the inbound root Restlet.voidsetMetadataService(MetadataService metadataService) Sets the metadata service.voidsetOutboundRoot(Class<? extends ServerResource> outboundRootClass) Sets the outbound root Resource class.voidsetOutboundRoot(Restlet outboundRoot) Sets the outbound root Restlet.voidsetRangeService(RangeService rangeService) Sets the range service.voidSets the modifiable list of roles.voidsetStatusService(StatusService statusService) Sets the status service.voidsetTaskService(TaskService taskService) Sets the task service.voidsetTunnelService(TunnelService tunnelService) Sets the tunnel service.voidstart()Starts the application, all the enabled associated services then the inbound and outbound roots.voidstop()Stops the application, the inbound and outbound roots then all the enabled associated services.Methods inherited from class org.restlet.Restlet
createFinder, finalize, getApplication, getAuthor, getContext, getDescription, getFinderClass, getLogger, getName, getOwner, handle, handle, handle, isStarted, isStopped, setAuthor, setDescription, setFinderClass, setName, setOwner
-
Constructor Details
-
Application
public Application()Constructor. Note this constructor is convenient because you don't have to provide a context like forApplication(Context). Therefore, the context will initially be null. It's only when you attach the application to a virtual host via one of its attach*() methods that a proper context will be set. -
Application
Constructor.- Parameters:
context- The context to use based on parent component context. This context should be created using theContext.createChildContext()method to ensure a proper isolation with the other applications.
-
-
Method Details
-
getCurrent
This variable is stored internally as a thread local variable and updated each time a call enters an application. Warning: this method should only be used under duress. You should by default prefer getting the current application using methods such asResource.getApplication()- Returns:
- The current context.
-
setCurrent
Sets the context associated with the current thread.- Parameters:
application- The thread's context.
-
createInboundRoot
Creates a inbound root Restlet that will receive all incoming calls. In general, instances of Router, Filter or Finder classes will be used as initial application Restlet. The default implementation returns null by default. This method is intended to be overridden by subclasses.- Returns:
- The inbound root Restlet.
-
createOutboundRoot
Creates a outbound root Restlet that will receive all outgoing calls from ClientResource. In general, instances ofRouterandFilterclasses will be used. The default implementation returns a Restlet giving access to the the outbound service layer and finally to theContext.getClientDispatcher().This method is intended to be overridden by subclasses but in order to benefit from the outbound service filtering layer, the original outbound root must be careful attached again at the end of the user filtering layer.
- Returns:
- The outbound root Restlet.
-
getConnectorService
Returns the connector service. The service is enabled by default.- Returns:
- The connector service.
-
getConnegService
Returns the content negotiation service. The service is enabled by default.- Returns:
- The content negotiation service.
-
getConverterService
Returns the converter service. The service is enabled by default.- Returns:
- The converter service.
-
getDecoderService
Returns the decoder service. The service is enabled by default.- Returns:
- The decoder service.
-
getEncoderService
Returns the encoder service. The service is disabled by default.- Returns:
- The encoder service.
-
getInboundRoot
Returns the inbound root Restlet.- Returns:
- The inbound root Restlet.
-
getMetadataService
Returns the metadata service. The service is enabled by default.- Returns:
- The metadata service.
-
getOutboundRoot
Returns the outbound root Restlet.- Returns:
- The outbound root Restlet.
-
getRangeService
Returns the range service.- Returns:
- The range service.
-
getRole
Returns the role associated to the given name.- Parameters:
name- The name of the role to find.- Returns:
- The role matched or null.
-
getRoles
Returns the modifiable list of roles.- Returns:
- The modifiable list of roles.
-
getServices
Returns the modifiable list of services.- Returns:
- The modifiable list of services.
-
getStatusService
Returns the status service. The service is enabled by default.- Returns:
- The status service.
-
getTunnelService
Returns the tunnel service. The service is enabled by default.- Returns:
- The tunnel service.
-
handle
Description copied from class:RestletHandles a call. The default behavior is to initialize the Restlet by setting the current context using theContext.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 toStatus.SERVER_ERROR_INTERNAL.Subclasses overriding this method should make sure that they call super.handle(request, response) before adding their own logic.
-
isDebugging
public boolean isDebugging()Indicates if the debugging mode is enabled. True by default.- Returns:
- True if the debugging mode is enabled.
-
setConnectorService
Sets the connector service.- Parameters:
connectorService- The connector service.
-
setConnegService
Sets the content negotiation service.- Parameters:
connegService- The content negotiation service.
-
setContext
Description copied from class:RestletSets the context.- Overrides:
setContextin classRestlet- Parameters:
context- The context.
-
setConverterService
Sets the converter service.- Parameters:
converterService- The converter service.
-
setDebugging
public void setDebugging(boolean debugging) Indicates if the debugging mode is enabled.- Parameters:
debugging- True if the debugging mode is enabled.
-
setDecoderService
Sets the decoder service.- Parameters:
decoderService- The decoder service.
-
setEncoderService
Sets the encoder service.- Parameters:
encoderService- The encoder service.
-
setInboundRoot
Sets the inbound root Resource class.- Parameters:
inboundRootClass- The inbound root Resource class.
-
setInboundRoot
Sets the inbound root Restlet.- Parameters:
inboundRoot- The inbound root Restlet.
-
setMetadataService
Sets the metadata service.- Parameters:
metadataService- The metadata service.
-
setOutboundRoot
Sets the outbound root Resource class.- Parameters:
outboundRootClass- The client rootServerResourcesubclass.
-
setOutboundRoot
Sets the outbound root Restlet.- Parameters:
outboundRoot- The outbound root Restlet.
-
setRangeService
Sets the range service.- Parameters:
rangeService- The range service.
-
setRoles
Sets the modifiable list of roles. This method clears the current list and adds all entries in the parameter list.- Parameters:
roles- A list of roles.
-
setStatusService
Sets the status service.- Parameters:
statusService- The status service.
-
setTaskService
Sets the task service.- Parameters:
taskService- The task service.
-
setTunnelService
Sets the tunnel service.- Parameters:
tunnelService- The tunnel service.
-
start
Starts the application, all the enabled associated services then the inbound and outbound roots. -
stop
Stops the application, the inbound and outbound roots then all the enabled associated services. Finally, it clears the internal cache of annotations.
-