|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.abstracthorizon.danube.service.Service org.abstracthorizon.danube.service.server.ServerService org.abstracthorizon.danube.service.server.MultiThreadServerService org.abstracthorizon.danube.service.server.MultiThreadServerSocketChannelService
public class MultiThreadServerSocketChannelService
This is server service that is implemented using socket channels.
This service works in blocked IO mode and accepts connections from a
server socket channel, creates new ConnectionHandlerThread
objects
and executes them in a given thread by Executor
.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class org.abstracthorizon.danube.service.server.MultiThreadServerService |
---|
MultiThreadServerService.ConnectionHandlerThread |
Field Summary | |
---|---|
protected int |
newSocketTimeout
New socket timeout |
protected ServerSocketChannel |
serverSocketChannel
Reference to the server socket |
protected int |
serverSocketTimeout
Initial socket timeout |
Fields inherited from class org.abstracthorizon.danube.service.server.MultiThreadServerService |
---|
activeConnections, executor, graceFinishPeriod |
Fields inherited from class org.abstracthorizon.danube.service.server.ServerService |
---|
connectionHandler, socketAddress |
Fields inherited from class org.abstracthorizon.danube.service.Service |
---|
DESTROYED, INITIALIZED, listeners, logger, name, NOT_INITIALIZED, RUNNING, SERVICE_STATE_NAMES, STARTED, STOPPED, STOPPING, stopService |
Constructor Summary | |
---|---|
MultiThreadServerSocketChannelService()
Default constructor |
Method Summary | |
---|---|
void |
create()
Creates the socket |
protected void |
createServerSocket()
Creates server socket |
protected Connection |
createSocketConnection(SocketChannel socketChannel)
Creates new socket connection |
void |
destroy()
Closes the server socket |
protected void |
destroyServerSocket()
Closes server socket |
int |
getNewSocketTimeout()
Returns new socket timeout |
int |
getServerSocketTimeout()
Returns server socket timeout |
protected void |
processConnection(SocketChannel socketChannel)
Creates socket connection and new instance of ConnectionHandlerThread to process
socket under the given executor |
protected void |
processConnections()
This method processes connections |
void |
setNewSocketTimeout(int socketTimeout)
Sets new socket timeout |
void |
setServerSocketTimeout(int socketTimeout)
Sets initial socket timeout |
Methods inherited from class org.abstracthorizon.danube.service.server.MultiThreadServerService |
---|
getActiveConnections, getExecutor, getGraceFinishPeriod, getNumberOfActiveConnections, run, setExecutor, setGraceFinishPeriod, start, stop |
Methods inherited from class org.abstracthorizon.danube.service.server.ServerService |
---|
getAddress, getConnectionHandler, getPort, getSocketAddress, setAddress, setConnectionHandler, setPort, setSocketAddress |
Methods inherited from class org.abstracthorizon.danube.service.Service |
---|
addListener, changeState, getName, getState, getStateName, removeListener, setName |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected int serverSocketTimeout
protected int newSocketTimeout
protected ServerSocketChannel serverSocketChannel
Constructor Detail |
---|
public MultiThreadServerSocketChannelService()
Method Detail |
---|
public int getServerSocketTimeout()
public void setServerSocketTimeout(int socketTimeout)
socketTimeout
- initial socket timeoutpublic int getNewSocketTimeout()
public void setNewSocketTimeout(int socketTimeout)
socketTimeout
- new socket timeoutpublic void create() throws ServiceException
create
in class Service
ServiceException
public void destroy() throws ServiceException
destroy
in class Service
ServiceException
protected void processConnections()
processConnections
in class MultiThreadServerService
protected void createServerSocket() throws ServiceException
ServiceException
protected void destroyServerSocket() throws ServiceException
ServiceException
protected void processConnection(SocketChannel socketChannel)
ConnectionHandlerThread
to process
socket under the given executor
socketChannel
- socket channelprotected Connection createSocketConnection(SocketChannel socketChannel) throws IOException
socketChannel
- socket channel
IOException
Exception
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |