org.d_haven.event.command
Class DefaultThreadManager

java.lang.Object
  extended by org.d_haven.event.command.DefaultThreadManager
All Implemented Interfaces:
ThreadManager

public class DefaultThreadManager
extends java.lang.Object
implements ThreadManager

The DefaultThreadManager is a very flexible implementation that should be able to solve just about any need. The ThreadManager portion of code manages the list of registered pipelines while the actual process of making events go through the pipeline is performed by the ThreadPolicy. The DefaultThreadManager will run all the events through all the pipelines in one background thread. If you supply a different ThreadPolicy, it will obey those rules.

Author:
Peter Royal, Berin Loritsch

Field Summary
private  java.util.List m_pipelines
           
private  ThreadPolicy m_policy
           
 
Constructor Summary
DefaultThreadManager()
          Create the DefaultThreadManager using the OneThreadPolicy as the way to run events through the pipelines.
DefaultThreadManager(ThreadPolicy policy)
          Create the DefaultThreadManager using the ThreadPolicy of your choice.
 
Method Summary
 java.util.Collection getRegisteredPipelines()
          Return a copy of all the pipelines registered at this point.
 void register(EventPipeline pipeline)
          Register an EventPipeline with the ThreadManager.
 void stop()
          Stop the ThreadManager from running the pipelines.
 java.lang.String toString()
           
 void unregister(EventPipeline pipeline)
          Unregister an EventPipeline with the ThreadManager.
 void unregisterAll()
          Unregisters all EventPipelines from this ThreadManager.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_pipelines

private final java.util.List m_pipelines

m_policy

private final ThreadPolicy m_policy
Constructor Detail

DefaultThreadManager

public DefaultThreadManager()
Create the DefaultThreadManager using the OneThreadPolicy as the way to run events through the pipelines. For small applications that handle only a few events, this is good enough.


DefaultThreadManager

public DefaultThreadManager(ThreadPolicy policy)
Create the DefaultThreadManager using the ThreadPolicy of your choice. The supplied ThreadPolicy will be used to run the events through all the pipelines.

Parameters:
policy - the ThreadPolicy to use
Method Detail

getRegisteredPipelines

public java.util.Collection getRegisteredPipelines()
Return a copy of all the pipelines registered at this point.

Specified by:
getRegisteredPipelines in interface ThreadManager
Returns:
a copy of the pipelines

register

public void register(EventPipeline pipeline)
Register an EventPipeline with the ThreadManager.

Specified by:
register in interface ThreadManager
Parameters:
pipeline - The pipeline to register

unregister

public void unregister(EventPipeline pipeline)
Unregister an EventPipeline with the ThreadManager.

Specified by:
unregister in interface ThreadManager
Parameters:
pipeline - The pipeline to unregister

unregisterAll

public void unregisterAll()
Unregisters all EventPipelines from this ThreadManager.

Specified by:
unregisterAll in interface ThreadManager

stop

public void stop()
Stop the ThreadManager from running the pipelines.

Specified by:
stop in interface ThreadManager

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object