Class AbstractPipe
- All Implemented Interfaces:
HasTransactionAttribute
,IConfigurable
,IConfigurationAware
,IForwardTarget
,INamedObject
,IPipe
,IScopeProvider
,IWithParameters
,EventThrowing
,HasStatistics
,org.springframework.beans.factory.Aware
,org.springframework.context.ApplicationContextAware
- Direct Known Subclasses:
CompareIntegerPipe
,CompareStringPipe
,ExceptionPipe
,FilenameSwitch
,FixedForwardPipe
,ForPipe
,IsXmlPipe
,RegExPipe
,XmlIf
,XmlSwitch
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 IPipe.configure()
is called, optionally
throwing a ConfigurationException
. As much as possible, class instantiating should take place in the
IPipe.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
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
addForward
(PipeForward forward) Forwards are used to determine the next Pipe to execute in the Pipelinevoid
addParameter
(IParameter param) Add a parameter to the list of parametersvoid
boolean
consumesSessionVariable
(String sessionKey) returnstrue
if the pipe or one of its children use the named session variable.protected <T> T
createBean
(Class<T> beanClass) findForward
(String forward) Looks up a key in the pipeForward hashtable.org.springframework.context.ApplicationContext
This ClassLoader is set upon creation of the object, used to retrieve resources configured by the Ibis application.long
Get pipe forwards.int
Indicates the maximum number of threads that may calldoPipe()
simultaneously.getName()
return the Parametersboolean
hasRegisteredForward
(String forward) boolean
boolean
boolean
boolean
void
registerEvent
(String description) Register an event for flexible monitoring.final void
setApplicationContext
(org.springframework.context.ApplicationContext applicationContext) final method to ensure nobody overrides this...void
setChompCharSize
(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)void
setDurationThreshold
(long maxDuration) If durationThreshold >=0 and the duration of the message processing exceeded the value specified (in milliseconds) the message is logged informatory to be analyzedvoid
setElementToMove
(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
+ }void
setElementToMoveChain
(String string) LikeelementToMove
but element is preceded with all ancestor elements and separated by semicolons (e.g.void
setElementToMoveSessionKey
(String string) (Only used whenelementToMove
is set) Name of the session key under which the character data is storedvoid
setEmptyInputReplacement
(String string) If set and the input is empty, this fixed value is taken as inputvoid
setEventPublisher
(EventPublisher eventPublisher) void
setGetInputFromFixedValue
(String string) If set, this fixed value is taken as input, instead of regular inputvoid
setGetInputFromSessionKey
(String string) If set, input is taken from this session key, instead of regular inputvoid
setHideRegex
(String hideRegex) Regular expression to mask strings in the log.void
Optional Locker, to avoid parallel execution of the Pipe by multiple threads or servers.void
setLogIntermediaryResults
(String string) when set, the value in AppConstants is overwritten (for this pipe only)void
setMaxThreads
(int newMaxThreads) The maximum number of threads that mayprocess messages
simultaneously.void
The functional name of this pipe.void
setPipeLine
(PipeLine pipeLine) Allowing pipe to register things at Configuration time.void
setPreserveInput
(boolean preserveInput) If settrue
, the result of the pipe is replaced with the original input (i.e. the input before configured replacements ofgetInputFromSessionKey
,getInputFromFixedValue
oremptyInputReplacement
)void
setRemoveCompactMsgNamespaces
(boolean b) void
setRestoreMovedElements
(boolean restoreMovedElements) If settrue
, compacted messages in the result are restored to their original format (see alsoIPipe.setElementToMove(java.lang.String)
)void
setSecLogSessionKeys
(String string) (only used whenwriteToSecLog=true
) comma separated list of keys of session variables that is appended to the security log recordvoid
setSizeStatistics
(boolean sizeStatistics) Collect and aggregate Message size statisticsvoid
setStoreResultInSessionKey
(String string) If set, the pipe result is copied to a session key that has the name defined by this attribute.void
setWriteToSecLog
(boolean b) when set totrue
a record is written to the security log when the pipe has finished successfullyboolean
void
start()
Perform necessary action to start the pipe.void
stop()
Perform necessary actions to stop thePipe
.
For instance, closing JMS connections, DBMS connections etc.void
throwEvent
(String event, Message message) 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
doPipe, throwEvent
-
Field Details
-
parameterNamesMustBeUnique
protected boolean parameterNamesMustBeUnique
-
-
Constructor Details
-
AbstractPipe
public AbstractPipe()
-
-
Method Details
-
configure
configure()
is called after thePipeline
is registered at theAdapter
. Purpose of this method is to reduce creating connections to databases etc. in thedoPipe()
method. As much as possible class-instantiating should take place in theconfigure()
method, to improve performance.- Specified by:
configure
in interfaceIConfigurable
- Specified by:
configure
in interfaceIPipe
- Overrides:
configure
in classTransactionAttributes
- Throws:
ConfigurationException
-
setApplicationContext
public final void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) final method to ensure nobody overrides this...- Specified by:
setApplicationContext
in interfaceorg.springframework.context.ApplicationContextAware
-
createBean
-
start
Description copied from interface:IPipe
Perform necessary action to start the pipe. This method is executed after theIPipe.configure()
method, for each start and stop command of the adapter.- Specified by:
start
in interfaceIPipe
- Throws:
PipeStartException
-
stop
public void stop()Description copied from interface:IPipe
Perform necessary actions to stop thePipe
.
For instance, closing JMS connections, DBMS connections etc. -
addParameter
Add a parameter to the list of parameters- Specified by:
addParameter
in interfaceIWithParameters
-
getParameterList
return the Parameters- Specified by:
getParameterList
in interfaceIWithParameters
-
setLocker
Description copied from interface:IPipe
Optional 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:
addForward
in 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:IPipe
Get pipe forwards.- Specified by:
getForwards
in interfaceIPipe
-
getEventSourceName
- Specified by:
getEventSourceName
in interfaceEventThrowing
-
registerEvent
Description copied from interface:IPipe
Register an event for flexible monitoring.- Specified by:
registerEvent
in interfaceIPipe
-
throwEvent
- Specified by:
throwEvent
in interfaceIPipe
-
getAdapter
- Specified by:
getAdapter
in interfaceEventThrowing
- Specified by:
getAdapter
in interfaceHasStatistics
-
consumesSessionVariable
Description copied from interface:IPipe
returnstrue
if 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:
consumesSessionVariable
in interfaceIPipe
-
setName
The functional name of this pipe. Can be referenced by thepath
attribute of aPipeForward
.- Specified by:
setName
in interfaceINamedObject
-
setGetInputFromSessionKey
Description copied from interface:IPipe
If set, input is taken from this session key, instead of regular input- Specified by:
setGetInputFromSessionKey
in interfaceIPipe
-
setGetInputFromFixedValue
Description copied from interface:IPipe
If set, this fixed value is taken as input, instead of regular input- Specified by:
setGetInputFromFixedValue
in interfaceIPipe
-
setEmptyInputReplacement
Description copied from interface:IPipe
If set and the input is empty, this fixed value is taken as input- Specified by:
setEmptyInputReplacement
in interfaceIPipe
-
setPreserveInput
public void setPreserveInput(boolean preserveInput) Description copied from interface:IPipe
If settrue
, the result of the pipe is replaced with the original input (i.e. the input before configured replacements ofgetInputFromSessionKey
,getInputFromFixedValue
oremptyInputReplacement
)- Specified by:
setPreserveInput
in 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:
setStoreResultInSessionKey
in interfaceIPipe
-
setMaxThreads
public void setMaxThreads(int newMaxThreads) The maximum number of threads that mayprocess messages
simultaneously. A value of 0 indicates an unlimited number of threads.- Default value
- 0
-
setChompCharSize
Description copied from interface:IPipe
If 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:
setChompCharSize
in interfaceIPipe
-
setElementToMove
Description copied from interface:IPipe
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
+ }- Specified by:
setElementToMove
in interfaceIPipe
-
setElementToMoveSessionKey
Description copied from interface:IPipe
(Only used whenelementToMove
is set) Name of the session key under which the character data is stored- Specified by:
setElementToMoveSessionKey
in interfaceIPipe
-
setElementToMoveChain
Description copied from interface:IPipe
LikeelementToMove
but element is preceded with all ancestor elements and separated by semicolons (e.g. 'adapter;pipeline;pipe')- Specified by:
setElementToMoveChain
in interfaceIPipe
-
setDurationThreshold
public void setDurationThreshold(long maxDuration) Description copied from interface:IPipe
If durationThreshold >=0 and the duration of the message processing exceeded the value specified (in milliseconds) the message is logged informatory to be analyzed- Specified by:
setDurationThreshold
in interfaceIPipe
-
setRemoveCompactMsgNamespaces
public void setRemoveCompactMsgNamespaces(boolean b) - Specified by:
setRemoveCompactMsgNamespaces
in interfaceIPipe
-
setRestoreMovedElements
public void setRestoreMovedElements(boolean restoreMovedElements) Description copied from interface:IPipe
If settrue
, compacted messages in the result are restored to their original format (see alsoIPipe.setElementToMove(java.lang.String)
)- Specified by:
setRestoreMovedElements
in interfaceIPipe
-
setSizeStatistics
public void setSizeStatistics(boolean sizeStatistics) Collect and aggregate Message size statistics -
sizeStatisticsEnabled
public boolean sizeStatisticsEnabled()- Specified by:
sizeStatisticsEnabled
in interfaceIPipe
-
setWriteToSecLog
public void setWriteToSecLog(boolean b) when set totrue
a record is written to the security log when the pipe has finished successfully- Specified by:
setWriteToSecLog
in interfaceIPipe
-
setSecLogSessionKeys
(only used whenwriteToSecLog=true
) comma separated list of keys of session variables that is appended to the security log record- Specified by:
setSecLogSessionKeys
in interfaceIPipe
-
setLogIntermediaryResults
Description copied from interface:IPipe
when set, the value in AppConstants is overwritten (for this pipe only)- Specified by:
setLogIntermediaryResults
in interfaceIPipe
-
setHideRegex
Description copied from interface:IPipe
Regular 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 ahideRegex
set 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 = 0
for how regular expressions are matched and replaced.- Specified by:
setHideRegex
in interfaceIPipe
-
getConfigurationClassLoader
Description copied from interface:IScopeProvider
This ClassLoader is set upon creation of the object, used to retrieve resources configured by the Ibis application.- Specified by:
getConfigurationClassLoader
in interfaceIScopeProvider
- Returns:
- returns the ClassLoader created by the
ClassLoaderManager
.
-
getApplicationContext
public org.springframework.context.ApplicationContext getApplicationContext()- Specified by:
getApplicationContext
in interfaceIConfigurationAware
-
getName
Description copied from interface:IForwardTarget
The part of the object that identifies its destination: Thename
of the Pipe or thepath
of the PipeLineExit.- Specified by:
getName
in interfaceIConfigurationAware
- Specified by:
getName
in interfaceIForwardTarget
- Specified by:
getName
in interfaceINamedObject
-
getGetInputFromSessionKey
- Specified by:
getGetInputFromSessionKey
in interfaceIPipe
-
getGetInputFromFixedValue
- Specified by:
getGetInputFromFixedValue
in interfaceIPipe
-
getStoreResultInSessionKey
- Specified by:
getStoreResultInSessionKey
in interfaceIPipe
-
isPreserveInput
public boolean isPreserveInput()- Specified by:
isPreserveInput
in interfaceIPipe
-
getMaxThreads
public int getMaxThreads()Description copied from interface:IPipe
Indicates the maximum number of threads that may calldoPipe()
simultaneously. A value of 0 indicates an unlimited number of threads. Pipe implementations that are not thread-safe, i.e. wheredoPipe()
may only be called by one thread at a time, should make sure getMaxThreads always returns a value of 1.- Specified by:
getMaxThreads
in interfaceIPipe
-
getDurationThreshold
public long getDurationThreshold()- Specified by:
getDurationThreshold
in interfaceIPipe
-
getChompCharSize
- Specified by:
getChompCharSize
in interfaceIPipe
-
getElementToMove
- Specified by:
getElementToMove
in interfaceIPipe
-
getElementToMoveSessionKey
- Specified by:
getElementToMoveSessionKey
in interfaceIPipe
-
getElementToMoveChain
- Specified by:
getElementToMoveChain
in interfaceIPipe
-
isRemoveCompactMsgNamespaces
public boolean isRemoveCompactMsgNamespaces()- Specified by:
isRemoveCompactMsgNamespaces
in interfaceIPipe
-
isRestoreMovedElements
public boolean isRestoreMovedElements()- Specified by:
isRestoreMovedElements
in interfaceIPipe
-
getLocker
-
getEmptyInputReplacement
- Specified by:
getEmptyInputReplacement
in interfaceIPipe
-
isWriteToSecLog
public boolean isWriteToSecLog()- Specified by:
isWriteToSecLog
in interfaceIPipe
-
getSecLogSessionKeys
- Specified by:
getSecLogSessionKeys
in interfaceIPipe
-
getLogIntermediaryResults
- Specified by:
getLogIntermediaryResults
in interfaceIPipe
-
getHideRegex
- Specified by:
getHideRegex
in interfaceIPipe
-
setEventPublisher
-
getPipeLine
-
setPipeLine
Description copied from interface:IPipe
Allowing pipe to register things at Configuration time. Must be set before calling configure()- Specified by:
setPipeLine
in interfaceIPipe
-