public class BaseServer extends Object
Constructor and Description |
---|
BaseServer(VinciServable my_servable)
Create a new BaseServer that will delegate requests to the provided servable.
|
Modifier and Type | Method and Description |
---|---|
protected void |
cleanExit()
Cleanly shut down this server.
|
protected ServerSocket |
createServerSocket(int port)
Create the server socket used to listen for requests.
|
Transportable |
eval(Transportable in,
KeyValuePair header)
This function is a callback for the (Base/Vinci)ServerRunnable.
|
protected Runnable |
getRunnable(Socket client)
Get a runnable object to run within a pooled thread that will handle the request.
|
VinciServable |
getServable()
Get the servable object being used by this server.
|
protected ServerSocket |
getServerSocket()
Get the server socket that this server uses to listen for requests.
|
protected void |
handleRequest(Socket client)
Initialize a new socket connection.
|
protected void |
handleRequests()
Enter the server socket accept() loop.
|
Transportable |
makeTransportable()
This is another callback for the (Base/Vinci)ServerRunnable that creates the document to be
populated by the service with the request response.
|
void |
serve(int port)
Serve requests, blocking until a clean shutdown is triggered.
|
void |
setSocketTimeout(int millis)
This method is used to override the default timeout value of one minute.
|
void |
setThreadPoolSize(int initial,
int max)
Set the intitial and maximum size of the threadpool used by this server.
|
void |
shutdownServing()
Cause the serve() method to terminate.
|
void |
startServing(int port)
Asynchronously start serving requests.
|
public BaseServer(VinciServable my_servable)
my_servable
- The servable object implementing the service.public VinciServable getServable()
public void setSocketTimeout(int millis) throws IOException
millis
- The socket timeout value in milliseconds.IOException
- -public void setThreadPoolSize(int initial, int max)
initial
- -max
- -public void startServing(int port) throws IOException
port
- The port on which to listen for requests.IOException
- Thrown if there was some problem with the server socket.public void serve(int port) throws IOException
port
- The port on which to listen for requests.IOException
- Thrown if there was some problem with the server socket.protected ServerSocket getServerSocket()
protected ServerSocket createServerSocket(int port) throws IOException
port
- The port which is to be listened to by the created socket.IOException
- -protected void handleRequests()
public void shutdownServing()
protected Runnable getRunnable(Socket client)
client
- -protected void handleRequest(Socket client)
client
- -protected void cleanExit()
public Transportable eval(Transportable in, KeyValuePair header)
in
- -header
- -public Transportable makeTransportable()
Copyright © 2016. All rights reserved.