public class Server extends Connector
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 and Description |
---|
Server(Context context,
java.util.List<Protocol> protocols,
int port,
Restlet next)
Constructor.
|
Server(Context context,
java.util.List<Protocol> protocols,
java.lang.String address,
int port,
Restlet next)
Constructor.
|
Server(Context context,
java.util.List<Protocol> protocols,
java.lang.String address,
int port,
Restlet next,
java.lang.String helperClass)
Constructor.
|
Server(Context context,
Protocol protocol)
Constructor.
|
Server(Context context,
Protocol protocol,
java.lang.Class<? extends ServerResource> nextClass)
Constructor.
|
Server(Context context,
Protocol protocol,
int port)
Constructor.
|
Server(Context context,
Protocol protocol,
int port,
java.lang.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,
java.lang.String address,
int port,
Restlet next)
Constructor.
|
Server(java.util.List<Protocol> protocols,
int port,
Restlet next)
Constructor.
|
Server(java.util.List<Protocol> protocols,
java.lang.String address,
int port,
Restlet next)
Constructor.
|
Server(Protocol protocol)
Constructor.
|
Server(Protocol protocol,
java.lang.Class<? extends ServerResource> nextClass)
Constructor using the protocol's default port.
|
Server(Protocol protocol,
int port)
Constructor.
|
Server(Protocol protocol,
int port,
java.lang.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,
java.lang.String address)
Constructor using the protocol's default port.
|
Server(Protocol protocol,
java.lang.String address,
java.lang.Class<? extends ServerResource> nextClass)
Constructor using the protocol's default port.
|
Server(Protocol protocol,
java.lang.String address,
int port)
Constructor.
|
Server(Protocol protocol,
java.lang.String address,
int port,
Restlet next)
Constructor.
|
Server(Protocol protocol,
java.lang.String address,
Restlet next)
Constructor using the protocol's default port.
|
Modifier and Type | Method and Description |
---|---|
int |
getActualPort()
Returns the actual server port after it has started.
|
java.lang.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(java.lang.String address)
Sets the optional listening IP address (local host used if null).
|
void |
setNext(java.lang.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.
|
getProtocols, setProtocols
createFinder, finalize, getApplication, getAuthor, getContext, getDescription, getFinderClass, getLogger, getName, getOwner, handle, handle, handle, isStarted, isStopped, setAuthor, setContext, setDescription, setFinderClass, setName, setOwner
public Server(Context context, java.util.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, java.util.List<Protocol> protocols, java.lang.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, java.util.List<Protocol> protocols, java.lang.String address, int port, Restlet next, java.lang.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, java.lang.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, java.lang.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, java.lang.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(java.util.List<Protocol> protocols, int port, Restlet next)
protocols
- The connector protocols.port
- The listening port.next
- The next Restlet.public Server(java.util.List<Protocol> protocols, java.lang.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, java.lang.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, java.lang.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, java.lang.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, java.lang.String address, java.lang.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, java.lang.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, java.lang.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, java.lang.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.public int getActualPort()
public java.lang.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.
public boolean hasNext()
public boolean isAvailable()
isAvailable
in class Connector
public void setAddress(java.lang.String address)
address
- The optional listening IP address (local host used if null).public void setNext(java.lang.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 java.lang.Exception
Restlet
public void stop() throws java.lang.Exception
Restlet
Copyright © 2005-2024 Restlet.