Class FixedResultPipe

All Implemented Interfaces:
HasTransactionAttribute, IConfigurable, IConfigurationAware, IForwardTarget, INamedObject, IPipe, IScopeProvider, IWithParameters, EventThrowing, HasStatistics, org.springframework.beans.factory.Aware, org.springframework.context.ApplicationContextAware

@Category(BASIC) @EnterpriseIntegrationPattern(TRANSLATOR) @Forward(name="filenotfound", description="the configured file was not found (when this forward isn\'t specified an exception will be thrown)") public class FixedResultPipe extends FixedForwardPipe
This Pipe opens and returns a file from the classpath. The filename is a mandatory parameter to use. You can provide this by using the filename attribute or with a param element to be able to use a sessionKey for instance.

Migrating from deprecated features

The FixedResultPipe was a jack of all trades. You could use it to read a file (only text) and/or use a 'resultString' to find / replace values in. The following migrations are available:

For using a 'resultString'

You can use the EchoPipe for a static value. This looked like this before:

 <pipe name="HelloWorld" className="org.frankframework.pipes.FixedResult" returnString="Hello World">
     <forward name="success" path="EXIT"/>
 </pipe>
 
Becomes:

 <pipe name="HelloWorld" className="org.frankframework.pipes.EchoPipe" getInputFromFixedValue="Hello World">
     <forward name="success" path="EXIT"/>
 </pipe>
 

For replacing a value

You can use the ReplacerPipe to replace a value in multiple ways. First, when you need to replace a placeholder with a parameter. This looked like:

 <pipe name="make unique message" className="org.frankframework.pipes.FixedResultPipe"
     returnString="&lt;msg mid=&quot;MID&quot; action=&quot;ACTION&quot; /&gt;" replaceFixedParams="true">
     <param name="MID" sessionKey="mid" />
     <param name="ACTION" xpathExpression="request/@action" />
 </pipe>
 
And can now be written like this (note the ?{..} syntax):

 <pipe name="make unique message" className="org.frankframework.pipes.ReplacerPipe"
     getInputFromFixedValue="&lt;msg mid=&quot;?{MID}&quot; action=&quot;?{ACTION}&quot; /&gt;">
     <param name="MID" sessionKey="mid" />
     <param name="ACTION" xpathExpression="request/@action" />
 </pipe>
 
When you need to replace a fixed value use the ReplacerPipe with find and replace. This looked like this:

 <FixedResultPipe name="InputValidateError"
     filename="ManageFileSystem/xml/ErrorMessage.xml"
     replaceFrom="%reasonCode" replaceTo="NOT_WELL_FORMED_XML">
     <forward name="success" path="EXIT" />
 </FixedResultPipe>
 
And now should be solved like this:

 <FixedResultPipe name="InputValidateError"
     filename="ManageFileSystem/xml/ErrorMessage.xml">
     <forward name="success" path="replaceReasonCode" />
 </FixedResultPipe>
 <ReplacerPipe name="replaceReasonCode"
     find="%reasonCode"
     replace="NOT_WELL_FORMED_XML">
     <forward name="success" path="EXIT" />
 </ReplacerPipe>
 
This is also an example of now using two pipes to achieve the same result. Each pipe has its own responsibility.

More complex configurations

In some cases, a combination of the above is needed to achieve what worked before. In some cases, FixedResultPipe was also used to store information in the session. For example, a port of configuration in the JMS listener sender configuration looked like this:

 <CompareStringPipe name="compareIdAndCid" >
     <param name="operand1" sessionKey="id"/>
     <param name="operand2" sessionKey="cid"/>
     <forward name="equals" path="IdAndCidSame" />
     <forward name="lessthan" path="IdAndCidDifferent" />
     <forward name="greaterthan" path="IdAndCidDifferent" />
 </CompareStringPipe>
 <FixedResultPipe name="IdAndCidSame" returnString="true" storeResultInSessionKey="IdAndCidSame">
     <forward name="success" path="displayKeys" />
 </FixedResultPipe>
 <FixedResultPipe name="IdAndCidDifferent" returnString="false" storeResultInSessionKey="IdAndCidSame">
     <forward name="success" path="displayKeys" />
 </FixedResultPipe>

 <pipe name="displayKeys" className="org.frankframework.pipes.FixedResultPipe"
     returnString="branch [BRANCH] Orignal Id [MID] cid [CID] id=cid [SAME]" replaceFixedParams="true">
     <param name="BRANCH" sessionKey="originalMessage" xpathExpression="*&#47;@branch" />
     <param name="MID" sessionKey="id" />
     <param name="CID" sessionKey="cid" />
     <param name="SAME" sessionKey="IdAndCidSame" />
     <forward name="success" path="EXIT" />
 </pipe>
 
Was rewritten to the following:

 <CompareStringPipe name="compareIdAndCid" >
     <param name="operand1" sessionKey="id"/>
     <param name="operand2" sessionKey="cid"/>
     <forward name="equals" path="IdAndCidSame" />
     <forward name="lessthan" path="IdAndCidDifferent" />
     <forward name="greaterthan" path="IdAndCidDifferent" />
 </CompareStringPipe>

 <PutInSessionPipe name="IdAndCidSame" value="true" sessionKey="IdAndCidSame">
     <forward name="success" path="putOriginalMessageInSession" />
 </PutInSessionPipe>
 <PutInSessionPipe name="IdAndCidDifferent" value="false" sessionKey="IdAndCidSame">
     <forward name="success" path="putOriginalMessageInSession" />
 </PutInSessionPipe>

 <PutInSessionPipe name="putOriginalMessageInSession" sessionKey="incomingMessage"/>

 <pipe name="displayKeys" className="org.frankframework.pipes.ReplacerPipe"
     getInputFromFixedValue="branch [?{BRANCH}] Original Id [?{MID}] cid [?{CID}] id=cid [?{SAME}]">
     <param name="BRANCH" sessionKey="originalMessage" xpathExpression="*&#47;@branch" />
     <param name="MID" sessionKey="id" />
     <param name="CID" sessionKey="cid" />
     <param name="SAME" sessionKey="IdAndCidSame" />
     <forward name="success" path="EXIT" />
 </pipe>
 

The features/documentation of the deprecated features

Produces a fixed result that does not depend on the input message. It may return the contents of a file when filename or filenameSessionKey is specified. Otherwise, the value of attribute returnString is returned.

Using parameters and the attributes of this pipe, it is possible to substitute values. This pipe performs the following steps:
  1. During execution, this pipe first obtains a string based on attributes returnString, filename or filenameSessionKey.
  2. The resulting string is transformed according to attributes replaceFrom and replaceTo if set. Please note that the plain value of attribute replaceFrom is matched, no ?{...} here.
  3. The resulting string is substituted based on the parameters of this pipe. This step depends on attribute replaceFixedParams. Assume that there is a parameter with name xyz. If replaceFixedParams is false, then each occurrence of ?{xyz} is replaced by the parameter's value. Otherwise, the text xyz is substituted. See Parameter to see how parameter values are determined.
  4. If attribute substituteVars is true, then expressions ${...} are substituted using system properties, pipelinesession variables and application properties. Please note that no ${...} patterns are left if the initial string came from attribute returnString, because any ${...} pattern in attribute returnString is substituted when the configuration is loaded.
  5. If attribute styleSheetName is set, then the referenced XSLT stylesheet is applied to the resulting string.

Many attributes of this pipe reference file names. If a file is referenced by a relative path, the path is relative to the configuration's root directory.
Parameters
Used for substitution. For a parameter named xyz, the string ?{xyz} or xyz (if replaceFixedParams is true) is substituted by the parameter's value.
  • Constructor Details

    • FixedResultPipe

      public FixedResultPipe()
  • Method Details

    • configure

      public void configure() throws ConfigurationException
      checks for correct configuration, and translates the filename to a file, to check existence. If a filename or filenameSessionKey was specified, the contents of the file is put in the returnString, so that the returnString may always be returned.
      Specified by:
      configure in interface IConfigurable
      Specified by:
      configure in interface IPipe
      Overrides:
      configure in class FixedForwardPipe
      Throws:
      ConfigurationException
    • doPipe

      public PipeRunResult doPipe(Message message, PipeLineSession session) throws PipeRunException
      Description copied from interface: IPipe
      This is where the action takes place. Pipes may only throw a PipeRunException, to be handled by the caller of this object. Implementations must either consume the message, or pass it on to the next Pipe in the PipeRunResult. If the result of the Pipe does not depend on the input, like for the FixedResultPipe, the Pipe can schedule the input to be closed at session exit, by calling Message.closeOnCloseOf(PipeLineSession, String) This allows the previous Pipe to release any resources (e.g. connections) that it might have kept open until the message was consumed. Doing so avoids connections leaking from pools, while it enables efficient streaming processing of data while it is being read from a stream.
      Throws:
      PipeRunException
    • setSubstituteVars

      @Deprecated(since="8.2", forRemoval=true) @ConfigurationWarning("substituteVars is scheduled for removal. Please use the ReplacerPipe") public void setSubstituteVars(boolean substitute)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Should values between ${ and } be resolved. If true, the search order of replacement values is: system properties (1), PipelineSession variables (2), application properties (3).
      Default value
      false
    • setFilename

      public void setFilename(String filename)
      Name of the file containing the result message.
    • setFilenameSessionKey

      @Deprecated(since="8.2", forRemoval=true) @ConfigurationWarning("fileNameSessionKey is scheduled for removal. Please use a <param> if you need a session value") public void setFilenameSessionKey(String filenameSessionKey)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Name of the session key containing the file name of the file containing the result message.
    • setReturnString

      @Deprecated(since="8.2", forRemoval=true) @ConfigurationWarning("returnString is scheduled for removal. Please use the ReplacerPipe or EchoPipe if you need to control the output string") public void setReturnString(String returnString)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Returned message.
    • setReplaceFrom

      @Deprecated(since="8.2", forRemoval=true) @ConfigurationWarning("replaceFrom is scheduled for removal. Please use the ReplacerPipe") public void setReplaceFrom(String replaceFrom)
      Deprecated, for removal: This API element is subject to removal in a future version.
      If set, every occurrence of this attribute's value is replaced by the value of replaceTo.
    • setReplaceTo

      @Deprecated(since="8.2", forRemoval=true) @ConfigurationWarning("replaceTo is scheduled for removal. Please use the ReplacerPipe") public void setReplaceTo(String replaceTo)
      Deprecated, for removal: This API element is subject to removal in a future version.
      See replaceFrom.
    • setStyleSheetName

      @Deprecated(since="8.2", forRemoval=true) @ConfigurationWarning("styleSheetName is scheduled for removal. Please use the XsltPipe") public void setStyleSheetName(String styleSheetName)
      Deprecated, for removal: This API element is subject to removal in a future version.
      File name of XSLT stylesheet to apply.
    • setReplaceFixedParams

      @Deprecated(since="8.2", forRemoval=true) @ConfigurationWarning("replaceFixedParams is scheduled for removal. Please use the ReplacerPipe") public void setReplaceFixedParams(boolean b)
      Deprecated, for removal: This API element is subject to removal in a future version.
      When set true, parameter replacement matches name-of-parameter, not ?{name-of-parameter}
      Default value
      false
    • setUseOldSubstitutionStartDelimiter

      @Deprecated(since="8.1", forRemoval=true) @ConfigurationWarning("please use ?{key} instead where possible so it\'s clear when to use properties and when to use session variables") public void setUseOldSubstitutionStartDelimiter(boolean old)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • getSubstitutionStartDelimiter

      public String getSubstitutionStartDelimiter()
    • getFilename

      public String getFilename()
    • getFilenameSessionKey

      public String getFilenameSessionKey()
    • getReturnString

      public String getReturnString()
    • isSubstituteVars

      public boolean isSubstituteVars()
    • getReplaceFrom

      public String getReplaceFrom()
    • getReplaceTo

      public String getReplaceTo()
    • getStyleSheetName

      public String getStyleSheetName()
    • isReplaceFixedParams

      public boolean isReplaceFixedParams()