net.sf.jbaobab.io
Class ThreadedSocketPool
java.lang.Object
net.sf.jbaobab.io.AbstractManager<ServerSocketChannel,SocketHandlerFactory>
net.sf.jbaobab.io.ThreadedSocketPool
- All Implemented Interfaces:
- Runnable, Manager<ServerSocketChannel,SocketHandlerFactory>, Preparer<SocketAddress,SocketHandlerFactory>, SocketPool, SocketPreparer
public class ThreadedSocketPool
- extends AbstractManager<ServerSocketChannel,SocketHandlerFactory>
- implements SocketPool
A SocketPool
that creates SocketHandler
instance on root
executor (obtained with
ExecutorPool.getRootExecutor()
). Delegates
SocketPreparer
jobs to given instance on constructor. If no
SocketPreparer
instance is given
prepare(SocketAddress, SocketHandlerFactory)
will throw
UnsupportedOperationException
.
- Author:
- Oakyoon Cha
- See Also:
SocketPreparer
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface net.sf.jbaobab.io.Manager |
cancel |
receiver
protected ChannelManager<SocketChannel> receiver
sender
protected ChannelManager<SocketChannel> sender
preparer
protected SocketPreparer preparer
executor
protected ExecutorService executor
ThreadedSocketPool
public ThreadedSocketPool(ChannelManager<SocketChannel> receiver,
ChannelManager<SocketChannel> sender,
SocketPreparer preparer)
throws IOException
- Throws:
IOException
ThreadedSocketPool
public ThreadedSocketPool(ChannelManager<SocketChannel> receiver,
ChannelManager<SocketChannel> sender)
throws IOException
- Throws:
IOException
ThreadedSocketPool
public ThreadedSocketPool(SocketPreparer preparer)
throws IOException
- Throws:
IOException
ThreadedSocketPool
public ThreadedSocketPool()
throws IOException
- Throws:
IOException
register
public SelectionKey register(ServerSocketChannel channel,
SocketHandlerFactory factory)
- Specified by:
register
in interface Manager<ServerSocketChannel,SocketHandlerFactory>
hold
public boolean hold(ServerSocketChannel channel)
- Specified by:
hold
in interface Manager<ServerSocketChannel,SocketHandlerFactory>
release
public boolean release(ServerSocketChannel channel)
- Specified by:
release
in interface Manager<ServerSocketChannel,SocketHandlerFactory>
prepare
public SelectionKey prepare(SocketAddress address,
SocketHandlerFactory factory)
- Specified by:
prepare
in interface Preparer<SocketAddress,SocketHandlerFactory>
manage
protected void manage(SelectionKey key,
SocketHandlerFactory factory)
- Specified by:
manage
in class AbstractManager<ServerSocketChannel,SocketHandlerFactory>
start
public void start()
- Specified by:
start
in interface Manager<ServerSocketChannel,SocketHandlerFactory>
- Specified by:
start
in interface Preparer<SocketAddress,SocketHandlerFactory>
- Overrides:
start
in class AbstractManager<ServerSocketChannel,SocketHandlerFactory>
shutdown
public void shutdown()
- Specified by:
shutdown
in interface Manager<ServerSocketChannel,SocketHandlerFactory>
- Specified by:
shutdown
in interface Preparer<SocketAddress,SocketHandlerFactory>
- Overrides:
shutdown
in class AbstractManager<ServerSocketChannel,SocketHandlerFactory>