|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.openqa.jetty.util.ThreadPool org.openqa.jetty.util.ThreadedServer
public abstract class 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/interfaces inherited from class org.openqa.jetty.util.ThreadPool |
---|
ThreadPool.PoolThread |
Field Summary |
---|
Fields inherited from class org.openqa.jetty.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 | |
---|---|
protected java.net.Socket |
acceptSocket(int timeout)
Accept socket connection. |
protected java.net.Socket |
acceptSocket(java.net.ServerSocket ignored,
int timeout)
Deprecated. use acceptSocket(int timeout) |
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. |
protected void |
handleConnection(java.io.InputStream in,
java.io.OutputStream out)
Handle new connection. |
protected void |
handleConnection(java.net.Socket connection)
Handle new connection. |
protected java.net.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(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. |
protected void |
stopJob(java.lang.Thread thread,
java.lang.Object job)
Kill a job. |
java.lang.String |
toString()
|
Methods inherited from class org.openqa.jetty.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 |
---|
clone, equals, finalize, 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
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 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()
protected void handleConnection(java.io.InputStream in, java.io.OutputStream out)
protected void handleConnection(java.net.Socket connection) throws java.io.IOException
java.io.IOException
public void handle(java.lang.Object job)
handle
in class ThreadPool
job
- A Connection.protected java.net.ServerSocket newServerSocket(InetAddrPort address, int acceptQueueSize) throws java.io.IOException
address
- Address and portacceptQueueSize
- Accept queue size
java.io.IOException
protected java.net.Socket acceptSocket(java.net.ServerSocket ignored, int timeout)
ignored
- timeout
- The time to wait for a connection. Normally passed the ThreadPool maxIdleTime.
protected java.net.Socket acceptSocket(int timeout)
serverSocket
- timeout
- The time to wait for a connection. Normally passed the ThreadPool maxIdleTime.
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.protected void stopJob(java.lang.Thread thread, java.lang.Object job)
stopJob
in class ThreadPool
thread
- job
- 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 |