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:
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
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] Orignal 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
,filename
orfilenameSessionKey
. - The resulting string is transformed according to attributes
replaceFrom
andreplaceTo
if set. Please note that the plain value of attributereplaceFrom
is 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
. IfreplaceFixedParams
isfalse
, then each occurrence of?{xyz}
is replaced by the parameter's value. Otherwise, the textxyz
is substituted. SeeParameter
to see how parameter values are determined. - If attribute
substituteVars
istrue
, 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 attributereturnString
, because any${...}
pattern in attributereturnString
is substituted when the configuration is loaded. - 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}
orxyz
(ifreplaceFixedParams
is true) is substituted by the parameter's value.
-
Field Summary
Fields inherited from class org.frankframework.pipes.AbstractPipe
parameterNamesMustBeUnique
Fields inherited from class org.frankframework.core.TransactionAttributes
log
Fields inherited from interface org.frankframework.core.IPipe
LONG_DURATION_MONITORING_EVENT, MESSAGE_SIZE_MONITORING_EVENT, PIPE_EXCEPTION_MONITORING_EVENT
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
checks 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.boolean
boolean
void
setFilename
(String filename) Name of the file containing the result message.void
setFilenameSessionKey
(String filenameSessionKey) Deprecated, for removal: This API element is subject to removal in a future version.void
setReplaceFixedParams
(boolean b) Deprecated, for removal: This API element is subject to removal in a future version.void
setReplaceFrom
(String replaceFrom) Deprecated, for removal: This API element is subject to removal in a future version.void
setReplaceTo
(String replaceTo) Deprecated, for removal: This API element is subject to removal in a future version.void
setReturnString
(String returnString) Deprecated, for removal: This API element is subject to removal in a future version.void
setStyleSheetName
(String styleSheetName) Deprecated, for removal: This API element is subject to removal in a future version.void
setSubstituteVars
(boolean substitute) Deprecated, for removal: This API element is subject to removal in a future version.void
setUseOldSubstitutionStartDelimiter
(boolean old) Deprecated, for removal: This API element is subject to removal in a future version.Methods inherited from class org.frankframework.pipes.FixedForwardPipe
getIfParam, getIfValue, getOnlyIfSessionKey, getOnlyIfValue, getParameterValue, getSuccessForward, getUnlessSessionKey, getUnlessValue, isSkipOnEmptyInput, setIfParam, setIfValue, setOnlyIfSessionKey, setOnlyIfValue, setSkipOnEmptyInput, setUnlessSessionKey, setUnlessValue, skipPipe
Methods inherited from class org.frankframework.pipes.AbstractPipe
addForward, addParameter, consumesSessionVariable, createBean, findForward, getAdapter, getApplicationContext, getChompCharSize, getConfigurationClassLoader, getDurationThreshold, getElementToMove, getElementToMoveChain, getElementToMoveSessionKey, getEmptyInputReplacement, getEventSourceName, getForwards, getGetInputFromFixedValue, getGetInputFromSessionKey, getHideRegex, getLocker, getLogIntermediaryResults, getMaxThreads, getName, getParameterList, getPipeLine, getSecLogSessionKeys, getStoreResultInSessionKey, hasRegisteredForward, isPreserveInput, isRemoveCompactMsgNamespaces, isRestoreMovedElements, isWriteToSecLog, registerEvent, setApplicationContext, setChompCharSize, setDurationThreshold, setElementToMove, setElementToMoveChain, setElementToMoveSessionKey, setEmptyInputReplacement, setEventPublisher, setGetInputFromFixedValue, setGetInputFromSessionKey, setHideRegex, setLocker, setLogIntermediaryResults, setMaxThreads, setName, setPipeLine, setPreserveInput, setRemoveCompactMsgNamespaces, setRestoreMovedElements, setSecLogSessionKeys, setSizeStatistics, setStoreResultInSessionKey, setWriteToSecLog, sizeStatisticsEnabled, start, stop, throwEvent
Methods inherited from class org.frankframework.core.TransactionAttributes
configureTransactionAttributes, getTransactionAttribute, getTransactionTimeout, getTxDef, isTransacted, isTransacted, setTransacted, setTransactionAttribute, setTransactionTimeout
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.frankframework.core.IPipe
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 is put in thereturnString
, so that thereturnString
may always be returned.- Specified by:
configure
in interfaceIConfigurable
- Specified by:
configure
in interfaceIPipe
- Overrides:
configure
in classFixedForwardPipe
- Throws:
ConfigurationException
-
doPipe
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 theFixedResultPipe
, the Pipe can schedule the input to be closed at session exit, by callingMessage.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
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 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 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 settrue
, 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. -
getSubstitutionStartDelimiter
-
getFilename
-
getFilenameSessionKey
-
getReturnString
-
isSubstituteVars
public boolean isSubstituteVars() -
getReplaceFrom
-
getReplaceTo
-
getStyleSheetName
-
isReplaceFixedParams
public boolean isReplaceFixedParams()
-