Package org.restlet
Class Component
java.lang.Object
org.restlet.Restlet
org.restlet.Component
- All Implemented Interfaces:
Uniform
Restlet managing a set of
From an architectural point of view, here is the REST definition: "A component is an abstract unit of software instructions and internal state that provides a transformation of data via its interface." Roy T. Fielding
Components also have useful services associated. They are all enabled by default and are available as properties that can be eventually overridden:
Connectors, VirtualHosts,
Services and Applications. Applications are expected to be
directly attached to virtual hosts or to the internal router (see RIAP
pseudo-protocol for usage). Components also expose several services: access
logging and status setting. From an architectural point of view, here is the REST definition: "A component is an abstract unit of software instructions and internal state that provides a transformation of data via its interface." Roy T. Fielding
Components also have useful services associated. They are all enabled by default and are available as properties that can be eventually overridden:
- "logService" to configure access logging.
- "statusService" to provide common representations for exception status.
- "taskService" to run tasks asynchronously.
- Author:
- Jerome Louvel
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns a modifiable list of client connectors.Returns the default virtual host.getHosts()Returns the modifiable list of virtual hosts.Returns the private internal router where Restlets like Applications can be attached.Returns the global log service.Finds the realm with the given name.Returns the modifiable list of security realms.Returns the modifiable list of server connectors.Returns the modifiable list of services.Returns a task service to run concurrent tasks.voidHandles a call.voidsetClients(ClientList clients) Sets the modifiable list of client connectors.voidsetContext(Context context) Sets the context.voidsetDefaultHost(VirtualHost defaultHost) Sets the default virtual host.voidsetHosts(List<VirtualHost> hosts) Sets the modifiable list of virtual hosts.voidsetInternalRouter(Router internalRouter) Sets the private internal router were Restlets like Applications can be attached.voidsetLogService(LogService logService) Sets the global log service.voidSets the list of realms.voidsetServers(ServerList servers) Sets the modifiable list of server connectors.voidsetTaskService(TaskService taskService) Sets the task service.voidstart()Starts the component.protected voidStarts the client connectors.protected voidStarts the internal helper allowing incoming requests to be served.protected voidStarts the realms.protected voidStarts the virtual hosts and the internal router.protected voidStarts the server connectors.protected voidStarts the associated services.voidstop()Stops the component.protected voidStops the client connectors.protected voidStops the internal helper allowing incoming requests to be served.protected voidStops the realms.protected voidStops the virtual hosts and the internal router.protected voidStops the server connectors.protected voidStops the associated services.voidUpdates the component to take into account changes to the virtual hosts.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
-
Component
public Component()Constructor.
-
-
Method Details
-
getClients
Returns a modifiable list of client connectors.- Returns:
- A modifiable list of client connectors.
-
getDefaultHost
Returns the default virtual host.- Returns:
- The default virtual host.
-
getHosts
Returns the modifiable list of virtual hosts. Note that the order of virtual hosts in this list will be used to check the first one that matches.- Returns:
- The modifiable list of virtual hosts.
-
getInternalRouter
Returns the private internal router where Restlets like Applications can be attached. Those Restlets can be addressed via theProtocol.RIAP(Restlet Internal Access Protocol) client connector. This is used to manage private, internal and optimized access to local applications.
The first use case is the modularization of a large application into modules or layers. This can also be achieved using theContext.getServerDispatcher()method, but the internal router is easily addressable via an URI scheme and can be fully private to the current Component.
The second use case is the composition/mash-up of several representations via the org.restlet.ext.xml.Transformer class for example. For this you can leverage the XPath's document() function or the XSLT's include and import elements with RIAP URIs.- Returns:
- The private internal router.
-
getLogService
Returns the global log service. On the first call, if no log service was defined via thesetLogService(LogService)method, then a default logger service is created. This service will be enabled by default and has a logger name composed the "org.restlet." prefix followed by the simple component class name (without packages), followed by the ".LogService" suffix.- Returns:
- The global log service.
-
getRealm
Finds the realm with the given name.- Parameters:
name- The name.- Returns:
- The realm found or null.
-
getRealms
Returns the modifiable list of security realms.- Returns:
- The modifiable list of security realms.
-
getServers
Returns the modifiable list of server connectors.- Returns:
- The modifiable list of server connectors.
-
getServices
Returns the modifiable list of services.- Returns:
- The modifiable list of services.
-
getTaskService
Returns a task service to run concurrent tasks. The service is enabled by default.- Returns:
- A task 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.
-
setClients
Sets the modifiable list of client connectors. This method clears the current list and adds all entries in the parameter list.- Parameters:
clients- A list of client connectors.
-
setContext
Description copied from class:RestletSets the context.- Overrides:
setContextin classRestlet- Parameters:
context- The context.
-
setDefaultHost
Sets the default virtual host.- Parameters:
defaultHost- The default virtual host.
-
setHosts
Sets the modifiable list of virtual hosts. Note that the order of virtual hosts in this list will be used to check the first one that matches. This method clears the current list and adds all entries in the parameter list.- Parameters:
hosts- A list of virtual hosts.
-
setInternalRouter
Sets the private internal router were Restlets like Applications can be attached.- Parameters:
internalRouter- The private internal router.- See Also:
-
setLogService
Sets the global log service.- Parameters:
logService- The global log service.
-
setRealms
Sets the list of realms. This method clears the current list and adds all entries in the parameter list.- Parameters:
realms- A list of realms.
-
setServers
Sets the modifiable list of server connectors. This method clears the current list and adds all entries in the parameter list.- Parameters:
servers- A list of server connectors.
-
setTaskService
Sets the task service.- Parameters:
taskService- The task service.
-
start
Starts the component. First it starts all the connectors (clients then servers), the routers, the services, the realms and then the component's internal helper. Finally, it calls the start method of the super class. -
startClients
Starts the client connectors.- Throws:
Exception
-
startHelper
Starts the internal helper allowing incoming requests to be served.- Throws:
Exception
-
startRealms
Starts the realms.- Throws:
Exception
-
startRouters
Starts the virtual hosts and the internal router.- Throws:
Exception
-
startServers
Starts the server connectors.- Throws:
Exception
-
startServices
Starts the associated services.- Throws:
Exception
-
stop
Stops the component. First it stops the component's internal helper, the realms, the services, the routers and then stops all the connectors (servers then clients) Finally it calls the stop method of the super class. -
stopClients
Stops the client connectors.- Throws:
Exception
-
stopHelper
Stops the internal helper allowing incoming requests to be served.- Throws:
Exception
-
stopRealms
Stops the realms.- Throws:
Exception
-
stopRouters
Stops the virtual hosts and the internal router.- Throws:
Exception
-
stopServers
Stops the server connectors.- Throws:
Exception
-
stopServices
Stops the associated services.- Throws:
Exception
-
updateHosts
Updates the component to take into account changes to the virtual hosts. This method doesn't stop the connectors or the applications or Restlets attached to the virtual hosts. It just updates the internal routes between the virtual hosts and the attached Restlets or applications.- Throws:
Exception
-