Class AbstractPipe
- 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:
CompareIntegerPipe,CompareStringPipe,ExceptionPipe,FixedForwardPipe,ForPipe,IfPipe,IsXmlPipe,RegExPipe,SwitchPipe
Pipe.
A Pipe represents an action to take in a Pipeline. This class is meant to be extended
for defining steps or actions to take to complete a request. The contract is that a pipe is created (by the digester),
setName(String) is called and
other setters are called, and then IConfigurable.configure() is called, optionally
throwing a ConfigurationException. As much as possible, class instantiating should take place in the
IConfigurable.configure() method.
The object remains alive while the framework is running. When the pipe is to be run,
the doPipe method is activated.
For the duration of the processing of a message by the pipeline has a pipeLineSession.
By this mechanism, pipes may communicate with one another.
However, use this functionality with caution, as it is not desirable to make pipes dependent
on each other. If a pipe expects something in a session, it is recommended that
the key under which the information is stored is configurable (has a setter for this keyname).
Also, the setting of something in the PipeLineSession should be done using
this technique (specifying the key under which to store the value by a parameter).
Since 4.1 this class also has parameters, so that descendants of this class automatically are parameter-enabled. However, your documentation should say if and how parameters are used!
All pipes support a forward named 'exception' which will be followed in the pipeline in case the PipeRunExceptions are not handled by the pipe itself
- Author:
- Johan Verrips / Gerrit van Brakel
- See Also:
-
Field Summary
FieldsFields 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 TypeMethodDescriptionvoidaddForward(PipeForward forward) Forwards are used to determine the next Pipe to execute in the Pipeline.voidaddParameter(IParameter param) Adds a parameter to the list of parameters.voidbooleanconsumesSessionVariable(String sessionKey) returnstrueif the pipe or one of its children use the named session variable.protected <T> TcreateBean(Class<T> beanClass) findForward(String forward) Looks up a key in the pipeForward hashtable.Get pipe forwards.Returns the parameters.booleanhasRegisteredForward(String forward) booleanvoidregisterEvent(String description) Register an event for flexible monitoring.final voidsetApplicationContext(org.springframework.context.ApplicationContext applicationContext) The method has been madefinalto ensure nobody overrides this.voidsetChompCharSize(String string) If set (>=0) and the character data length inside a xml element exceeds this size, the character data is chomped (with a clear comment)voidsetDurationThreshold(long maxDuration) If durationThreshold >=0 and the duration of the message processing exceeded the value specified (in milliseconds) the message will be logged and a monitor event will be fired.voidsetElementToMove(String string) If set, the character data in this element is stored under a session key and in the message replaced by a reference to this session key: {sessionKey: +elementToMoveSessionKey+ }voidsetElementToMoveChain(String string) LikeelementToMovebut element is preceded with all ancestor elements and separated by semicolons (e.g.voidsetElementToMoveSessionKey(String string) (Only used whenelementToMoveis set) Name of the session key under which the character data is storedvoidsetEmptyInputReplacement(String string) If set and the input is empty, this fixed value is taken as inputvoidsetGetInputFromFixedValue(String string) If set, this fixed value is taken as input, instead of regular inputvoidsetGetInputFromSessionKey(String string) If set, input is taken from this session key, instead of regular inputvoidsetHideRegex(String hideRegex) Regular expression to mask strings in the log.voidOptional Locker, to avoid parallel execution of the Pipe by multiple threads or servers.voidsetLogIntermediaryResults(String string) when set, the value in AppConstants is overwritten (for this pipe only)voidsetMaxThreads(int newMaxThreads) The maximum number of threads that mayprocess messagessimultaneously.voidThe functional name of this pipe.voidsetPreserveInput(boolean preserveInput) If settrue, the result of the pipe is replaced with the original input (i.e. the input before configured replacements ofgetInputFromSessionKey,getInputFromFixedValueoremptyInputReplacement)voidsetRemoveCompactMsgNamespaces(boolean b) voidsetRestoreMovedElements(boolean restoreMovedElements) If settrue, compacted messages in the result are restored to their original format (see alsoIPipe.setElementToMove(java.lang.String))voidsetSecLogSessionKeys(String string) (only used whenwriteToSecLogistrue) comma separated list of keys of session variables that is appended to the security log recordvoidsetSizeStatistics(boolean sizeStatistics) Toggle if message-size statistics should be collected and aggregated.voidsetStoreResultInSessionKey(String string) If set, the pipe result is copied to a session key that has the name defined by this attribute.voidsetWriteToSecLog(boolean b) Iftrue, a record is written to the security log when the pipe has finished successfully.booleanvoidstart()Perform necessary action to start the pipe.voidstop()Perform necessary actions to stop thePipe.
For instance, closing JMS connections, DBMS connections etc.voidthrowEvent(String event, Message message) Methods 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
doPipe, getChompCharSize, getDurationThreshold, getElementToMove, getElementToMoveChain, getElementToMoveSessionKey, getEmptyInputReplacement, getGetInputFromFixedValue, getGetInputFromSessionKey, getHideRegex, getLocker, getLogIntermediaryResults, getMaxThreads, getSecLogSessionKeys, getStoreResultInSessionKey, isPreserveInput, isRemoveCompactMsgNamespaces, isRestoreMovedElements, isWriteToSecLog, setPipeLine, throwEvent
-
Field Details
-
parameterNamesMustBeUnique
protected boolean parameterNamesMustBeUnique
-
-
Constructor Details
-
AbstractPipe
public AbstractPipe()
-
-
Method Details
-
configure
configure()is called after thePipelineis registered at theAdapter. The purpose of this method is to reduce creating connections to databases, etc. in thedoPipe()method. As much as possible, class instantiation should take place in theconfigure()method to improve performance.- Specified by:
configurein interfaceIConfigurable- Overrides:
configurein classTransactionAttributes- Throws:
ConfigurationException- in case it was not able to configure the component.
-
setApplicationContext
public final void setApplicationContext(@Nonnull org.springframework.context.ApplicationContext applicationContext) The method has been madefinalto ensure nobody overrides this.- Specified by:
setApplicationContextin interfaceorg.springframework.context.ApplicationContextAware
-
createBean
-
start
public void start()Description copied from interface:IPipePerform necessary action to start the pipe. This method is executed after theIConfigurable.configure()method, for each start and stop command of the adapter. -
stop
public void stop()Description copied from interface:IPipePerform necessary actions to stop thePipe.
For instance, closing JMS connections, DBMS connections etc. -
isRunning
public boolean isRunning()- Specified by:
isRunningin interfaceorg.springframework.context.Lifecycle
-
addParameter
Adds a parameter to the list of parameters.- Specified by:
addParameterin interfaceIWithParameters
-
getParameterList
Returns the parameters.- Specified by:
getParameterListin interfaceIWithParameters
-
setLocker
Description copied from interface:IPipeOptional Locker, to avoid parallel execution of the Pipe by multiple threads or servers. An exception is thrown when the lock cannot be obtained, e.g. in case another thread, may be in another server, holds the lock and does not release it in a timely manner. -
addForward
Forwards are used to determine the next Pipe to execute in the Pipeline.- Specified by:
addForwardin interfaceIPipe- See Also:
-
hasRegisteredForward
-
findForward
Looks up a key in the pipeForward hashtable.
A typical use would be on return from a Pipe:
findForward searches:return new PipeRunResult(findForward("success"), result);- All forwards defined in XML under the pipe element of this pipe.
- All global forwards defined in XML under the PipeLine element.
- All pipe names with their (identical) path.
-
getForwards
Description copied from interface:IPipeGet pipe forwards.- Specified by:
getForwardsin interfaceIPipe
-
getEventSourceName
- Specified by:
getEventSourceNamein interfaceEventThrowing
-
registerEvent
Description copied from interface:IPipeRegister an event for flexible monitoring.- Specified by:
registerEventin interfaceIPipe
-
throwEvent
- Specified by:
throwEventin interfaceIPipe
-
getAdapter
- Specified by:
getAdapterin interfaceEventThrowing
-
consumesSessionVariable
Description copied from interface:IPipereturnstrueif the pipe or one of its children use the named session variable. Callers can use this to determine if a message needs to be preserved.- Specified by:
consumesSessionVariablein interfaceIPipe
-
setName
The functional name of this pipe. It can be referenced by thepathattribute of aPipeForward. -
setGetInputFromSessionKey
Description copied from interface:IPipeIf set, input is taken from this session key, instead of regular input- Specified by:
setGetInputFromSessionKeyin interfaceIPipe
-
setGetInputFromFixedValue
Description copied from interface:IPipeIf set, this fixed value is taken as input, instead of regular input- Specified by:
setGetInputFromFixedValuein interfaceIPipe
-
setEmptyInputReplacement
Description copied from interface:IPipeIf set and the input is empty, this fixed value is taken as input- Specified by:
setEmptyInputReplacementin interfaceIPipe
-
setPreserveInput
public void setPreserveInput(boolean preserveInput) Description copied from interface:IPipeIf settrue, the result of the pipe is replaced with the original input (i.e. the input before configured replacements ofgetInputFromSessionKey,getInputFromFixedValueoremptyInputReplacement)- Specified by:
setPreserveInputin interfaceIPipe
-
setStoreResultInSessionKey
If set, the pipe result is copied to a session key that has the name defined by this attribute. The pipe result is still written as the output message as usual.- Specified by:
setStoreResultInSessionKeyin interfaceIPipe
-
setMaxThreads
public void setMaxThreads(int newMaxThreads) The maximum number of threads that mayprocess messagessimultaneously. A value of 0 indicates an unlimited number of threads.- Default value
- 0
-
setChompCharSize
Description copied from interface:IPipeIf set (>=0) and the character data length inside a xml element exceeds this size, the character data is chomped (with a clear comment)- Specified by:
setChompCharSizein interfaceIPipe
-
setElementToMove
Description copied from interface:IPipeIf set, the character data in this element is stored under a session key and in the message replaced by a reference to this session key: {sessionKey: +elementToMoveSessionKey+ }- Specified by:
setElementToMovein interfaceIPipe
-
setElementToMoveSessionKey
Description copied from interface:IPipe(Only used whenelementToMoveis set) Name of the session key under which the character data is stored- Specified by:
setElementToMoveSessionKeyin interfaceIPipe
-
setElementToMoveChain
Description copied from interface:IPipeLikeelementToMovebut element is preceded with all ancestor elements and separated by semicolons (e.g. 'adapter;pipeline;pipe')- Specified by:
setElementToMoveChainin interfaceIPipe
-
setDurationThreshold
public void setDurationThreshold(long maxDuration) Description copied from interface:IPipeIf durationThreshold >=0 and the duration of the message processing exceeded the value specified (in milliseconds) the message will be logged and a monitor event will be fired.- Specified by:
setDurationThresholdin interfaceIPipe
-
setRemoveCompactMsgNamespaces
public void setRemoveCompactMsgNamespaces(boolean b) - Specified by:
setRemoveCompactMsgNamespacesin interfaceIPipe
-
setRestoreMovedElements
public void setRestoreMovedElements(boolean restoreMovedElements) Description copied from interface:IPipeIf settrue, compacted messages in the result are restored to their original format (see alsoIPipe.setElementToMove(java.lang.String))- Specified by:
setRestoreMovedElementsin interfaceIPipe
-
setSizeStatistics
public void setSizeStatistics(boolean sizeStatistics) Toggle if message-size statistics should be collected and aggregated. The default is controlled by the application propertystatistics.size. -
sizeStatisticsEnabled
public boolean sizeStatisticsEnabled()- Specified by:
sizeStatisticsEnabledin interfaceIPipe
-
setWriteToSecLog
public void setWriteToSecLog(boolean b) Iftrue, a record is written to the security log when the pipe has finished successfully.- Specified by:
setWriteToSecLogin interfaceIPipe
-
setSecLogSessionKeys
(only used whenwriteToSecLogistrue) comma separated list of keys of session variables that is appended to the security log record- Specified by:
setSecLogSessionKeysin interfaceIPipe
-
setLogIntermediaryResults
Description copied from interface:IPipewhen set, the value in AppConstants is overwritten (for this pipe only)- Specified by:
setLogIntermediaryResultsin interfaceIPipe
-
setHideRegex
Description copied from interface:IPipeRegular expression to mask strings in the log. For example, the regular expression(?<=<password>).*?(?=</password>)will replace every character between keys '<password>' and '</password>'. note: this feature is used at adapter level, so ahideRegexset on one pipe affects all pipes in the pipeline (and multiple values in different pipes are combined into a single regex). The regular expressions are matched against part of the log lines. SeeStringUtil.hideAll(String, Collection, int)withmode = 0for how regular expressions are matched and replaced.- Specified by:
setHideRegexin interfaceIPipe
-