Package org.ikasan.flow.visitorPattern
Class VisitingInvokerFlow<ID>
- java.lang.Object
-
- org.ikasan.flow.visitorPattern.VisitingInvokerFlow<ID>
-
- All Implemented Interfaces:
org.ikasan.spec.configuration.Configured<FlowPersistentConfiguration>,org.ikasan.spec.configuration.ConfiguredResource<FlowPersistentConfiguration>,org.ikasan.spec.error.reporting.IsErrorReportingServiceAware,org.ikasan.spec.event.EventListener<org.ikasan.spec.flow.FlowEvent<?,?>>,org.ikasan.spec.flow.Flow,org.ikasan.spec.monitor.MonitorSubject
public class VisitingInvokerFlow<ID> extends java.lang.Object implements org.ikasan.spec.flow.Flow, org.ikasan.spec.event.EventListener<org.ikasan.spec.flow.FlowEvent<?,?>>, org.ikasan.spec.monitor.MonitorSubject, org.ikasan.spec.error.reporting.IsErrorReportingServiceAware, org.ikasan.spec.configuration.ConfiguredResource<FlowPersistentConfiguration>
Default implementation of a Flow- Author:
- Ikasan Development Team
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classVisitingInvokerFlow.ManagedResourceRecoveryManagerFactoryManaged Resource Recovery Manager factory used to create MR recovery manager instances per named managed resource.
-
Field Summary
Fields Modifier and Type Field Description protected java.util.List<org.ikasan.spec.flow.FlowElement<org.ikasan.spec.configuration.ConfiguredResource>>dynamicConfiguredResourceFlowElementshandle to the dynamically configured resources within the flow.protected booleaninvokeContextListenersflag to control invocation of the context listeners at runtime, defaults to true
-
Constructor Summary
Constructors Constructor Description VisitingInvokerFlow(java.lang.String name, java.lang.String moduleName, org.ikasan.spec.flow.FlowConfiguration flowConfiguration, ExclusionFlowConfiguration exclusionFlowConfiguration, org.ikasan.spec.recovery.RecoveryManager<org.ikasan.spec.flow.FlowEvent<?,?>,org.ikasan.spec.flow.FlowInvocationContext,ID> recoveryManager, org.ikasan.spec.exclusion.ExclusionService exclusionService, org.ikasan.spec.serialiser.SerialiserFactory serialiserFactory)ConstructorVisitingInvokerFlow(java.lang.String name, java.lang.String moduleName, org.ikasan.spec.flow.FlowConfiguration flowConfiguration, org.ikasan.spec.recovery.RecoveryManager<org.ikasan.spec.flow.FlowEvent<?,?>,org.ikasan.spec.flow.FlowInvocationContext,ID> recoveryManager, org.ikasan.spec.exclusion.ExclusionService exclusionService, org.ikasan.spec.serialiser.SerialiserFactory serialiserFactory)Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void_start()booleanaddFlowListener(org.ikasan.spec.flow.FlowEventListener flowEventListener)Add a flow event listenerbooleanareContextListenersRunning()protected org.ikasan.spec.flow.FlowInvocationContextcreateFlowInvocationContext()Factory method for creating a flow invocation context.protected voidflowElementCaptureMetrics(org.ikasan.spec.flow.FlowElement flowElement)FlowPersistentConfigurationgetConfiguration()java.lang.StringgetConfiguredResourceId()org.ikasan.spec.flow.FlowConfigurationgetFlowConfiguration()org.ikasan.spec.flow.FlowElement<?>getFlowElement(java.lang.String name)Return the flow element matching this name.java.util.List<org.ikasan.spec.flow.FlowElement<?>>getFlowElements()protected java.util.List<org.ikasan.spec.flow.FlowEventListener>getFlowEventListeners()Allow extention for testing.java.util.List<org.ikasan.spec.flow.FlowInvocationContextListener>getFlowInvocationContextListeners()java.lang.StringgetModuleName()Get this module name String moduleNamejava.lang.StringgetName()Get this flow name return nameorg.ikasan.spec.serialiser.SerialiserFactorygetSerialiserFactory()java.lang.StringgetState()Resolve the state of this flow into a string representationlonggetStopWaitTimeout()Get the stop wait timeoutorg.ikasan.spec.trigger.TriggerServicegetTriggerService()protected voidinvoke(java.lang.String moduleName, java.lang.String flowName, org.ikasan.spec.flow.FlowInvocationContext flowInvocationContext, org.ikasan.spec.flow.FlowEvent flowEvent, org.ikasan.spec.flow.FlowElement flowElement)voidinvoke(java.lang.Throwable throwable)Invoke the recover manager to act on the passed exception.voidinvoke(org.ikasan.spec.event.Resubmission<org.ikasan.spec.flow.FlowEvent<?,?>> event)voidinvoke(org.ikasan.spec.flow.FlowEvent<?,?> event)Invoke the flow with a flow eventbooleanisPaused()Is this flow in a paused statebooleanisRunning()Is this flow in a running / recovering stateprotected voidnotifyFlowInvocationContextListenersEndFlow(org.ikasan.spec.flow.FlowInvocationContext flowInvocationContext)Notify any FlowInvocationContextListeners that the flow has completedprotected voidnotifyMonitor()Notification to all registeredMonitorListenerof the current state of theInitiatorvoidpause()booleanremoveFlowListener(org.ikasan.spec.flow.FlowEventListener flowEventListener)Remove a flow event listenervoidresume()voidsetConfiguration(FlowPersistentConfiguration configuration)voidsetConfiguredResourceId(java.lang.String id)voidsetErrorReportingService(org.ikasan.spec.error.reporting.ErrorReportingService errorReportingService)voidsetFlowInvocationContextListeners(java.util.List<org.ikasan.spec.flow.FlowInvocationContextListener> flowInvocationContextListeners)voidsetFlowListener(org.ikasan.spec.flow.FlowEventListener flowEventListener)Replace existing flow event listeners with this flow event listener.voidsetManagedResourceRecoveryManagerFactory(VisitingInvokerFlow.ManagedResourceRecoveryManagerFactory managedResourceRecoveryManagerFactory)Allow override of the managed resource recovery manager within this class.voidsetMonitor(org.ikasan.spec.monitor.Monitor monitor)Set the flow monitorvoidsetStopWaitTimeout(long stopWaitTimeout)Set the stop wait timeoutvoidsetTriggerService(org.ikasan.spec.trigger.TriggerService triggerService)voidstart()Start this flowprotected voidstartConsumer()Start the consumer component.voidstartContextListeners()protected voidstartManagedResources()Start the components marked as including Managed Resources.voidstartPause()voidstop()Stop this flowvoidstopContextListeners()protected voidstopManagedResources()Stop all managed resources from left to right.
-
-
-
Field Detail
-
invokeContextListeners
protected volatile boolean invokeContextListeners
flag to control invocation of the context listeners at runtime, defaults to true
-
dynamicConfiguredResourceFlowElements
protected java.util.List<org.ikasan.spec.flow.FlowElement<org.ikasan.spec.configuration.ConfiguredResource>> dynamicConfiguredResourceFlowElements
handle to the dynamically configured resources within the flow. We hold on to this so its only refreshed on the start of the flow so we arent establishing this on every event invocation.
-
-
Constructor Detail
-
VisitingInvokerFlow
public VisitingInvokerFlow(java.lang.String name, java.lang.String moduleName, org.ikasan.spec.flow.FlowConfiguration flowConfiguration, org.ikasan.spec.recovery.RecoveryManager<org.ikasan.spec.flow.FlowEvent<?,?>,org.ikasan.spec.flow.FlowInvocationContext,ID> recoveryManager, org.ikasan.spec.exclusion.ExclusionService exclusionService, org.ikasan.spec.serialiser.SerialiserFactory serialiserFactory)Constructor- Parameters:
name-moduleName-flowConfiguration-recoveryManager-exclusionService-
-
VisitingInvokerFlow
public VisitingInvokerFlow(java.lang.String name, java.lang.String moduleName, org.ikasan.spec.flow.FlowConfiguration flowConfiguration, ExclusionFlowConfiguration exclusionFlowConfiguration, org.ikasan.spec.recovery.RecoveryManager<org.ikasan.spec.flow.FlowEvent<?,?>,org.ikasan.spec.flow.FlowInvocationContext,ID> recoveryManager, org.ikasan.spec.exclusion.ExclusionService exclusionService, org.ikasan.spec.serialiser.SerialiserFactory serialiserFactory)Constructor- Parameters:
name-moduleName-flowConfiguration-exclusionFlowConfiguration-recoveryManager-exclusionService-
-
-
Method Detail
-
getFlowEventListeners
protected java.util.List<org.ikasan.spec.flow.FlowEventListener> getFlowEventListeners()
Allow extention for testing.- Returns:
-
getStopWaitTimeout
public long getStopWaitTimeout()
Get the stop wait timeout- Returns:
-
setStopWaitTimeout
public void setStopWaitTimeout(long stopWaitTimeout)
Set the stop wait timeout- Parameters:
stopWaitTimeout-
-
getName
public java.lang.String getName()
Get this flow name return name- Specified by:
getNamein interfaceorg.ikasan.spec.flow.Flow
-
getModuleName
public java.lang.String getModuleName()
Get this module name String moduleName- Specified by:
getModuleNamein interfaceorg.ikasan.spec.flow.Flow
-
setManagedResourceRecoveryManagerFactory
public void setManagedResourceRecoveryManagerFactory(VisitingInvokerFlow.ManagedResourceRecoveryManagerFactory managedResourceRecoveryManagerFactory)
Allow override of the managed resource recovery manager within this class. Mainly for testability.- Parameters:
managedResourceRecoveryManagerFactory-
-
start
public void start()
Start this flow- Specified by:
startin interfaceorg.ikasan.spec.flow.Flow
-
startPause
public void startPause()
- Specified by:
startPausein interfaceorg.ikasan.spec.flow.Flow
-
_start
protected void _start()
-
pause
public void pause()
- Specified by:
pausein interfaceorg.ikasan.spec.flow.Flow
-
resume
public void resume()
- Specified by:
resumein interfaceorg.ikasan.spec.flow.Flow
-
isRunning
public boolean isRunning()
Is this flow in a running / recovering state- Specified by:
isRunningin interfaceorg.ikasan.spec.flow.Flow- Returns:
-
isPaused
public boolean isPaused()
Is this flow in a paused state- Specified by:
isPausedin interfaceorg.ikasan.spec.flow.Flow- Returns:
-
startContextListeners
public void startContextListeners()
- Specified by:
startContextListenersin interfaceorg.ikasan.spec.flow.Flow
-
stopContextListeners
public void stopContextListeners()
- Specified by:
stopContextListenersin interfaceorg.ikasan.spec.flow.Flow
-
areContextListenersRunning
public boolean areContextListenersRunning()
- Specified by:
areContextListenersRunningin interfaceorg.ikasan.spec.flow.Flow
-
startConsumer
protected void startConsumer()
Start the consumer component.
-
stopManagedResources
protected void stopManagedResources()
Stop all managed resources from left to right.
-
startManagedResources
protected void startManagedResources()
Start the components marked as including Managed Resources. These component are started from right to left in the flow.
-
stop
public void stop()
Stop this flow- Specified by:
stopin interfaceorg.ikasan.spec.flow.Flow
-
invoke
public void invoke(org.ikasan.spec.flow.FlowEvent<?,?> event)
Invoke the flow with a flow event- Specified by:
invokein interfaceorg.ikasan.spec.event.EventListener<ID>
-
invoke
public void invoke(org.ikasan.spec.event.Resubmission<org.ikasan.spec.flow.FlowEvent<?,?>> event)
- Specified by:
invokein interfaceorg.ikasan.spec.event.EventListener<ID>
-
invoke
protected void invoke(java.lang.String moduleName, java.lang.String flowName, org.ikasan.spec.flow.FlowInvocationContext flowInvocationContext, org.ikasan.spec.flow.FlowEvent flowEvent, org.ikasan.spec.flow.FlowElement flowElement)
-
invoke
public void invoke(java.lang.Throwable throwable)
Invoke the recover manager to act on the passed exception.- Specified by:
invokein interfaceorg.ikasan.spec.event.EventListener<ID>- Parameters:
throwable-
-
notifyMonitor
protected void notifyMonitor()
Notification to all registeredMonitorListenerof the current state of theInitiator
-
flowElementCaptureMetrics
protected void flowElementCaptureMetrics(org.ikasan.spec.flow.FlowElement flowElement)
-
notifyFlowInvocationContextListenersEndFlow
protected void notifyFlowInvocationContextListenersEndFlow(org.ikasan.spec.flow.FlowInvocationContext flowInvocationContext)
Notify any FlowInvocationContextListeners that the flow has completed
-
setMonitor
public void setMonitor(org.ikasan.spec.monitor.Monitor monitor)
Set the flow monitor- Specified by:
setMonitorin interfaceorg.ikasan.spec.monitor.MonitorSubject- Parameters:
monitor-
-
getState
public java.lang.String getState()
Resolve the state of this flow into a string representation- Specified by:
getStatein interfaceorg.ikasan.spec.flow.Flow- Returns:
-
createFlowInvocationContext
protected org.ikasan.spec.flow.FlowInvocationContext createFlowInvocationContext()
Factory method for creating a flow invocation context.- Returns:
- FlowInvocationContext
-
getFlowElements
public java.util.List<org.ikasan.spec.flow.FlowElement<?>> getFlowElements()
- Specified by:
getFlowElementsin interfaceorg.ikasan.spec.flow.Flow
-
getFlowElement
public org.ikasan.spec.flow.FlowElement<?> getFlowElement(java.lang.String name)
Return the flow element matching this name.- Specified by:
getFlowElementin interfaceorg.ikasan.spec.flow.Flow- Returns:
- flowElement
-
setFlowListener
public void setFlowListener(org.ikasan.spec.flow.FlowEventListener flowEventListener)
Replace existing flow event listeners with this flow event listener.- Specified by:
setFlowListenerin interfaceorg.ikasan.spec.flow.Flow- Parameters:
flowEventListener-
-
addFlowListener
public boolean addFlowListener(org.ikasan.spec.flow.FlowEventListener flowEventListener)
Add a flow event listener- Specified by:
addFlowListenerin interfaceorg.ikasan.spec.flow.Flow- Parameters:
flowEventListener-
-
removeFlowListener
public boolean removeFlowListener(org.ikasan.spec.flow.FlowEventListener flowEventListener)
Remove a flow event listener- Specified by:
removeFlowListenerin interfaceorg.ikasan.spec.flow.Flow- Parameters:
flowEventListener-
-
setTriggerService
public void setTriggerService(org.ikasan.spec.trigger.TriggerService triggerService)
- Specified by:
setTriggerServicein interfaceorg.ikasan.spec.flow.Flow
-
getTriggerService
public org.ikasan.spec.trigger.TriggerService getTriggerService()
- Specified by:
getTriggerServicein interfaceorg.ikasan.spec.flow.Flow
-
setErrorReportingService
public void setErrorReportingService(org.ikasan.spec.error.reporting.ErrorReportingService errorReportingService)
- Specified by:
setErrorReportingServicein interfaceorg.ikasan.spec.error.reporting.IsErrorReportingServiceAware
-
getFlowConfiguration
public org.ikasan.spec.flow.FlowConfiguration getFlowConfiguration()
- Specified by:
getFlowConfigurationin interfaceorg.ikasan.spec.flow.Flow
-
getSerialiserFactory
public org.ikasan.spec.serialiser.SerialiserFactory getSerialiserFactory()
- Specified by:
getSerialiserFactoryin interfaceorg.ikasan.spec.flow.Flow
-
getConfiguration
public FlowPersistentConfiguration getConfiguration()
- Specified by:
getConfigurationin interfaceorg.ikasan.spec.configuration.Configured<ID>
-
setConfiguration
public void setConfiguration(FlowPersistentConfiguration configuration)
- Specified by:
setConfigurationin interfaceorg.ikasan.spec.configuration.Configured<ID>
-
getConfiguredResourceId
public java.lang.String getConfiguredResourceId()
- Specified by:
getConfiguredResourceIdin interfaceorg.ikasan.spec.configuration.ConfiguredResource<ID>
-
setConfiguredResourceId
public void setConfiguredResourceId(java.lang.String id)
- Specified by:
setConfiguredResourceIdin interfaceorg.ikasan.spec.configuration.ConfiguredResource<ID>
-
setFlowInvocationContextListeners
public void setFlowInvocationContextListeners(java.util.List<org.ikasan.spec.flow.FlowInvocationContextListener> flowInvocationContextListeners)
- Specified by:
setFlowInvocationContextListenersin interfaceorg.ikasan.spec.flow.Flow
-
getFlowInvocationContextListeners
public java.util.List<org.ikasan.spec.flow.FlowInvocationContextListener> getFlowInvocationContextListeners()
- Specified by:
getFlowInvocationContextListenersin interfaceorg.ikasan.spec.flow.Flow
-
-