Class XmlSwitch

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

@Forward(name="*",description="name of the root-element") @Forward(name="*",description="result of transformation, when <code>styleSheetName</code> or <code>xpathExpression</code> is specified") @Category(BASIC) @EnterpriseIntegrationPattern(ROUTER) public class XmlSwitch extends AbstractPipe
Selects an exitState, based on either the content of the input message, by means of a XSLT-stylesheet, the content of a session variable or, by default, by returning the name of the root-element.
Author:
Johan Verrips
  • Field Details

    • XML_SWITCH_FORWARD_FOUND_MONITOR_EVENT

      public static final String XML_SWITCH_FORWARD_FOUND_MONITOR_EVENT
      See Also:
    • XML_SWITCH_FORWARD_NOT_FOUND_MONITOR_EVENT

      public static final String XML_SWITCH_FORWARD_NOT_FOUND_MONITOR_EVENT
      See Also:
  • Constructor Details

    • XmlSwitch

      public XmlSwitch()
  • 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
      Specified by:
      configure in interface IPipe
      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 IPipe.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 PipeRunResult doPipe(Message message, 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 $
    • 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

      public void setNotFoundForwardName(String notFound)
      Forward returned when the pipename derived from the stylesheet could not be found.
    • setEmptyForwardName

      public void setEmptyForwardName(String empty)
      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
    • getStyleSheetName

      public String getStyleSheetName()
    • getXpathExpression

      public String getXpathExpression()
    • getNamespaceDefs

      public String getNamespaceDefs()
    • getStoreForwardInSessionKey

      public String getStoreForwardInSessionKey()
    • getNotFoundForwardName

      public String getNotFoundForwardName()
    • getEmptyForwardName

      public String getEmptyForwardName()
    • getXsltVersion

      public int getXsltVersion()
    • getForwardNameSessionKey

      public String getForwardNameSessionKey()
    • isNamespaceAware

      public boolean isNamespaceAware()