Interface ChainExecutionPathTreeVisitor

All Known Implementing Classes:
BaseChainExecutionPathTreeVisitor

@Experimental public interface ChainExecutionPathTreeVisitor
Provides a way to navigate a ChainExecutionPathTree with its ChainExecutionPathTree.accept(ChainExecutionPathTreeVisitor) method not coupled to its internal structure.

For each item of interest in the ChainExecutionPathTree being navigated, a method from this visitor will be called. The order of the called methods is consistent and depends on the definition of the chain. It is up to implementations to keep the proper context for backtracking after an inner chain or an error handler is finished.

Implementations need not be tread-safe.

Since:
1.1
  • Method Details

    • visitSource

      void visitSource(ChainExecutionPathTree source)
      Called when a #SOURCE is found in the execution tree.

      If the chain is a #FLOW with a #SOURCE, this will be the first method called when visiting the chain.

      Parameters:
      source - the tree representing visited source
    • visitSimpleOperation

      void visitSimpleOperation(ChainExecutionPathTree operation)
      Called when a simple #OPERATION is found in the execution tree.

      A simple #OPERATION is any operation within a chain that is not a #SCOPE or #ROUTER.

      Parameters:
      operation - the visited simple operation.
    • visitReferencedOperation

      void visitReferencedOperation(ChainExecutionPathTree operation)
      Called when an #OPERATION that references to another operation in the execution tree.

      This could be the case of a Flow Reference Operation.

      Parameters:
      operation - the visited reference operation.
    • finishReferencedOperation

      void finishReferencedOperation(ChainExecutionPathTree operation)
      Called after a reference was traversed, to mark that the referenced ChainExecutionPathTree has finished.
      Parameters:
      operation -
    • visitScope

      boolean visitScope(ChainExecutionPathTree scope)
      Called when a #SCOPE is found in the execution tree.

      After this method is called, if it returns true it will proceed to visit its inner components. After that, scopeFinished(ChainExecutionPathTree) will be called and then the method for the component right after the scope the last call to that method. If visitScope(ChainExecutionPathTree) returned false, this method won't be called.

      Parameters:
      scope - the visited scope.
      Returns:
      true if the visitor should visit the inner components of the #SCOPE, or false if it should just skip to the next element. If it is true, then every inner component of this particular #SCOPE will be visited.
    • scopeFinished

      void scopeFinished(ChainExecutionPathTree scope)
      Called after the #ROUTE/#CHAIN within a #SCOPE was visited.

      This is a delimiter call. This will only be called after visitScope(ChainExecutionPathTree) and will be referred to the last call to that method.

    • visitRouter

      boolean visitRouter(ChainExecutionPathTree router)
      Called when a #ROUTER is found in the execution tree.

      After this method is called, if it returns {@link true}, for each of its inner chains innerRouteStarted(ChainExecutionPathTree) (ComponentAst)} followed by the calls that correspond to its inner components, and then routerFinished(ChainExecutionPathTree) will be called. After all inner chains have been navigated, routerFinished(ChainExecutionPathTree) will be called with the same ComponentAst of this #ROUTER, and the method for the component right after the scope will be called.

      Parameters:
      router - the visited router.
      Returns:
      true if the visitor should visit the inner components of the #ROUTER, or false if it should just skip to the next element.
    • innerRouteStarted

      boolean innerRouteStarted(ChainExecutionPathTree innerChain)
      Called when a #ROUTE within a #ROUTER is found in the execution tree.

      This is a delimiter call. The finish of the innerChain started here will be notified by a call to innerRouteFinished(ChainExecutionPathTree). This wil only be called if visitRouter(ChainExecutionPathTree) returned true.

      Parameters:
      innerChain - the visited innerChain.
      Returns:
      true if this particular route is required to be started.
    • innerRouteFinished

      void innerRouteFinished(ChainExecutionPathTree innerChain)
      Called after the last component in a #ROUTE within a #ROUTER.

      This is a delimiter call. This will only be called after innerRouteStarted(ChainExecutionPathTree) and will apply to the innerChain indicated in the last call to that method.

      Parameters:
      innerChain - the visited innerChain
    • routerFinished

      void routerFinished(ChainExecutionPathTree router)
      Called after the last #ROUTE within a #ROUTER was visited.

      This is a delimiter call. This will only be called after visitRouter(ChainExecutionPathTree) and will be referred to the last call to that method. If visitRouter(ChainExecutionPathTree) returned false, this method won't be called.

    • errorHandlerCouldBeInvoked

      void errorHandlerCouldBeInvoked(ChainExecutionPathTree errorHandler, org.mule.runtime.api.message.ErrorType errorType)
      Called after an operation is found that may raise an error that would incur in the invocation of the . This also includes the case of an OnErrorPropagate, which in the end propagates as well to this error handler. The visitor must consider that this method may be called for the same error handler for every error that may occur and this matches.
      Parameters:
      errorHandler - the ChainExecutionPathTree corresponding to the error handler that could be invoked.
      errorType - the ErrorType of the error that the operation may raise.
    • errorHandlerStarted

      boolean errorHandlerStarted(ChainExecutionPathTree handler)
      This method will be called before starting the traversal of an error handler. This will be called after the entire chain of the owner of this ErrorHandler has been traversed, which will allow to retrieve all the potential calls to this, which are modeled with #errorHandlerCouldBeInvoked(ChainExecutionPathTree).

      If there is the need to continue the propagation (i.e. this is an on error propagate handler), it will as well invoke #errorHandlerCouldBeInvoked(ChainExecutionPathTree) after the propagation of this one is finished.

      Parameters:
      handler - the visited error handler
      Returns:
      true if the visitor should travers this error handler (errorHandlerFinished(ChainExecutionPathTree) won't be invoked if this returns false).
    • errorHandlerFinished

      void errorHandlerFinished(ChainExecutionPathTree handler)
      Called after the last component in an #ERROR_HANDLER.

      This is a delimiter call. This will only be called after errorHandlerStarted(ChainExecutionPathTree).

      Parameters:
      handler - the visited error handler.
    • errorHandlerPropagationComplete

      void errorHandlerPropagationComplete(ChainExecutionPathTree handler)
      Called after the last component in an #ERROR_HANDLER if the error has finished to be propagated to other error handlers. This is, for example, if the current is an on-error-continue, or if we reached the last level of error handling to be able to handle the error (e.g. the main flow). This method will be called for every that the originating component may throw, as far as there is at least an error handler to handle it.

      This is a delimiter call. The finish of the error handler started here will be notified by a call to errorHandlerFinished(ChainExecutionPathTree), including for this last , to then call this method.

      Parameters:
      handler - the visited error handler
    • chainInterruptedWithError

      void chainInterruptedWithError(ChainExecutionPathTree chain)
      Called after a component that will always interrupt the execution flow of a chain prematurely and with an error.

      This represents a situation in which, if there are other nodes after this one, they will never be executed.

      Parameters:
      chain - the interrupted chain.
      Since:
      1.5