public class RestServer
extends HTTPServer
REST servers can always handle requests that target endpoints. Other kind of request are handles by custom request handlers.
EndpointHandler
,
RequestHandler
Constructor and Description |
---|
RestServer(int port,
int maxSimultaneousConnection,
int jobCountBySession)
Creates a new server bounded to given port.
|
RestServer(int port,
int maxSimultaneousConnection,
int jobCountBySession,
ServerSocketFactory serverSocketFactory)
Creates a REST server on top of the given HTTP server.
|
Modifier and Type | Method and Description |
---|---|
void |
addEndpoint(RestEndpoint endpoint)
Adds an endpoint to this server.
|
void |
addRequestResolver(RequestHandler handler)
Adds a request handler to this server.
|
List<RestEndpoint> |
getEndpoints()
Gets the list of active endpoints.
|
List<RequestHandler> |
getRequestResolvers()
Gets the list of active request handlers.
|
public RestServer(int port, int maxSimultaneousConnection, int jobCountBySession) throws IOException
This constructor looks for server socket service implementation using a Service Loader. The returned server socket will be used. If no service is declared, default implementation is used (Java standard server socket).
port
- the port.maxSimultaneousConnection
- the maximal number of simultaneously opened connections.jobCountBySession
- the number of parallel jobs to process by opened sessions.IOException
- if server cannot be bind to given port.public RestServer(int port, int maxSimultaneousConnection, int jobCountBySession, ServerSocketFactory serverSocketFactory) throws IOException
port
- the port.maxSimultaneousConnection
- the maximal number of simultaneously opened connections.jobCountBySession
- the number of parallel jobs to process by opened sessions.serverSocketFactory
- the serverSocketFactory to use.IOException
- if server cannot be bind to given port.public void addEndpoint(RestEndpoint endpoint)
endpoint
- the endpoint to add.public void addRequestResolver(RequestHandler handler)
handler
- the handler to add.public List<RestEndpoint> getEndpoints()
public List<RequestHandler> getRequestResolvers()
EndpointHandler