|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.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 | |
java.lang.String |
getHost()
|
java.net.InetAddress |
getInetAddress()
|
InetAddrPort |
getInetAddrPort()
|
int |
getLingerTimeSecs()
|
int |
getMaxReadTimeMs()
|
int |
getPort()
|
java.net.ServerSocket |
getServerSocket()
|
void |
handle(java.lang.Object job)
Handle Job. |
void |
open()
Open the server socket. |
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 |
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.UnknownHostException
public 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 handle(java.lang.Object job)
handle
in class ThreadPool
job
- A Connection.public void open() throws java.io.IOException
java.io.IOException
- if an error occurspublic void start() throws java.lang.Exception
LifeCycle
start
in interface LifeCycle
start
in class ThreadPool
java.lang.Exception
- An arbitrary exception may be thrown.public void stop() throws java.lang.InterruptedException
ThreadPool
stop
in interface LifeCycle
stop
in class ThreadPool
java.lang.InterruptedException
- Stopping a lifecycle is rarely atomic
and may be interrupted by another thread. If this happens
InterruptedException is throw and the component will be in an
indeterminant state and should probably be discarded.public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |