|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.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.
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(InetAddrPort address,
int minThreads,
int maxThreads,
int maxIdleTime)
Constructor. |
|
ThreadedServer(int port)
Construct for specific port |
|
ThreadedServer(java.lang.String name)
|
Method Summary | |
protected java.net.Socket |
accept(java.net.ServerSocket serverSocket)
Accept socket connection. |
java.net.InetAddress |
address()
Deprecated. Use getInetAddress() |
java.net.InetAddress |
getInetAddress()
|
InetAddrPort |
getInetAddrPort()
|
int |
getMaxIdleTimeMs()
|
int |
getMaxSize()
|
int |
getMinSize()
|
int |
getPort()
|
int |
getSize()
|
protected void |
handleConnection(java.io.InputStream in,
java.io.OutputStream out)
Handle new connection This method should be overridden by the derived class to implement the required handling. |
protected void |
handleConnection(java.net.Socket connection)
Handle new connection If access is required to the actual socket, override this method instead of handleConnection(InputStream in,OutputStream out). |
void |
join()
|
protected java.net.ServerSocket |
newServerSocket(InetAddrPort address,
int acceptQueueSize)
New server socket. |
int |
port()
Deprecated. Use getPort() |
void |
run()
|
void |
setAddress(java.net.InetAddress address,
int port)
|
void |
setAddress(InetAddrPort address)
|
void |
setThreadClass(java.lang.Class threadClass)
Set the Thread class. |
void |
start()
|
void |
stop()
|
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Constructor Detail |
public ThreadedServer()
public ThreadedServer(java.lang.String name)
public ThreadedServer(int port) throws java.io.IOException
public ThreadedServer(java.net.InetAddress address, int port) throws java.io.IOException
public ThreadedServer(InetAddrPort address) throws java.io.IOException
public ThreadedServer(InetAddrPort address, int minThreads, int maxThreads, int maxIdleTime) throws java.io.IOException
address
- The address to listen onminThreads
- Minimum number of handler threads.maxThreads
- Maximum number of handler threads.maxIdleTime
- Idle time in milliseconds before a handler thread dies.Method Detail |
public void setThreadClass(java.lang.Class threadClass)
threadClass
- protected void handleConnection(java.io.InputStream in, java.io.OutputStream out)
protected void handleConnection(java.net.Socket connection)
public InetAddrPort getInetAddrPort()
public java.net.InetAddress address()
public java.net.InetAddress getInetAddress()
public int port()
public int getPort()
public int getSize()
public int getMinSize()
public int getMaxSize()
public int getMaxIdleTimeMs()
public void setAddress(java.net.InetAddress address, int port) throws java.io.IOException
public void setAddress(InetAddrPort address) throws java.io.IOException
protected java.net.ServerSocket newServerSocket(InetAddrPort address, int acceptQueueSize) throws java.io.IOException
address
- Address and portacceptQueueSize
- Accept queue sizeprotected java.net.Socket accept(java.net.ServerSocket serverSocket) throws java.io.IOException
serverSocket
- public void start() throws java.io.IOException
public void stop()
public final void join() throws java.lang.InterruptedException
public final void run()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |