|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.restlet.Restlet
org.restlet.Connector
org.restlet.Server
public class Server
Connector acting as a generic server. It internally uses one of the available
connector helpers registered with the Restlet engine.
Concurrency note: instances of this class or its subclasses can be invoked by
several threads at the same time and therefore must be thread-safe. You
should be especially careful when storing state in member variables.
For advanced cases, it is possible to obtained the wrapped
RestletHelper
instance that is used by this client to handle the
calls via the "org.restlet.engine.helper" attribute stored in the
Context
object.
Constructor Summary | |
---|---|
Server(Context context,
List<Protocol> protocols,
int port,
Restlet next)
Constructor. |
|
Server(Context context,
List<Protocol> protocols,
String address,
int port,
Restlet next)
Constructor. |
|
Server(Context context,
List<Protocol> protocols,
String address,
int port,
Restlet next,
String helperClass)
Constructor. |
|
Server(Context context,
Protocol protocol)
Constructor. |
|
Server(Context context,
Protocol protocol,
Class<? extends ServerResource> nextClass)
Constructor. |
|
Server(Context context,
Protocol protocol,
int port)
Constructor. |
|
Server(Context context,
Protocol protocol,
int port,
Class<? extends ServerResource> nextClass)
Constructor. |
|
Server(Context context,
Protocol protocol,
int port,
Restlet next)
Constructor. |
|
Server(Context context,
Protocol protocol,
Restlet next)
Constructor using the protocol's default port. |
|
Server(Context context,
Protocol protocol,
String address,
int port,
Restlet next)
Constructor. |
|
Server(List<Protocol> protocols,
int port,
Restlet next)
Constructor. |
|
Server(List<Protocol> protocols,
String address,
int port,
Restlet next)
Constructor. |
|
Server(Protocol protocol)
Constructor. |
|
Server(Protocol protocol,
Class<? extends ServerResource> nextClass)
Constructor using the protocol's default port. |
|
Server(Protocol protocol,
int port)
Constructor. |
|
Server(Protocol protocol,
int port,
Class<? extends ServerResource> nextClass)
Constructor. |
|
Server(Protocol protocol,
int port,
Restlet next)
Constructor. |
|
Server(Protocol protocol,
Restlet next)
Constructor using the protocol's default port. |
|
Server(Protocol protocol,
String address)
Constructor using the protocol's default port. |
|
Server(Protocol protocol,
String address,
Class<? extends ServerResource> nextClass)
Constructor using the protocol's default port. |
|
Server(Protocol protocol,
String address,
int port)
Constructor. |
|
Server(Protocol protocol,
String address,
int port,
Restlet next)
Constructor. |
|
Server(Protocol protocol,
String address,
Restlet next)
Constructor using the protocol's default port. |
Method Summary | |
---|---|
int |
getActualPort()
Returns the actual server port after it has started. |
String |
getAddress()
Returns the optional listening IP address (local host used if null). |
int |
getEphemeralPort()
Returns the actual ephemeral port used when the listening port is set to '0'. |
Restlet |
getNext()
Returns the next Restlet. |
int |
getPort()
Returns the listening port if specified. |
void |
handle(Request request,
Response response)
Handles a call. |
boolean |
hasNext()
Indicates if a next Restlet is set. |
boolean |
isAvailable()
Indicates the underlying connector helper is available. |
void |
setAddress(String address)
Sets the optional listening IP address (local host used if null). |
void |
setNext(Class<? extends ServerResource> nextClass)
Sets the next Restlet as a Finder for a given resource class. |
void |
setNext(Restlet next)
Sets the next Restlet. |
protected void |
setPort(int port)
Sets the listening port if specified. |
void |
start()
Starts the Restlet. |
void |
stop()
Stops the Restlet. |
Methods inherited from class org.restlet.Connector |
---|
getProtocols, setProtocols |
Methods inherited from class org.restlet.Restlet |
---|
createFinder, finalize, getApplication, getAuthor, getContext, getDescription, getFinderClass, getLogger, getName, getOwner, handle, handle, handle, isStarted, isStopped, setAuthor, setContext, setDescription, setFinderClass, setName, setOwner |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Server(Context context, List<Protocol> protocols, int port, Restlet next)
context
- The context.protocols
- The connector protocols.port
- The listening port.next
- The next Restlet.public Server(Context context, List<Protocol> protocols, String address, int port, Restlet next)
context
- The context.protocols
- The connector protocols.address
- The optional listening IP address (useful if multiple IP
addresses available). You can also use a domain name as an
alias for the IP address to listen to.port
- The listening port.next
- The next Restlet.public Server(Context context, List<Protocol> protocols, String address, int port, Restlet next, String helperClass)
context
- The context.protocols
- The connector protocols.address
- The optional listening IP address (useful if multiple IP
addresses available). You can also use a domain name as an
alias for the IP address to listen to.port
- The listening port.next
- The next Restlet.helperClass
- Optional helper class name.public Server(Context context, Protocol protocol)
context
- The parent context.protocol
- The connector protocol.public Server(Context context, Protocol protocol, Class<? extends ServerResource> nextClass)
context
- The context.protocol
- The connector protocol.nextClass
- The next server resource.public Server(Context context, Protocol protocol, int port)
context
- The parent context.protocol
- The connector protocol.port
- The listening port.public Server(Context context, Protocol protocol, int port, Class<? extends ServerResource> nextClass)
context
- The context.protocol
- The connector protocol.port
- The listening port.nextClass
- The next server resource.public Server(Context context, Protocol protocol, int port, Restlet next)
context
- The context.protocol
- The connector protocol.port
- The listening port.next
- The next Restlet.public Server(Context context, Protocol protocol, Restlet next)
context
- The context.protocol
- The connector protocol.next
- The next Restlet.public Server(Context context, Protocol protocol, String address, int port, Restlet next)
context
- The context.protocol
- The connector protocol.address
- The optional listening IP address (useful if multiple IP
addresses available). You can also use a domain name as an
alias for the IP address to listen to.port
- The listening port.next
- The next Restlet.public Server(List<Protocol> protocols, int port, Restlet next)
protocols
- The connector protocols.port
- The listening port.next
- The next Restlet.public Server(List<Protocol> protocols, String address, int port, Restlet next)
protocols
- The connector protocols.address
- The optional listening IP address (useful if multiple IP
addresses available). You can also use a domain name as an
alias for the IP address to listen to.port
- The listening port.next
- The next Restlet.public Server(Protocol protocol)
protocol
- The connector protocol.public Server(Protocol protocol, Class<? extends ServerResource> nextClass)
protocol
- The connector protocol.nextClass
- The next server resource.public Server(Protocol protocol, int port)
protocol
- The connector protocol.port
- The listening port.public Server(Protocol protocol, int port, Class<? extends ServerResource> nextClass)
protocol
- The connector protocol.port
- The listening port.nextClass
- The next server resource.public Server(Protocol protocol, int port, Restlet next)
protocol
- The connector protocol.port
- The listening port.next
- The next Restlet.public Server(Protocol protocol, Restlet next)
protocol
- The connector protocol.next
- The next Restlet.public Server(Protocol protocol, String address)
protocol
- The connector protocol.address
- The listening IP address (useful if multiple IP addresses
available). You can also use a domain name as an alias for the
IP address to listen to.public Server(Protocol protocol, String address, Class<? extends ServerResource> nextClass)
protocol
- The connector protocol.address
- The listening IP address (useful if multiple IP addresses
available). You can also use a domain name as an alias for the
IP address to listen to.nextClass
- The next server resource.public Server(Protocol protocol, String address, int port)
protocol
- The connector protocol.address
- The optional listening IP address (useful if multiple IP
addresses available). You can also use a domain name as an
alias for the IP address to listen to.port
- The listening port.public Server(Protocol protocol, String address, int port, Restlet next)
protocol
- The connector protocol.address
- The optional listening IP address (useful if multiple IP
addresses available). You can also use a domain name as an
alias for the IP address to listen to.port
- The listening port.next
- The next Restlet.public Server(Protocol protocol, String address, Restlet next)
protocol
- The connector protocol.address
- The listening IP address (useful if multiple IP addresses
available). You can also use a domain name as an alias for the
IP address to listen to.next
- The next Restlet.Method Detail |
---|
public int getActualPort()
public String getAddress()
public int getEphemeralPort()
public Restlet getNext()
public int getPort()
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.
handle
in interface Uniform
handle
in class Restlet
request
- The request to handle.response
- The response to update.public boolean hasNext()
public boolean isAvailable()
isAvailable
in class Connector
public void setAddress(String address)
address
- The optional listening IP address (local host used if null).public void setNext(Class<? extends ServerResource> nextClass)
nextClass
- The next resource class to attach.public void setNext(Restlet next)
next
- The next Restlet.protected void setPort(int port)
getEphemeralPort()
method.
port
- The listening port if specified.public void start() throws Exception
Restlet
start
in class Restlet
Exception
public void stop() throws Exception
Restlet
stop
in class Restlet
Exception
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |