org.mortbay.util
public abstract class ThreadedServer extends ThreadPool
The class is abstract and derived classes must provide the handling for the connections.
The properties THREADED_SERVER_MIN_THREADS and THREADED_SERVER_MAX_THREADS can be set to control the number of threads created.
Version: $Id: ThreadedServer.java,v 1.41 2005/12/10 00:38:20 gregwilkins Exp $
Constructor Summary | |
---|---|
ThreadedServer() | |
ThreadedServer(int port)
Construct for specific port. | |
ThreadedServer(InetAddress address, int port)
Construct for specific address and port. | |
ThreadedServer(String host, int port)
Construct for specific address and port. | |
ThreadedServer(InetAddrPort address)
Construct for specific address and port. |
Method Summary | |
---|---|
protected Socket | acceptSocket(ServerSocket ignored, int timeout)
Accept socket connection. |
protected Socket | acceptSocket(int timeout)
Accept socket connection. |
int | getAcceptorThreads()
Get the nmber of threads used to accept connections |
int | getAcceptQueueSize() |
String | getHost() |
InetAddress | getInetAddress() |
InetAddrPort | getInetAddrPort() |
int | getLingerTimeSecs() |
int | getMaxReadTimeMs() |
int | getPort() |
ServerSocket | getServerSocket() |
boolean | getTcpNoDelay() |
void | handle(Object job)
Handle Job. |
protected void | handleConnection(InputStream in, OutputStream out)
Handle new connection. |
protected void | handleConnection(Socket connection)
Handle new connection. |
protected ServerSocket | newServerSocket(InetAddrPort address, int acceptQueueSize)
New server socket. |
void | open()
Open the server socket. |
void | setAcceptorThreads(int n)
Set the number of threads used to accept connections. |
void | setAcceptQueueSize(int acceptQueueSize)
The size of the queue for unaccepted connections. |
void | setHost(String host) |
void | setInetAddress(InetAddress addr) |
void | setInetAddrPort(InetAddrPort address)
Set the server InetAddress and port.
|
void | setLingerTimeSecs(int ls) |
void | setMaxReadTimeMs(int ms)
Set Max Read Time.
|
void | setPort(int port) |
void | setTcpNoDelay(boolean tcpNoDelay) |
void | start() |
void | stop() |
protected void | stopJob(Thread thread, Object job)
Kill a job. |
String | toString() |
Deprecated: use acceptSocket(int timeout)
Accept socket connection. May be overriden by derived class to create specialist serversockets (eg SSL).Parameters: ignored timeout The time to wait for a connection. Normally passed the ThreadPool maxIdleTime.
Returns: Accepted Socket
Parameters: serverSocket timeout The time to wait for a connection. Normally passed the ThreadPool maxIdleTime.
Returns: Accepted Socket
Returns: Returns the acceptQueueSize or -1 if not set.
Returns: Host name
Returns: IP Address
Returns: IP Address and port in a new Instance of InetAddrPort.
Returns: seconds.
Returns: milliseconds
Returns: port number
Returns: The ServerSocket
Returns: true if setTcpNoDelay(true) is called on accepted sockets.
Parameters: job A Connection.
Parameters: address Address and port acceptQueueSize Accept queue size
Returns: The new ServerSocket
Throws: java.io.IOException
Throws: IOException if an error occurs
Parameters: acceptQueueSize The acceptQueueSize to set.
Parameters: host
Parameters: addr
Parameters: address The Address to listen on, or 0.0.0.0:port for all interfaces.
Parameters: ls seconds to linger or -1 to disable linger.
Deprecated: maxIdleTime is used instead.
Set Max Read Time.Parameters: port
Parameters: tcpNoDelay if true then setTcpNoDelay(true) is called on accepted sockets.
Parameters: thread job