|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.ikasan.framework.initiator.AbstractInitiator
public abstract class AbstractInitiator
Abstract base class for all existing Initiator implementations
Provides implementations for the common Initiator functionality:
| Field Summary | |
|---|---|
protected boolean |
error
Flag indicating a stoppage in error |
protected ErrorLoggingService |
errorLoggingService
Service for logging errors in a heavyweight fashion |
static String |
EXCEPTION_ACTION_IMPLIED_ROLLBACK
Exception action is an implied rollback message |
protected IkasanExceptionHandler |
exceptionHandler
Handler for exceptions |
protected ExcludedEventService |
excludedEventService
Service for excluding events |
protected Set<String> |
exclusions
Set of ids for Events that will be immediately excluded when next encountered |
protected Flow |
flow
Flow to be invoked by this initiator |
protected String |
moduleName
Name of the module |
protected List<MonitorListener> |
monitorListeners
Monitor listeners for the initiator |
protected String |
name
Name of the initiator |
protected Integer |
retryCount
Count of how many times this Initiator has retried |
protected boolean |
stopping
Flag indicating that the initiator has received a stop call |
static String |
UNSUPPORTED_EXCLUDE_ENCONTERED
Exception action is an implied rollback message |
| Constructor Summary | |
|---|---|
AbstractInitiator(String moduleName,
String name,
Flow flow,
IkasanExceptionHandler exceptionHandler)
Constructor |
|
| Method Summary | |
|---|---|
void |
addListener(MonitorListener monitorListener)
Adds a MonitorListener to this Initiator |
protected abstract void |
cancelRetryCycle()
Cancels retry activity |
protected abstract void |
completeRetryCycle()
Cancel the retry activity, and resume any business as usual activity |
protected void |
continueRetryCycle(long delay)
Template method for subclasses to selectively override |
IkasanExceptionHandler |
getExceptionHandler()
Accessor for exceptionHandler |
Set<String> |
getExclusions()
Accessor for exclusions |
Flow |
getFlow()
Returns the flow that this invokes |
long |
getHandledEventCount()
|
Date |
getLastEventTime()
|
protected abstract org.apache.log4j.Logger |
getLogger()
Provides access to the implementation class specific logger instance |
String |
getModuleName()
Accessor for moduleName |
List<MonitorListener> |
getMonitorListeners()
Accessor for monitorListeners |
String |
getName()
The flow initiator's name. |
Integer |
getRetryCount()
Accessor for retryCount |
InitiatorState |
getState()
Returns the current state of the Initiator |
protected void |
handleAction(IkasanExceptionAction action,
String eventId)
Handle the returned action from the flow invocation |
protected void |
handleRetry(Integer maxAttempts,
long delay)
Handle an IkasanExceptionAction 'retry' |
protected void |
invokeFlow(Event event)
Invoke the flow with a single Event |
protected void |
invokeFlow(List<Event> events)
Invoke the flow with all available Events, handing exception actions as we go |
boolean |
isError()
Is this initiator in an error state. |
boolean |
isStopping()
Accessor for stopping flag |
protected void |
logError(Event event,
Throwable throwable,
String componentName,
IkasanExceptionAction exceptionAction)
Logs errors in a heavy weight fashion using an ErrorLoggingService if available |
protected void |
notifyMonitorListeners()
Notification to all registered MonitorListener of the current state of the Initiator |
void |
removeListener(MonitorListener monitorListener)
Removes a specified MonitorListener from this Initiator
This method has no effect if the specified MonitorListener is not currently a registered listener |
protected void |
resume()
Returns the Initiator to normal running, completes recovering if necessary |
void |
setErrorLoggingService(ErrorLoggingService errorLoggingService)
Setter for optional ErrorLoggingService |
void |
setExcludedEventService(ExcludedEventService excludedEventService)
|
void |
start()
Start this initiator. |
protected abstract void |
startInitiator()
Only the extending class knows how to start the initiator. |
protected abstract void |
startRetryCycle(Integer maxAttempts,
long delay)
Initiator needs to start a retry cycle due to an exception action. |
void |
stop()
Stop this initiator. |
protected void |
stopInError()
Sets the error flag before stopping the initiator by normal means |
protected abstract void |
stopInitiator()
Only the extending class knows how to stop the initiator. |
boolean |
supportsExclusions()
Returns true if an excludedEventService is present, and thus supports exclusions |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.ikasan.framework.initiator.Initiator |
|---|
getType, isRecovering, isRunning |
| Field Detail |
|---|
public static final String EXCEPTION_ACTION_IMPLIED_ROLLBACK
public static final String UNSUPPORTED_EXCLUDE_ENCONTERED
protected List<MonitorListener> monitorListeners
protected String moduleName
protected String name
protected Flow flow
protected boolean error
protected boolean stopping
protected Integer retryCount
protected IkasanExceptionHandler exceptionHandler
protected ErrorLoggingService errorLoggingService
protected ExcludedEventService excludedEventService
protected Set<String> exclusions
| Constructor Detail |
|---|
public AbstractInitiator(String moduleName,
String name,
Flow flow,
IkasanExceptionHandler exceptionHandler)
moduleName - The name of the modulename - The name of this initiatorflow - The name of the flow it startsexceptionHandler - | Method Detail |
|---|
public void addListener(MonitorListener monitorListener)
MonitorListener to this Initiator
monitorListener - public void removeListener(MonitorListener monitorListener)
MonitorListener from this Initiator
This method has no effect if the specified MonitorListener is not currently a registered listener
monitorListener - - listener to removeprotected void notifyMonitorListeners()
MonitorListener of the current state of the Initiator
public IkasanExceptionHandler getExceptionHandler()
Initiator
getExceptionHandler in interface Initiatorpublic List<MonitorListener> getMonitorListeners()
MonitorListeners registered with this Initiatorpublic InitiatorState getState()
Initiator
getState in interface Initiator
public void start()
throws InitiatorOperationException
Initiator
start in interface InitiatorInitiatorOperationException - Exception if we cannot start the Initiator
public void stop()
throws InitiatorOperationException
Initiator
stop in interface InitiatorInitiatorOperationException - Exception if we cannot stop the Initiatorprotected void invokeFlow(List<Event> events)
Events, handing exception actions as we go
events -
protected void logError(Event event,
Throwable throwable,
String componentName,
IkasanExceptionAction exceptionAction)
ErrorLoggingService if available
event - throwable - componentName - protected void invokeFlow(Event event)
Event
event -
protected void handleAction(IkasanExceptionAction action,
String eventId)
action - IkasanExceptionAction to deal with
protected void handleRetry(Integer maxAttempts,
long delay)
throws InitiatorOperationException
maxAttempts - - maximum number of times to retrydelay - - time to delay between retries
InitiatorOperationException - Exception to throw if we cannot retry
protected void resume()
throws InitiatorOperationException
InitiatorOperationExceptionprotected void stopInError()
public String getModuleName()
public Integer getRetryCount()
getRetryCount in interface Initiatorpublic String getName()
Initiator
getName in interface Initiatorpublic Flow getFlow()
Initiator
getFlow in interface Initiatorpublic boolean isError()
Initiator
isError in interface Initiatorpublic boolean isStopping()
public void setErrorLoggingService(ErrorLoggingService errorLoggingService)
errorLoggingService - protected abstract org.apache.log4j.Logger getLogger()
protected abstract void completeRetryCycle()
protected abstract void cancelRetryCycle()
protected abstract void startInitiator()
throws InitiatorOperationException
InitiatorOperationException - Exception if we cannot start initiator
protected abstract void stopInitiator()
throws InitiatorOperationException
InitiatorOperationException - Excetpion if we cannot stop initiator
protected abstract void startRetryCycle(Integer maxAttempts,
long delay)
throws InitiatorOperationException
maxAttemptss - The number of retries we allowdelay - The delay in milliseconds before we perform a retry
InitiatorOperationExceptionprotected void continueRetryCycle(long delay)
delay - public void setExcludedEventService(ExcludedEventService excludedEventService)
excludedEventService - to setpublic boolean supportsExclusions()
public Set<String> getExclusions()
public long getHandledEventCount()
getHandledEventCount in interface Initiatorpublic Date getLastEventTime()
getLastEventTime in interface Initiator
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||