public class CommandManager
extends org.apache.avalon.framework.logger.AbstractLogEnabled
implements org.apache.excalibur.event.command.EventPipeline, org.apache.avalon.framework.activity.Disposable, org.apache.excalibur.event.EnqueuePredicate
Source Example
//
// Set up the ThreadManager that the CommandManager will use
//
ThreadManager threadManager = new TPCThreadManager();
threadManager.enableLogging( getLogger().getChildLogger("threadmanager") );
Parameters params = new Parameters();
params.setParameter( "threads-per-processor", "2" );
params.setParameter( "sleep-time", "1000" );
params.setParameter( "block-timeout", "250" );
threadManager.parameterize( params );
threadManager.initialize();
//
// Set up the CommandManager
//
CommandManager commandManager = new CommandManager();
commandManager.enableLogging( getLogger().getChildLogger("commandmanager") );
threadManager.register( commandManager );
| Modifier and Type | Class and Description |
|---|---|
private class |
CommandManager.CommandEventHandler |
private static class |
CommandManager.DelayedCommandInfo |
| Modifier and Type | Field and Description |
|---|---|
private org.apache.excalibur.event.EventHandler |
m_eventHandler |
private org.apache.excalibur.event.command.CommandFailureHandler |
m_failureHandler |
private boolean |
m_isAccepting |
private EDU.oswego.cs.dl.util.concurrent.ReentrantLock |
m_mutex |
private org.apache.excalibur.event.Queue |
m_queue |
private java.util.HashMap |
m_signalHandlers |
private org.apache.excalibur.event.Source[] |
m_sources |
| Constructor and Description |
|---|
CommandManager()
Create the CommandManager
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
accept(java.lang.Object[] elements,
org.apache.excalibur.event.Sink modifyingSink)
Tests the given element for acceptance onto the m_sink.
|
boolean |
accept(java.lang.Object element,
org.apache.excalibur.event.Sink modifyingSink)
Tests the given element for acceptance onto the m_sink.
|
void |
deregisterSignalHandler(org.apache.excalibur.event.Signal signal,
org.apache.excalibur.event.EventHandler handler)
Deregister a Signal with an EventHandler.
|
void |
dispose()
When you are done with CommandManager, call this and it will
clean up all its resources.
|
protected org.apache.excalibur.event.command.CommandFailureHandler |
getCommandFailureHandler()
Get the failure handler so that CommandManager can use it when a problem happens.
|
org.apache.excalibur.event.Sink |
getCommandSink()
Get the Command Sink so that you can enqueue new commands.
|
org.apache.excalibur.event.EventHandler |
getEventHandler()
Used by the ThreadManager to get the EventHandler for the
CommandManager.
|
org.apache.excalibur.event.Source[] |
getSources()
Used by the Threadmanager to get the sources that are feeding
the CommandManager.
|
void |
registerSignalHandler(org.apache.excalibur.event.Signal signal,
org.apache.excalibur.event.EventHandler handler)
Register a Signal with an EventHandler.
|
void |
setCommandFailureHandler(org.apache.excalibur.event.command.CommandFailureHandler handler)
Set the failure handler that the application can use to override what happens when a command
failure happens.
|
private final org.apache.excalibur.event.Queue m_queue
private final java.util.HashMap m_signalHandlers
private final EDU.oswego.cs.dl.util.concurrent.ReentrantLock m_mutex
private final org.apache.excalibur.event.EventHandler m_eventHandler
private final org.apache.excalibur.event.Source[] m_sources
private org.apache.excalibur.event.command.CommandFailureHandler m_failureHandler
private boolean m_isAccepting
public void setCommandFailureHandler(org.apache.excalibur.event.command.CommandFailureHandler handler)
handler - the new Handlerjava.lang.NullPointerException - if "handler" is null.protected org.apache.excalibur.event.command.CommandFailureHandler getCommandFailureHandler()
public final org.apache.excalibur.event.Sink getCommandSink()
public final void registerSignalHandler(org.apache.excalibur.event.Signal signal,
org.apache.excalibur.event.EventHandler handler)
Signal interface. When CommandManager recieves
events that match the Signal, it will send a copy of it to all the
EventHandlers attached to it.signal - The signal we are listening for.handler - The handler that wants to be notifiedpublic final void deregisterSignalHandler(org.apache.excalibur.event.Signal signal,
org.apache.excalibur.event.EventHandler handler)
signal - The signal we are listening for.handler - The handler that wants to be notifiedpublic void dispose()
dispose in interface org.apache.avalon.framework.activity.Disposablepublic final org.apache.excalibur.event.Source[] getSources()
getSources in interface org.apache.excalibur.event.command.EventPipelinepublic final org.apache.excalibur.event.EventHandler getEventHandler()
getEventHandler in interface org.apache.excalibur.event.command.EventPipelinepublic boolean accept(java.lang.Object element,
org.apache.excalibur.event.Sink modifyingSink)
accept in interface org.apache.excalibur.event.EnqueuePredicateelement - The element to enqueuemodifyingSink - The sink that is used for this predicatetrue if the sink accepts the element;
false otherwise.public boolean accept(java.lang.Object[] elements,
org.apache.excalibur.event.Sink modifyingSink)
accept in interface org.apache.excalibur.event.EnqueuePredicateelements - The array of elements to enqueuemodifyingSink - The sink that is used for this predicatetrue if the sink accepts all the elements;
false otherwise.