Package org.frankframework.pipes
Class FixedResultPipe
java.lang.Object
org.frankframework.core.TransactionAttributes
org.frankframework.pipes.AbstractPipe
org.frankframework.pipes.FixedForwardPipe
org.frankframework.pipes.FixedResultPipe
- 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
@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
Using parameters and the attributes of this pipe, it is possible to substitute values. This pipe performs the following steps:
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.
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 theEchoPipe 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 theReplacerPipe 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="<msg mid="MID" action="ACTION" />" 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="<msg mid="?{MID}" action="?{ACTION}" />">
<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] Original Id [MID] cid [CID] id=cid [SAME]" replaceFixedParams="true">
<param name="BRANCH" sessionKey="originalMessage" xpathExpression="*/@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="*/@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 whenfilename 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:
- During execution, this pipe first obtains a string based on attributes
returnString,filenameorfilenameSessionKey. - The resulting string is transformed according to attributes
replaceFromandreplaceToif set. Please note that the plain value of attributereplaceFromis matched, no?{...}here. - 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 namexyz. IfreplaceFixedParamsisfalse, then each occurrence of?{xyz}is replaced by the parameter's value. Otherwise, the textxyzis substituted. SeeParameterto see how parameter values are determined. - If attribute
substituteVarsistrue, then expressions${...}are substituted using system properties, pipeline session variables and application properties. Please note that no${...}patterns are left if the initial string came from attributereturnString, because any${...}pattern in attributereturnStringis substituted when the configuration is loaded. - If attribute
styleSheetNameis 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}orxyz(ifreplaceFixedParamsis true) is substituted by the parameter's value.
-
Field Summary
Fields inherited from class org.frankframework.pipes.AbstractPipe
parameterNamesMustBeUniqueFields inherited from class org.frankframework.core.TransactionAttributes
logFields inherited from interface org.frankframework.core.IPipe
LONG_DURATION_MONITORING_EVENT, MESSAGE_SIZE_MONITORING_EVENT, PIPE_EXCEPTION_MONITORING_EVENT -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidChecks for correct configuration and translates the filename to a file to check existence.doPipe(Message message, PipeLineSession session) This is where the action takes place.voidsetFilename(String filename) Name of the file containing the result message.voidsetFilenameSessionKey(String filenameSessionKey) Deprecated, for removal: This API element is subject to removal in a future version.voidsetReplaceFixedParams(boolean b) Deprecated, for removal: This API element is subject to removal in a future version.voidsetReplaceFrom(String replaceFrom) Deprecated, for removal: This API element is subject to removal in a future version.voidsetReplaceTo(String replaceTo) Deprecated, for removal: This API element is subject to removal in a future version.voidsetReturnString(String returnString) Deprecated, for removal: This API element is subject to removal in a future version.voidsetStyleSheetName(String styleSheetName) Deprecated, for removal: This API element is subject to removal in a future version.voidsetSubstituteVars(boolean substitute) Deprecated, for removal: This API element is subject to removal in a future version.voidsetUseOldSubstitutionStartDelimiter(boolean old) Deprecated, for removal: This API element is subject to removal in a future version.Methods inherited from class org.frankframework.pipes.FixedForwardPipe
getParameterValue, setIfParam, setIfValue, setOnlyIfSessionKey, setOnlyIfValue, setSkipOnEmptyInput, setUnlessSessionKey, setUnlessValue, skipPipeMethods inherited from class org.frankframework.pipes.AbstractPipe
addForward, addParameter, consumesSessionVariable, createBean, findForward, getAdapter, getEventSourceName, getForwards, getParameterList, hasRegisteredForward, isRunning, registerEvent, setApplicationContext, setChompCharSize, setDurationThreshold, setElementToMove, setElementToMoveChain, setElementToMoveSessionKey, setEmptyInputReplacement, setGetInputFromFixedValue, setGetInputFromSessionKey, setHideRegex, setLocker, setLogIntermediaryResults, setMaxThreads, setName, setPreserveInput, setRemoveCompactMsgNamespaces, setRestoreMovedElements, setSecLogSessionKeys, setSizeStatistics, setStoreResultInSessionKey, setWriteToSecLog, sizeStatisticsEnabled, start, stop, throwEventMethods inherited from class org.frankframework.core.TransactionAttributes
configureTransactionAttributes, isTransacted, isTransacted, setTransacted, setTransactionTimeoutMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.frankframework.core.FrankElement
addConfigWarningMethods inherited from interface org.frankframework.core.HasApplicationContext
getApplicationContext, getConfigurationClassLoaderMethods inherited from interface org.frankframework.core.HasTransactionAttribute
getTransactionAttribute, getTransactionTimeout, getTxDef, setTransactionAttributeMethods inherited from interface org.frankframework.core.IForwardTarget
getNameMethods inherited from interface org.frankframework.core.IPipe
getChompCharSize, getDurationThreshold, getElementToMove, getElementToMoveChain, getElementToMoveSessionKey, getEmptyInputReplacement, getGetInputFromFixedValue, getGetInputFromSessionKey, getHideRegex, getLocker, getLogIntermediaryResults, getMaxThreads, getSecLogSessionKeys, getStoreResultInSessionKey, isPreserveInput, isRemoveCompactMsgNamespaces, isRestoreMovedElements, isWriteToSecLog, setPipeLine, throwEvent
-
Constructor Details
-
FixedResultPipe
public FixedResultPipe()
-
-
Method Details
-
configure
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 are put in thereturnString, so that thereturnStringmay always be returned.- Specified by:
configurein interfaceIConfigurable- Overrides:
configurein classFixedForwardPipe- Throws:
ConfigurationException
-
doPipe
Description copied from interface:IPipeThis 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.- 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. Iftrue, the search order of replacement values is: system properties (1), PipelineSession variables (2), and application properties (3).- Default value
- false
-
setFilename
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 that contains 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 ofreplaceTo. -
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.SeereplaceFrom. -
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 the 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.Iftrue, parameter replacement matchesname-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.
-