|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.mortbay.util.ThreadPool
org.mortbay.util.ThreadedServer
Threaded socket server. This class listens at a socket and gives the connections received to a pool of Threads
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.
| Nested Class Summary |
| Nested classes inherited from class org.mortbay.util.ThreadPool |
ThreadPool.PoolThread |
| Field Summary |
| Fields inherited from class org.mortbay.util.ThreadPool |
__DAEMON, __PRIORITY |
| Constructor Summary | |
ThreadedServer()
|
|
ThreadedServer(java.net.InetAddress address,
int port)
Construct for specific address and port. |
|
ThreadedServer(InetAddrPort address)
Construct for specific address and port. |
|
ThreadedServer(int port)
Construct for specific port. |
|
ThreadedServer(java.lang.String host,
int port)
Construct for specific address and port. |
|
| Method Summary | |
int |
getAcceptorThreads()
Get the nmber of threads used to accept connections |
int |
getAcceptQueueSize()
|
java.lang.String |
getHost()
|
java.net.InetAddress |
getInetAddress()
|
InetAddrPort |
getInetAddrPort()
|
int |
getLingerTimeSecs()
|
int |
getMaxReadTimeMs()
|
int |
getPort()
|
java.net.ServerSocket |
getServerSocket()
|
boolean |
getTcpNoDelay()
|
void |
handle(java.lang.Object job)
Handle Job. |
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(java.lang.String host)
|
void |
setInetAddress(java.net.InetAddress addr)
|
void |
setInetAddrPort(InetAddrPort address)
Set the server InetAddress and port. |
void |
setLingerTimeSecs(int ls)
|
void |
setMaxReadTimeMs(int ms)
Deprecated. maxIdleTime is used instead. |
void |
setPort(int port)
|
void |
setTcpNoDelay(boolean tcpNoDelay)
|
void |
start()
Start the LifeCycle. |
void |
stop()
Stop the ThreadPool. |
java.lang.String |
toString()
|
| Methods inherited from class org.mortbay.util.ThreadPool |
getIdleThreads, getMaxIdleTimeMs, getMaxThreads, getMinThreads, getName, getPoolName, getThreads, getThreadsPriority, isDaemon, isStarted, join, run, setDaemon, setMaxIdleTimeMs, setMaxStopTimeMs, setMaxThreads, setMinThreads, setName, setPoolName, setThreadsPriority, shrink |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
public ThreadedServer()
public ThreadedServer(int port)
public ThreadedServer(java.net.InetAddress address,
int port)
public ThreadedServer(java.lang.String host,
int port)
throws java.net.UnknownHostException
public ThreadedServer(InetAddrPort address)
| Method Detail |
public java.net.ServerSocket getServerSocket()
public void setInetAddrPort(InetAddrPort address)
address - The Address to listen on, or 0.0.0.0:port for all interfaces.public InetAddrPort getInetAddrPort()
public void setHost(java.lang.String host)
throws java.net.UnknownHostException
host -
java.net.UnknownHostExceptionpublic java.lang.String getHost()
public void setInetAddress(java.net.InetAddress addr)
addr - public java.net.InetAddress getInetAddress()
public void setPort(int port)
port - public int getPort()
public void setMaxReadTimeMs(int ms)
public int getMaxReadTimeMs()
public void setLingerTimeSecs(int ls)
ls - seconds to linger or -1 to disable linger.public int getLingerTimeSecs()
public void setTcpNoDelay(boolean tcpNoDelay)
tcpNoDelay - if true then setTcpNoDelay(true) is called on accepted sockets.public boolean getTcpNoDelay()
public int getAcceptQueueSize()
public void setAcceptQueueSize(int acceptQueueSize)
acceptQueueSize - The acceptQueueSize to set.public void setAcceptorThreads(int n)
public int getAcceptorThreads()
public void handle(java.lang.Object job)
job - A Connection.
public void open()
throws java.io.IOException
java.io.IOException - if an error occurs
public void start()
throws java.lang.Exception
LifeCycle
start in interface LifeCyclestart in class ThreadPooljava.lang.Exception
public void stop()
throws java.lang.InterruptedException
ThreadPool
stop in interface LifeCyclestop in class ThreadPooljava.lang.InterruptedExceptionpublic java.lang.String toString()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||