|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.vinci.transport.BaseServer
public class BaseServer
Class for running VinciServables in the Vinci framework. This implementation supports multiple concurrent clients (in a Thread per client manner). Creating a service typically requires defining implementing a VinciServable which is passed to this class to service requests. This class can be used independently of VNS. For VNS-enhanced serving, use the VinciServer. This class is designed to be extensible. For example you can extend to provide new Runnable objects that are used to handle requests in the appropriate fashion. You can also override configure socket to install SSL-supporting server sockets, and so on...
Constructor Summary | |
---|---|
BaseServer(VinciServable my_servable)
Create a new BaseServer that will delegate requests to the provided servable. |
Method Summary | |
---|---|
protected void |
cleanExit()
Cleanly shut down this server. |
protected java.net.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 java.lang.Runnable |
getRunnable(java.net.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 java.net.ServerSocket |
getServerSocket()
Get the server socket that this server uses to listen for requests. |
protected void |
handleRequest(java.net.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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public BaseServer(VinciServable my_servable)
my_servable
- The servable object implementing the service.Method Detail |
---|
public VinciServable getServable()
public void setSocketTimeout(int millis) throws java.io.IOException
millis
- The socket timeout value in milliseconds.
java.io.IOException
public void setThreadPoolSize(int initial, int max)
public void startServing(int port) throws java.io.IOException
port
- The port on which to listen for requests.
java.io.IOException
- Thrown if there was some problem with the server socket.public void serve(int port) throws java.io.IOException
port
- The port on which to listen for requests.
java.io.IOException
- Thrown if there was some problem with the server socket.protected java.net.ServerSocket getServerSocket()
protected java.net.ServerSocket createServerSocket(int port) throws java.io.IOException
port
- The port which is to be listened to by the created socket.
java.io.IOException
protected void handleRequests()
public void shutdownServing()
protected java.lang.Runnable getRunnable(java.net.Socket client)
protected void handleRequest(java.net.Socket client)
protected void cleanExit()
public Transportable eval(Transportable in, KeyValuePair header)
public Transportable makeTransportable()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |