public class Component extends Restlet
Connector
s, VirtualHost
s,
Service
s and Application
s. 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. <?xml version="1.0"?> <component xmlns="http://www.restlet.org/schemas/2.0/Component"> <client protocol="CLAP" /> <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 and Description |
---|
Component()
Constructor.
|
Component(Reference xmlConfigRef)
Constructor with the reference to the XML configuration file.
|
Component(Representation xmlConfigRepresentation)
Constructor with the representation of the XML configuration file.
|
Component(String xmlConfigurationRef)
Constructor with the URI reference to the XML configuration file.
|
Modifier and Type | Method and Description |
---|---|
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 where Restlets like Applications can
be attached.
|
LogService |
getLogService()
Returns the global log service.
|
Realm |
getRealm(String name)
Finds the realm with the given name.
|
List<Realm> |
getRealms()
Returns the modifiable list of security realms.
|
ServerList |
getServers()
Returns the modifiable list of server connectors.
|
ServiceList |
getServices()
Returns the modifiable list of services.
|
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 the modifiable list of client connectors.
|
void |
setContext(Context context)
Sets the context.
|
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 |
setRealms(List<Realm> realms)
Sets the list of realms.
|
void |
setServers(ServerList servers)
Sets the 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 |
startRealms()
Starts the realms.
|
protected void |
startRouters()
Starts the virtual hosts and the internal router.
|
protected void |
startServers()
Starts the server connectors.
|
protected void |
startServices()
Starts the associated services.
|
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 |
stopRealms()
Stops the realms.
|
protected void |
stopRouters()
Stops the virtual hosts and the internal router.
|
protected void |
stopServers()
Stops the server connectors.
|
protected void |
stopServices()
Stops the associated services.
|
void |
updateHosts()
Updates the component to take into account changes to the virtual hosts.
|
createFinder, finalize, getApplication, getAuthor, getContext, getDescription, getFinderClass, getLogger, getName, getOwner, handle, handle, handle, isStarted, isStopped, setAuthor, setDescription, setFinderClass, setName, setOwner
public Component()
public Component(Reference xmlConfigRef)
xmlConfigRef
- The URI reference to the XML configuration file.public Component(Representation xmlConfigRepresentation)
xmlConfigRepresentation
- The representation of the XML configuration file.public Component(String xmlConfigurationRef)
xmlConfigurationRef
- The URI reference to the XML configuration file.public static void main(String[] args) throws Exception
args
- The list of in-line parameters.Exception
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.public LogService getLogService()
setLogService(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.public Realm getRealm(String name)
name
- The name.public List<Realm> getRealms()
public ServerList getServers()
public ServiceList getServices()
public StatusService getStatusService()
public void handle(Request request, Response response)
Restlet
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
.
Subclasses overriding this method should make sure that they call super.handle(request, response) before adding their own logic.
public void setClients(ClientList clients)
clients
- A list of client connectors.public void setContext(Context context)
Restlet
setContext
in class Restlet
context
- The context.public void setDefaultHost(VirtualHost defaultHost)
defaultHost
- The default virtual host.public void setHosts(List<VirtualHost> hosts)
hosts
- A 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 setRealms(List<Realm> realms)
realms
- A list of realms.public void setServers(ServerList servers)
servers
- A list of server connectors.public void setStatusService(StatusService statusService)
statusService
- The status service.public void start() throws Exception
start
in class Restlet
Exception
startClients()
,
startServers()
,
startRouters()
,
startServices()
,
startRealms()
,
startHelper()
protected void startClients() throws Exception
Exception
protected void startHelper() throws Exception
Exception
protected void startRouters() throws Exception
Exception
protected void startServers() throws Exception
Exception
protected void startServices() throws Exception
Exception
public void stop() throws Exception
stop
in class Restlet
Exception
stopHelper()
,
stopRealms()
,
stopServices()
,
stopRouters()
,
stopServers()
,
stopClients()
protected void stopClients() throws Exception
Exception
protected void stopHelper() throws Exception
Exception
protected void stopRouters() throws Exception
Exception
protected void stopServers() throws Exception
Exception
protected void stopServices() throws Exception
Exception
public void updateHosts() throws Exception
Exception
Copyright © 2005–2014. All rights reserved.