Class 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
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.util.List<org.ikasan.spec.flow.FlowElement<org.ikasan.spec.configuration.ConfiguredResource>> dynamicConfiguredResourceFlowElements
      handle to the dynamically configured resources within the flow.
      protected boolean invokeContextListeners
      flag to control invocation of the context listeners at runtime, defaults to true
      • Fields inherited from interface org.ikasan.spec.flow.Flow

        PAUSED, RECOVERING, RUNNING, STOPPED, STOPPED_IN_ERROR
    • 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)
      Constructor
      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
    • 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:
        getName in interface org.ikasan.spec.flow.Flow
      • getModuleName

        public java.lang.String getModuleName()
        Get this module name String moduleName
        Specified by:
        getModuleName in interface org.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:
        start in interface org.ikasan.spec.flow.Flow
      • startPause

        public void startPause()
        Specified by:
        startPause in interface org.ikasan.spec.flow.Flow
      • _start

        protected void _start()
      • pause

        public void pause()
        Specified by:
        pause in interface org.ikasan.spec.flow.Flow
      • resume

        public void resume()
        Specified by:
        resume in interface org.ikasan.spec.flow.Flow
      • isRunning

        public boolean isRunning()
        Is this flow in a running / recovering state
        Specified by:
        isRunning in interface org.ikasan.spec.flow.Flow
        Returns:
      • isPaused

        public boolean isPaused()
        Is this flow in a paused state
        Specified by:
        isPaused in interface org.ikasan.spec.flow.Flow
        Returns:
      • startContextListeners

        public void startContextListeners()
        Specified by:
        startContextListeners in interface org.ikasan.spec.flow.Flow
      • stopContextListeners

        public void stopContextListeners()
        Specified by:
        stopContextListeners in interface org.ikasan.spec.flow.Flow
      • areContextListenersRunning

        public boolean areContextListenersRunning()
        Specified by:
        areContextListenersRunning in interface org.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:
        stop in interface org.ikasan.spec.flow.Flow
      • invoke

        public void invoke​(org.ikasan.spec.flow.FlowEvent<?,​?> event)
        Invoke the flow with a flow event
        Specified by:
        invoke in interface org.ikasan.spec.event.EventListener<ID>
      • invoke

        public void invoke​(org.ikasan.spec.event.Resubmission<org.ikasan.spec.flow.FlowEvent<?,​?>> event)
        Specified by:
        invoke in interface org.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:
        invoke in interface org.ikasan.spec.event.EventListener<ID>
        Parameters:
        throwable -
      • notifyMonitor

        protected void notifyMonitor()
        Notification to all registered MonitorListener of the current state of the Initiator
      • 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:
        setMonitor in interface org.ikasan.spec.monitor.MonitorSubject
        Parameters:
        monitor -
      • getState

        public java.lang.String getState()
        Resolve the state of this flow into a string representation
        Specified by:
        getState in interface org.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:
        getFlowElements in interface org.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:
        getFlowElement in interface org.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:
        setFlowListener in interface org.ikasan.spec.flow.Flow
        Parameters:
        flowEventListener -
      • addFlowListener

        public boolean addFlowListener​(org.ikasan.spec.flow.FlowEventListener flowEventListener)
        Add a flow event listener
        Specified by:
        addFlowListener in interface org.ikasan.spec.flow.Flow
        Parameters:
        flowEventListener -
      • removeFlowListener

        public boolean removeFlowListener​(org.ikasan.spec.flow.FlowEventListener flowEventListener)
        Remove a flow event listener
        Specified by:
        removeFlowListener in interface org.ikasan.spec.flow.Flow
        Parameters:
        flowEventListener -
      • setTriggerService

        public void setTriggerService​(org.ikasan.spec.trigger.TriggerService triggerService)
        Specified by:
        setTriggerService in interface org.ikasan.spec.flow.Flow
      • getTriggerService

        public org.ikasan.spec.trigger.TriggerService getTriggerService()
        Specified by:
        getTriggerService in interface org.ikasan.spec.flow.Flow
      • setErrorReportingService

        public void setErrorReportingService​(org.ikasan.spec.error.reporting.ErrorReportingService errorReportingService)
        Specified by:
        setErrorReportingService in interface org.ikasan.spec.error.reporting.IsErrorReportingServiceAware
      • getFlowConfiguration

        public org.ikasan.spec.flow.FlowConfiguration getFlowConfiguration()
        Specified by:
        getFlowConfiguration in interface org.ikasan.spec.flow.Flow
      • getSerialiserFactory

        public org.ikasan.spec.serialiser.SerialiserFactory getSerialiserFactory()
        Specified by:
        getSerialiserFactory in interface org.ikasan.spec.flow.Flow
      • getConfiguration

        public FlowPersistentConfiguration getConfiguration()
        Specified by:
        getConfiguration in interface org.ikasan.spec.configuration.Configured<ID>
      • setConfiguration

        public void setConfiguration​(FlowPersistentConfiguration configuration)
        Specified by:
        setConfiguration in interface org.ikasan.spec.configuration.Configured<ID>
      • getConfiguredResourceId

        public java.lang.String getConfiguredResourceId()
        Specified by:
        getConfiguredResourceId in interface org.ikasan.spec.configuration.ConfiguredResource<ID>
      • setConfiguredResourceId

        public void setConfiguredResourceId​(java.lang.String id)
        Specified by:
        setConfiguredResourceId in interface org.ikasan.spec.configuration.ConfiguredResource<ID>
      • setFlowInvocationContextListeners

        public void setFlowInvocationContextListeners​(java.util.List<org.ikasan.spec.flow.FlowInvocationContextListener> flowInvocationContextListeners)
        Specified by:
        setFlowInvocationContextListeners in interface org.ikasan.spec.flow.Flow
      • getFlowInvocationContextListeners

        public java.util.List<org.ikasan.spec.flow.FlowInvocationContextListener> getFlowInvocationContextListeners()
        Specified by:
        getFlowInvocationContextListeners in interface org.ikasan.spec.flow.Flow