|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.codehaus.spice.netserve.connection.impl.DefaultAcceptorManager
Default implementation of SocketAcceptorManager that uses a thread per acceptor approach.
Note that on some OS/JVM combinations soTimeout must be set to non-0 value or else the ServerSocket will never get out of accept() system call and we wont be able to shutdown the server socket properly. However it can introduce performance problems if constantly timing out.
Constructor Summary | |
DefaultAcceptorManager()
|
Method Summary | |
void |
connect(String name,
ServerSocket socket,
RequestHandler handler)
Start accepting connections from a socket and passing connections to specified handler. |
void |
disconnect(String name)
This shuts down the acceptor and the associated ServerSocket. |
protected AcceptorMonitor |
getMonitor()
Return the monitor used by manager. |
protected int |
getShutdownTimeout()
Return the shutdownTimeout. |
boolean |
isConnected(String name)
Return true if acceptor with specified name exists. |
void |
setMonitor(AcceptorMonitor monitor)
Set the AcceptorMonitor that receives events when changes occur. |
void |
setShutdownTimeout(int shutdownTimeout)
Set timeout for shutting down handlers. |
void |
setSoTimeout(int soTimeout)
Set the value that we are to set SO_TIMEOUT to if the user has not already set the timeout. |
void |
shutdownAcceptors()
Dispose the ConnectionManager which involves shutting down all the connected acceptors. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public DefaultAcceptorManager()
Method Detail |
public void setMonitor(AcceptorMonitor monitor)
monitor
- the AcceptorMonitor that receives events when
changes occur.public void setSoTimeout(int soTimeout)
soTimeout
- the timeout valuepublic void setShutdownTimeout(int shutdownTimeout)
shutdownTimeout
- the timeoutprotected int getShutdownTimeout()
public void shutdownAcceptors()
public void connect(String name, ServerSocket socket, RequestHandler handler) throws Exception
connect
in interface SocketAcceptorManager
name
- the name of connection. This serves as a key used to
shutdown acceptor.socket
- the ServerSocket from which connections are accepted
Exception
- if unable to initiate connection management. This could
be due to the key already being used for another acceptor,
the serversocket being closed, the handler being null etc.public boolean isConnected(String name)
isConnected
in interface SocketAcceptorManager
name
- the name
public void disconnect(String name)
disconnect
in interface SocketAcceptorManager
name
- the name of connection
IllegalArgumentException
- if no connection with specified nameprotected AcceptorMonitor getMonitor()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |