Class SwitchPipe

All Implemented Interfaces:
FrankElement, HasApplicationContext, HasName, HasTransactionAttribute, IConfigurable, IForwardTarget, IPipe, IScopeProvider, IWithParameters, NameAware, EventThrowing, org.springframework.beans.factory.Aware, org.springframework.context.ApplicationContextAware, org.springframework.context.Lifecycle
Direct Known Subclasses:
XmlSwitch

@Forward(name="notFound",description="when the forward derived from the stylesheet could not be found") @Forward(name="empty",description="when the content, on which the switch is performed, is empty") @Forward(name="*",description="name of the root-element OR result of transformation (when <code>styleSheetName</code> or <code>xpathExpression</code> is specified)") @Category(BASIC) @EnterpriseIntegrationPattern(ROUTER) public class SwitchPipe extends AbstractPipe
Selects an exitState, based on either the content of the input message, by means of an XSLT-stylesheet, the content of a session variable, a JSON Path expression, or, by default, by returning the name of the root-element. This pipe returns its input.
Since:
9.2
  • Field Details

    • SWITCH_FORWARD_FOUND_MONITOR_EVENT

      public static final String SWITCH_FORWARD_FOUND_MONITOR_EVENT
      See Also:
    • SWITCH_FORWARD_NOT_FOUND_MONITOR_EVENT

      public static final String SWITCH_FORWARD_NOT_FOUND_MONITOR_EVENT
      See Also:
  • Constructor Details

    • SwitchPipe

      public SwitchPipe()
  • Method Details

    • configure

      public void configure() throws ConfigurationException
      If no styleSheetName is specified, the switch uses the root node.
      Specified by:
      configure in interface IConfigurable
      Overrides:
      configure in class AbstractPipe
      Throws:
      ConfigurationException - in case it was not able to configure the component.
    • start

      public void start()
      Description copied from interface: IPipe
      Perform necessary action to start the pipe. This method is executed after the IConfigurable.configure() method, for each start and stop command of the adapter.
      Specified by:
      start in interface IPipe
      Specified by:
      start in interface org.springframework.context.Lifecycle
      Overrides:
      start in class AbstractPipe
    • stop

      public void stop()
      Description copied from interface: IPipe
      Perform necessary actions to stop the Pipe.
      For instance, closing JMS connections, DBMS connections etc.
      Specified by:
      stop in interface IPipe
      Specified by:
      stop in interface org.springframework.context.Lifecycle
      Overrides:
      stop in class AbstractPipe
    • doPipe

      public @NonNull PipeRunResult doPipe(@NonNull Message message, @NonNull PipeLineSession session) throws PipeRunException
      This is where the action takes place, the switching is done. Pipes may only throw a PipeRunException, to be handled by the caller of this object.
      As WebLogic has the problem that when a not well-formed XML stream is given to `weblogic.xerces` the transformer gets corrupt, on an exception the configuration is done again, so that the transformer is re-initialized.
      Throws:
      PipeRunException
    • setStyleSheetName

      public void setStyleSheetName(String styleSheetName)
      stylesheet may return a string representing the forward to look up
      Default value
      a stylesheet that returns the name of the root-element
    • setXpathExpression

      public void setXpathExpression(String xpathExpression)
      xpath-expression that returns a string representing the forward to look up. It's possible to refer to a parameter (which e.g. contains a value from a sessionkey) by using the parameter name prefixed with $
    • setJsonPathExpression

      public void setJsonPathExpression(String jsonPathExpression)
      jsonPath expression to be applied to the input-message. if not set, no transformation is done when the input message is mediatype JSON
    • setNamespaceDefs

      public void setNamespaceDefs(String namespaceDefs)
      Namespace defintions for xpathExpression. Must be in the form of a comma or space separated list of prefix=namespaceuri-definitions. For some use other cases (NOT xpathExpression), one entry can be without a prefix, that will define the default namespace.
    • setNotFoundForwardName

      @Deprecated @ConfigurationWarning("it's no longer possible to set a custom [notFoundForward], you must add a forward named [notFound].") public void setNotFoundForwardName(String notFound)
      Deprecated.
      Forward returned when the forward derived from the stylesheet could not be found.
    • setEmptyForwardName

      @Deprecated @ConfigurationWarning("it's no longer possible to set a custom [emptyForwardName], you must add a forward named [empty].") public void setEmptyForwardName(String empty)
      Deprecated.
      Forward returned when the content, on which the switch is performed, is empty. if emptyforwardname is not specified, notfoundforwardname is used.
    • setXsltVersion

      public void setXsltVersion(int xsltVersion)
      If set to 2 or 3 a Saxon (net.sf.saxon) xslt processor 2.0 or 3.0 respectively will be used, otherwise xslt processor 1.0 (org.apache.xalan). 0 will auto-detect
      Default value
      0
    • setStoreForwardInSessionKey

      public void setStoreForwardInSessionKey(String storeForwardInSessionKey)
      Selected forward name will be stored in the specified session key.
    • setForwardNameSessionKey

      public void setForwardNameSessionKey(String forwardNameSessionKey)
      Session key that will be used to get the forward name from.
    • setNamespaceAware

      public void setNamespaceAware(boolean b)
      controls namespace-awareness of XSLT transformation
      Default value
      true
    • setPreserveInput

      public void setPreserveInput(boolean preserveInput)
      If set true, the result of the pipe is replaced with the original input (i.e. the input before configured replacements of getInputFromSessionKey, getInputFromFixedValue or emptyInputReplacement)

      Use this if you want to pass the original input message of this pipe to the branch, but want to select a branch based on a session-key value via IPipe.setGetInputFromSessionKey(String).

      Specified by:
      setPreserveInput in interface IPipe
      Overrides:
      setPreserveInput in class AbstractPipe