|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.restlet.Uniform
org.restlet.Restlet
org.restlet.Component
public class Component
Restlet managing a set of Connectors, VirtualHosts and Applications.
Applications are expected to be directly attached to VirtualHosts. 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
The configuration of a Component can be done programmatically or by using a
XML document. There is a dedicated constructor that accepts an URI reference
to such XML document, allowing easy configuration of the list of supported
client and server connectors as well as services. In addition, you can add
and configure virtual hosts (including the default one). Finally, you can
attach applications either using their fully qualified class name or by
pointing to a descriptor document (at this time only WADL description are
supported, see the WADL Restlet extension for details).
The XML Schema of the configuration files is available both online and inside
the API JAR under the "org.restlet.Component.xsd" name.
Here is a sample of XML configuration:
<?xml version="1.0"?>
<component xmlns="http://www.restlet.org/schemas/1.1/Component"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.restlet.org/schemas/1.1/Component">
<client protocol="FILE" />
<client protocols="HTTP HTTPS" />
<server protocols="HTTP HTTPS" />
<defaultHost>
<attach uriPattern="/abcd/{xyz}"
targetClass="org.restlet.test.MyApplication" />
<attach uriPattern="/efgh/{xyz}"
targetDescriptor="clap://class/org.restlet.test.MyApplication.wadl" />
</defaultHost>
</component>
| Constructor Summary | |
|---|---|
Component()
Constructor. |
|
Component(Reference xmlConfigReference)
Parse a configuration file and update the component's configuration. |
|
| Method Summary | |
|---|---|
ClientList |
getClients()
Returns a modifiable list of client connectors. |
VirtualHost |
getDefaultHost()
Returns the default virtual host. |
List<VirtualHost> |
getHosts()
Returns the modifiable list of virtual hosts. |
Router |
getInternalRouter()
Returns the private internal router were Restlets like Applications can be attached. |
LogService |
getLogService()
Returns the global log service. |
ServerList |
getServers()
Returns the modifiable list of server connectors. |
StatusService |
getStatusService()
Returns the status service, enabled by default. |
void |
handle(Request request,
Response response)
Handles a call. |
static void |
main(String[] args)
Used as bootstrap for configuring and running a component in command line. |
void |
setClients(ClientList clients)
Sets a modifiable list of client connectors. |
void |
setDefaultHost(VirtualHost defaultHost)
Sets the default virtual host. |
void |
setHosts(List<VirtualHost> hosts)
Sets the modifiable list of virtual hosts. |
void |
setInternalRouter(Router internalRouter)
Sets the private internal router were Restlets like Applications can be attached. |
void |
setLogService(LogService logService)
Sets the global log service. |
void |
setServers(ServerList servers)
Sets a modifiable list of server connectors. |
void |
setStatusService(StatusService statusService)
Sets the status service. |
void |
start()
Starts the component. |
protected void |
startClients()
Starts the client connectors. |
protected void |
startHelper()
Starts the internal helper allowing incoming requests to be served. |
protected void |
startServers()
Starts the server connectors. |
void |
stop()
Stops the component. |
protected void |
stopClients()
Stops the client connectors. |
protected void |
stopHelper()
Stops the internal helper allowing incoming requests to be served. |
protected void |
stopServers()
Stops the server connectors. |
void |
updateHosts()
Updates the component to take into account changes to the virtual hosts. |
| 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 |
|---|
public Component()
public Component(Reference xmlConfigReference)
xmlConfigReference - The reference to the XML config file.| Method Detail |
|---|
public ClientList getClients()
public VirtualHost getDefaultHost()
public List<VirtualHost> getHosts()
public Router getInternalRouter()
Protocol.RIAP (Restlet Internal Access Protocol)
client connector. This is used to manage private, internal and optimized
access to local applications.Context.getServerDispatcher() method, but the internal router is
easily addressable via an URI scheme and can be fully private to the
current Component.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.
public LogService getLogService()
setLogService(LogService) method, then a default
logger service is created. This default service is enabled by default and
has a logger name composed of the canonical name of the current
component's class or subclass, appended with the instance hash code
between parenthesis (eg. "com.mycompany.MyComponent(1439)").
public ServerList getServers()
public StatusService getStatusService()
public void handle(Request request,
Response response)
RestletRestlet.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.
handle in class Restletrequest - The request to handle.response - The response to update.public void setClients(ClientList clients)
clients - A modifiable list of client connectors.public void setDefaultHost(VirtualHost defaultHost)
defaultHost - The default virtual host.public void setHosts(List<VirtualHost> hosts)
hosts - The modifiable list of virtual hosts.public void setInternalRouter(Router internalRouter)
internalRouter - The private internal router.getInternalRouter()public void setLogService(LogService logService)
logService - The global log service.public void setServers(ServerList servers)
servers - A modifiable list of server connectors.public void setStatusService(StatusService statusService)
statusService - The status service.
public void start()
throws Exception
start in class RestletExceptionstartClients(),
startServers(),
startHelper()
protected void startClients()
throws Exception
Exception
protected void startHelper()
throws Exception
Exception
protected void startServers()
throws Exception
Exception
public void stop()
throws Exception
stop in class RestletExceptionstopHelper(),
stopServers(),
stopClients()
protected void stopClients()
throws Exception
Exception
protected void stopHelper()
throws Exception
Exception
protected void stopServers()
throws Exception
Exception
public void updateHosts()
throws Exception
Exception
public static void main(String[] args)
throws Exception
args - The list of in-line parameters.
Exception
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||