public boolean mediate(MessageContext synCtx, ContinuationState contState) {
    SynapseLog synLog = getLog(synCtx);

    if (synLog.isTraceOrDebugEnabled()) {
      synLog.traceOrDebug("Aggregate mediator : Mediating from ContinuationState");
    }

    boolean result;

    SequenceMediator onCompleteSequence = getOnCompleteSequence();
    RuntimeStatisticCollector.openLogForContinuation(
        synCtx, onCompleteSequence.getSequenceNameForStatistics(synCtx));
    if (!contState.hasChild()) {
      result = onCompleteSequence.mediate(synCtx, contState.getPosition() + 1);
    } else {
      FlowContinuableMediator mediator =
          (FlowContinuableMediator) onCompleteSequence.getChild(contState.getPosition());
      RuntimeStatisticCollector.openLogForContinuation(
          synCtx, ((Mediator) mediator).getMediatorName());

      result = mediator.mediate(synCtx, contState.getChildContState());

      ((Mediator) mediator).reportStatistic(synCtx, null, false);
    }
    onCompleteSequence.reportStatistic(synCtx, null, false);
    return result;
  }
 /**
  * Update SeqContinuationState with the current mediator position in the sequence.
  * SeqContinuationState should be updated when branching to a new flow using a
  * FlowContinuableMediator
  *
  * @param synCtx Message Context
  */
 public static void updateSeqContinuationState(MessageContext synCtx, int position) {
   if (synCtx.isContinuationEnabled()) {
     if (!synCtx.getContinuationStateStack().isEmpty()) {
       ContinuationState seqContState = synCtx.getContinuationStateStack().peek();
       seqContState.getLeafChild().setPosition(position);
     } else {
       // Ideally we should not get here.
       log.warn("Continuation Stack is empty. Probably due to a configuration issue");
     }
   }
 }
 /**
  * Remove a ReliantContinuationState from the top SeqContinuationState in the stack. This should
  * be done when returning back from a sub branch of a FlowContinuableMediator.
  *
  * @param synCtx MessageContext
  */
 public static void removeReliantContinuationState(MessageContext synCtx) {
   if (synCtx.isContinuationEnabled()) {
     if (!synCtx.getContinuationStateStack().isEmpty()) {
       ContinuationState seqContState = synCtx.getContinuationStateStack().peek();
       seqContState.removeLeafChild();
     } else {
       // Ideally we should not get here.
       log.warn("Continuation Stack is empty. Probably due to a configuration issue");
     }
   }
 }
Exemplo n.º 4
0
  public boolean mediate(MessageContext synCtx, ContinuationState contState) {
    SynapseLog synLog = getLog(synCtx);

    if (synLog.isTraceOrDebugEnabled()) {
      synLog.traceOrDebug("Aggregate mediator : Mediating from ContinuationState");
    }

    boolean result;

    if (!contState.hasChild()) {
      result = getOnCompleteSequence().mediate(synCtx, contState.getPosition() + 1);
    } else {
      FlowContinuableMediator mediator =
          (FlowContinuableMediator) getOnCompleteSequence().getChild(contState.getPosition());
      result = mediator.mediate(synCtx, contState.getChildContState());
    }
    return result;
  }
Exemplo n.º 5
0
  public boolean mediate(MessageContext synCtx, ContinuationState continuationState) {
    SynapseLog synLog = getLog(synCtx);

    if (synLog.isTraceOrDebugEnabled()) {
      synLog.traceOrDebug("Clone mediator : Mediating from ContinuationState");
    }

    boolean result;
    int subBranch = ((ReliantContinuationState) continuationState).getSubBranch();

    if (!continuationState.hasChild()) {
      result =
          targets.get(subBranch).getSequence().mediate(synCtx, continuationState.getPosition() + 1);
    } else {
      FlowContinuableMediator mediator =
          (FlowContinuableMediator)
              targets.get(subBranch).getSequence().getChild(continuationState.getPosition());
      result = mediator.mediate(synCtx, continuationState.getChildContState());
    }
    return result;
  }
Exemplo n.º 6
0
  public boolean mediate(MessageContext synCtx, ContinuationState continuationState) {
    SynapseLog synLog = getLog(synCtx);

    if (synLog.isTraceOrDebugEnabled()) {
      synLog.traceOrDebug("Invoke mediator : Mediating from ContinuationState");
    }

    boolean result;
    int subBranch = ((ReliantContinuationState) continuationState).getSubBranch();

    if (subBranch == 0) {
      // Default flow
      TemplateMediator templateMediator =
          (TemplateMediator) synCtx.getSequenceTemplate(targetTemplate);

      if (!continuationState.hasChild()) {
        result = templateMediator.mediate(synCtx, continuationState.getPosition() + 1);
        if (result) {
          templateMediator.popFuncContextFrom(synCtx);
        }
      } else {
        FlowContinuableMediator mediator =
            (FlowContinuableMediator) templateMediator.getChild(continuationState.getPosition());
        result = mediator.mediate(synCtx, continuationState.getChildContState());
      }
    } else {
      // Pre fetching invoke mediator flow
      String prefetchInvokeKey = key.evaluateValue(synCtx);
      InvokeMediator prefetchInvoke =
          (InvokeMediator) synCtx.getDefaultConfiguration(prefetchInvokeKey);

      ContinuationState childContinuationState = continuationState.getChildContState();
      result = prefetchInvoke.mediate(synCtx, childContinuationState);

      if (result && !childContinuationState.hasChild()) {
        // Pre fetching invoke mediator flow completed.
        // Remove ContinuationState represent the prefetchInvoke mediator and
        // flip the subbranch to default flow
        continuationState.removeLeafChild();
        ((ReliantContinuationState) continuationState).setSubBranch(0);
        // after prefetch invoke mediator flow, execute default flow
        result = mediate(synCtx, false);
      }
    }
    return result;
  }