com.flat502.rox.processing
Class ResourcePool

java.lang.Object
  extended by com.flat502.rox.processing.ResourcePool
Direct Known Subclasses:
ClientResourcePool, ServerResourcePool

public abstract class ResourcePool
extends java.lang.Object


Constructor Summary
protected ResourcePool()
           
 
Method Summary
 int addWorker()
          Create a new worker instance and add it to the underlying thread pool.
 int addWorkers(int count)
          A convenience method for adding multiple worker threads in a single call.
protected  void detach(HttpRpcProcessor processor)
           
protected  com.flat502.rox.processing.ChannelSelector getChannelSelector()
           
protected  ProfilerCollection getProfilers()
           
 BlockingQueue getQueue()
           
protected  java.util.Timer getTimer()
           
 int getWorkerCount()
          Get the number of worker threads currently responsible for this instance.
protected  com.flat502.rox.processing.ChannelSelector newChannelSelector()
           
protected  java.lang.Thread newProcessingThread(java.lang.Runnable target)
          A factory method for creating the central HTTP processing thread.
protected  BlockingQueue newQueue()
           
protected abstract  HttpMessageHandler newWorker()
           
protected  void notifyUnownedChannelClosure(java.nio.channels.SocketChannel channel)
           
 void registerProfiler(Profiler p)
           
 int removeWorker()
           
 void shutdown()
           
protected  void startProcessingThread()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResourcePool

protected ResourcePool()
Method Detail

getChannelSelector

protected com.flat502.rox.processing.ChannelSelector getChannelSelector()
                                                                 throws java.io.IOException
Throws:
java.io.IOException

getTimer

protected java.util.Timer getTimer()

startProcessingThread

protected void startProcessingThread()

getQueue

public BlockingQueue getQueue()

shutdown

public void shutdown()

addWorker

public int addWorker()
Create a new worker instance and add it to the underlying thread pool.

Worker threads are responsible for handling complete HTTP messages. All I/O is handled by this thread instance alone.

If an instance of this class is constructed and started without this method having been invoked it will be invoked before processing begins.

Returns:
The number of worker threads backing this instance.

addWorkers

public int addWorkers(int count)
A convenience method for adding multiple worker threads in a single call.

Parameters:
count - The number of worker threads to add.
Returns:
The number of worker threads backing this instance.

getWorkerCount

public int getWorkerCount()
Get the number of worker threads currently responsible for this instance.

Returns:
The number of worker threads backing this instance.

removeWorker

public int removeWorker()

registerProfiler

public void registerProfiler(Profiler p)

getProfilers

protected ProfilerCollection getProfilers()

newWorker

protected abstract HttpMessageHandler newWorker()

newProcessingThread

protected java.lang.Thread newProcessingThread(java.lang.Runnable target)
A factory method for creating the central HTTP processing thread.

Sub-classes may override this method if an alternative implementation is required, or to alter properties of the thread that is created by default, but they should not invoke the Thread.start() method.

Parameters:
target -
Returns:
This implementation returns a new instance of HttpRpcProcessor.

newChannelSelector

protected com.flat502.rox.processing.ChannelSelector newChannelSelector()
                                                                 throws java.io.IOException
Throws:
java.io.IOException

detach

protected void detach(HttpRpcProcessor processor)
               throws java.io.IOException
Throws:
java.io.IOException

notifyUnownedChannelClosure

protected void notifyUnownedChannelClosure(java.nio.channels.SocketChannel channel)

newQueue

protected BlockingQueue newQueue()