net.sf.jbaobab.io
Class ThreadedSocketPreparer

java.lang.Object
  extended by net.sf.jbaobab.io.AbstractManager<SocketChannel,SocketHandlerFactory>
      extended by net.sf.jbaobab.io.ThreadedSocketPreparer
All Implemented Interfaces:
Runnable, Manager<SocketChannel,SocketHandlerFactory>, Preparer<SocketAddress,SocketHandlerFactory>, SocketPreparer

public class ThreadedSocketPreparer
extends AbstractManager<SocketChannel,SocketHandlerFactory>
implements SocketPreparer

A SocketPreparer that creates SocketHandler instance on root executor (obtained with ExecutorPool.getRootExecutor()).

Author:
Oakyoon Cha
See Also:
SocketPreparer

Nested Class Summary
 class ThreadedSocketPreparer.SocketWorker
           
 
Nested classes/interfaces inherited from interface net.sf.jbaobab.io.SocketPreparer
SocketPreparer.NullSocketPreparer
 
Field Summary
protected  ExecutorService executor
           
protected  ChannelManager<SocketChannel> receiver
           
protected  ChannelManager<SocketChannel> sender
           
 
Fields inherited from interface net.sf.jbaobab.io.SocketPreparer
NULL
 
Constructor Summary
ThreadedSocketPreparer()
           
ThreadedSocketPreparer(ChannelManager<SocketChannel> receiver, ChannelManager<SocketChannel> sender)
           
 
Method Summary
 boolean hold(SocketChannel channel)
           
protected  void manage(SelectionKey key, SocketHandlerFactory factory)
           
 SelectionKey prepare(SocketAddress address, SocketHandlerFactory factory)
           
 SelectionKey register(SocketChannel channel, SocketHandlerFactory factory)
           
 boolean release(SocketChannel channel)
           
 
Methods inherited from class net.sf.jbaobab.io.AbstractManager
cancel, interestOps, interestOps, register, run, shutdown, start
 
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.Preparer
shutdown, start
 

Field Detail

receiver

protected ChannelManager<SocketChannel> receiver

sender

protected ChannelManager<SocketChannel> sender

executor

protected ExecutorService executor
Constructor Detail

ThreadedSocketPreparer

public ThreadedSocketPreparer(ChannelManager<SocketChannel> receiver,
                              ChannelManager<SocketChannel> sender)
                       throws IOException
Throws:
IOException

ThreadedSocketPreparer

public ThreadedSocketPreparer()
                       throws IOException
Throws:
IOException
Method Detail

register

public SelectionKey register(SocketChannel channel,
                             SocketHandlerFactory factory)
Specified by:
register in interface Manager<SocketChannel,SocketHandlerFactory>

hold

public boolean hold(SocketChannel channel)
Specified by:
hold in interface Manager<SocketChannel,SocketHandlerFactory>

release

public boolean release(SocketChannel channel)
Specified by:
release in interface Manager<SocketChannel,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<SocketChannel,SocketHandlerFactory>