public class Server extends Connector
Constructor and Description |
---|
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,
Class<?> nextClass)
Constructor.
|
Server(Context context,
Protocol protocol,
int port)
Constructor.
|
Server(Context context,
Protocol protocol,
int port,
Class<?> 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<?> nextClass)
Constructor using the protocol's default port.
|
Server(Protocol protocol,
int port)
Constructor.
|
Server(Protocol protocol,
int port,
Class<?> 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<?> 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.
|
Modifier and Type | Method and Description |
---|---|
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.
|
Restlet |
getTarget()
Deprecated.
Use the
getNext() method instead. |
void |
handle(Request request,
Response response)
Handles a call.
|
boolean |
hasNext()
Indicates if a next Restlet is set.
|
boolean |
hasTarget()
Deprecated.
Use the
hasNext() method instead. |
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<?> 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 |
setTarget(Restlet next)
Deprecated.
Use the
setNext(Restlet) method instead. |
void |
start()
Starts the Restlet.
|
void |
stop()
Stops the Restlet.
|
getProtocols, setProtocols
finalize, getApplication, getAuthor, getContext, getDescription, getLogger, getName, getOwner, isStarted, isStopped, setAuthor, setContext, setDescription, setName, setOwner
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, Class<?> 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<?> 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<?> 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<?> 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<?> 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.public String getAddress()
public int getEphemeralPort()
public Restlet getNext()
public int getPort()
@Deprecated public Restlet getTarget()
getNext()
method instead.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()
@Deprecated public boolean hasTarget()
hasNext()
method instead.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<?> 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.@Deprecated public void setTarget(Restlet next)
setNext(Restlet)
method instead.next
- The next Restlet.public void start() throws Exception
Restlet
Copyright © 2005–2016. All rights reserved.