org.d_haven.event.command

Class DefaultThreadManager

public class DefaultThreadManager extends 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
Listm_pipelines
ThreadPolicym_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
CollectiongetRegisteredPipelines()
Return a copy of all the pipelines registered at this point.
voidregister(EventPipeline pipeline)
Register an EventPipeline with the ThreadManager.
voidstop()
Stop the ThreadManager from running the pipelines.
StringtoString()
voidunregister(EventPipeline pipeline)
Unregister an EventPipeline with the ThreadManager.
voidunregisterAll()
Unregisters all EventPipelines from this ThreadManager.

Field Detail

m_pipelines

private final 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 Collection getRegisteredPipelines()
Return a copy of all the pipelines registered at this point.

Returns: a copy of the pipelines

register

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

Parameters: pipeline The pipeline to register

stop

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

toString

public String toString()

unregister

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

Parameters: pipeline The pipeline to unregister

unregisterAll

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