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, FilenameSwitch, FixedForwardPipe, IsXmlPipe, XmlIf, XmlSwitch

public abstract class AbstractPipe extends TransactionAttributes implements IPipe, EventThrowing, org.springframework.context.ApplicationContextAware, IWithParameters, HasStatistics
Base class for 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 Details

    • parameterNamesMustBeUnique

      protected boolean parameterNamesMustBeUnique
  • Constructor Details

    • AbstractPipe

      public AbstractPipe()
  • Method Details

    • configure

      public void configure() throws ConfigurationException
      configure() is called after the Pipeline is registered at the Adapter. Purpose of this method is to reduce creating connections to databases etc. in the doPipe() method. As much as possible class-instantiating should take place in the configure() method, to improve performance.
      Specified by:
      configure in interface IConfigurable
      Specified by:
      configure in interface IPipe
      Overrides:
      configure in class TransactionAttributes
      Throws:
      ConfigurationException
    • setApplicationContext

      public final void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
      final method to ensure nobody overrides this...
      Specified by:
      setApplicationContext in interface org.springframework.context.ApplicationContextAware
    • createBean

      protected <T> T createBean(Class<T> beanClass)
    • start

      public void start() throws PipeStartException
      Description copied from interface: IPipe
      Perform necessary action to start the pipe. This method is executed after the IPipe.configure() method, for each start and stop command of the adapter.
      Specified by:
      start in interface IPipe
      Throws:
      PipeStartException
    • stop

      public void stop()
      Description copied from interface: IPipe
      Perform necessary actions to stop the Pipe.
      For instance, closing JMS connections, DBMS connections etc.
      Specified by:
      stop in interface IPipe
    • addParameter

      public void addParameter(IParameter param)
      Add a parameter to the list of parameters
      Specified by:
      addParameter in interface IWithParameters
    • getParameterList

      public ParameterList getParameterList()
      return the Parameters
      Specified by:
      getParameterList in interface IWithParameters
    • setLocker

      public void setLocker(Locker locker)
      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.
      Specified by:
      setLocker in interface IPipe
    • registerForward

      public void registerForward(PipeForward forward) throws ConfigurationException
      Forwards are used to determine the next Pipe to execute in the Pipeline
      Specified by:
      registerForward in interface IPipe
      Throws:
      ConfigurationException - If the forward target cannot be registered.
      See Also:
    • findForward

      @Nullable public PipeForward findForward(@Nullable String forward)
      Looks up a key in the pipeForward hashtable.
      A typical use would be on return from a Pipe:
       return new PipeRunResult(findForward("success"), result);
       
      findForward searches:
      • 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

      @Nonnull public Map<String,PipeForward> getForwards()
      Description copied from interface: IPipe
      Get pipe forwards.
      Specified by:
      getForwards in interface IPipe
    • getEventSourceName

      public String getEventSourceName()
      Specified by:
      getEventSourceName in interface EventThrowing
    • registerEvent

      public void registerEvent(String description)
      Description copied from interface: IPipe
      Register an event for flexible monitoring.
      Specified by:
      registerEvent in interface IPipe
    • throwEvent

      public void throwEvent(String event, Message message)
      Specified by:
      throwEvent in interface IPipe
    • getAdapter

      public Adapter getAdapter()
      Specified by:
      getAdapter in interface EventThrowing
      Specified by:
      getAdapter in interface HasStatistics
    • consumesSessionVariable

      public boolean consumesSessionVariable(String sessionKey)
      Description copied from interface: IPipe
      returns true 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 interface IPipe
    • setName

      @Mandatory public void setName(String name)
      The functional name of this pipe. Can be referenced by the path attribute of a PipeForward.
      Specified by:
      setName in interface INamedObject
    • setGetInputFromSessionKey

      public void setGetInputFromSessionKey(String string)
      Description copied from interface: IPipe
      If set, input is taken from this session key, instead of regular input
      Specified by:
      setGetInputFromSessionKey in interface IPipe
    • setGetInputFromFixedValue

      public void setGetInputFromFixedValue(String string)
      Description copied from interface: IPipe
      If set, this fixed value is taken as input, instead of regular input
      Specified by:
      setGetInputFromFixedValue in interface IPipe
    • setEmptyInputReplacement

      public void setEmptyInputReplacement(String string)
      Description copied from interface: IPipe
      If set and the input is empty, this fixed value is taken as input
      Specified by:
      setEmptyInputReplacement in interface IPipe
    • setPreserveInput

      public void setPreserveInput(boolean preserveInput)
      Description copied from interface: IPipe
      If set true, the result of the pipe is replaced with the original input (i.e. the input before configured replacements of getInputFromSessionKey, getInputFromFixedValue or emptyInputReplacement)
      Specified by:
      setPreserveInput in interface IPipe
    • setStoreResultInSessionKey

      public void setStoreResultInSessionKey(String string)
      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 interface IPipe
    • setMaxThreads

      public void setMaxThreads(int newMaxThreads)
      The maximum number of threads that may process messages simultaneously. A value of 0 indicates an unlimited number of threads.
      Default value
      0
    • setChompCharSize

      public void setChompCharSize(String string)
      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 interface IPipe
    • setElementToMove

      public void setElementToMove(String string)
      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 interface IPipe
    • setElementToMoveSessionKey

      public void setElementToMoveSessionKey(String string)
      Description copied from interface: IPipe
      (Only used when elementToMove is set) Name of the session key under which the character data is stored
      Specified by:
      setElementToMoveSessionKey in interface IPipe
    • setElementToMoveChain

      public void setElementToMoveChain(String string)
      Description copied from interface: IPipe
      Like elementToMove but element is preceded with all ancestor elements and separated by semicolons (e.g. 'adapter;pipeline;pipe')
      Specified by:
      setElementToMoveChain in interface IPipe
    • 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 interface IPipe
    • setRemoveCompactMsgNamespaces

      public void setRemoveCompactMsgNamespaces(boolean b)
      Specified by:
      setRemoveCompactMsgNamespaces in interface IPipe
    • setRestoreMovedElements

      public void setRestoreMovedElements(boolean restoreMovedElements)
      Description copied from interface: IPipe
      If set true, compacted messages in the result are restored to their original format (see also IPipe.setElementToMove(java.lang.String))
      Specified by:
      setRestoreMovedElements in interface IPipe
    • setSizeStatistics

      public void setSizeStatistics(boolean sizeStatistics)
      Collect and aggregate Message size statistics
    • sizeStatisticsEnabled

      public boolean sizeStatisticsEnabled()
      Specified by:
      sizeStatisticsEnabled in interface IPipe
    • setWriteToSecLog

      public void setWriteToSecLog(boolean b)
      when set to true a record is written to the security log when the pipe has finished successfully
      Specified by:
      setWriteToSecLog in interface IPipe
    • setSecLogSessionKeys

      public void setSecLogSessionKeys(String string)
      (only used when writeToSecLog=true) comma separated list of keys of session variables that is appended to the security log record
      Specified by:
      setSecLogSessionKeys in interface IPipe
    • setLogIntermediaryResults

      public void setLogIntermediaryResults(String string)
      when set, the value in AppConstants is overwritten (for this pipe only)
    • setHideRegex

      public void setHideRegex(String hideRegex)
      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 one pipe affects all pipes in the pipeline (and multiple values in different pipes are merged)
    • getConfigurationClassLoader

      public ClassLoader 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 interface IScopeProvider
      Returns:
      returns the ClassLoader created by the ClassLoaderManager.
    • getApplicationContext

      public org.springframework.context.ApplicationContext getApplicationContext()
      Specified by:
      getApplicationContext in interface IConfigurationAware
    • getName

      public String getName()
      Description copied from interface: IForwardTarget
      The part of the object that identifies its destination: The name of the Pipe or the path of the PipeLineExit.
      Specified by:
      getName in interface IConfigurationAware
      Specified by:
      getName in interface IForwardTarget
      Specified by:
      getName in interface INamedObject
    • getGetInputFromSessionKey

      public String getGetInputFromSessionKey()
      Specified by:
      getGetInputFromSessionKey in interface IPipe
    • getGetInputFromFixedValue

      public String getGetInputFromFixedValue()
      Specified by:
      getGetInputFromFixedValue in interface IPipe
    • getStoreResultInSessionKey

      public String getStoreResultInSessionKey()
      Specified by:
      getStoreResultInSessionKey in interface IPipe
    • isPreserveInput

      public boolean isPreserveInput()
      Specified by:
      isPreserveInput in interface IPipe
    • getMaxThreads

      public int getMaxThreads()
      Description copied from interface: IPipe
      Indicates the maximum number of threads that may call doPipe() simultaneously. A value of 0 indicates an unlimited number of threads. Pipe implementations that are not thread-safe, i.e. where doPipe() may only be called by one thread at a time, should make sure getMaxThreads always returns a value of 1.
      Specified by:
      getMaxThreads in interface IPipe
    • getDurationThreshold

      public long getDurationThreshold()
      Specified by:
      getDurationThreshold in interface IPipe
    • getChompCharSize

      public String getChompCharSize()
      Specified by:
      getChompCharSize in interface IPipe
    • getElementToMove

      public String getElementToMove()
      Specified by:
      getElementToMove in interface IPipe
    • getElementToMoveSessionKey

      public String getElementToMoveSessionKey()
      Specified by:
      getElementToMoveSessionKey in interface IPipe
    • getElementToMoveChain

      public String getElementToMoveChain()
      Specified by:
      getElementToMoveChain in interface IPipe
    • isRemoveCompactMsgNamespaces

      public boolean isRemoveCompactMsgNamespaces()
      Specified by:
      isRemoveCompactMsgNamespaces in interface IPipe
    • isRestoreMovedElements

      public boolean isRestoreMovedElements()
      Specified by:
      isRestoreMovedElements in interface IPipe
    • getLocker

      public Locker getLocker()
      Specified by:
      getLocker in interface IPipe
    • getEmptyInputReplacement

      public String getEmptyInputReplacement()
      Specified by:
      getEmptyInputReplacement in interface IPipe
    • isWriteToSecLog

      public boolean isWriteToSecLog()
      Specified by:
      isWriteToSecLog in interface IPipe
    • getSecLogSessionKeys

      public String getSecLogSessionKeys()
      Specified by:
      getSecLogSessionKeys in interface IPipe
    • getLogIntermediaryResults

      public String getLogIntermediaryResults()
    • getHideRegex

      public String getHideRegex()
    • setEventPublisher

      public void setEventPublisher(EventPublisher eventPublisher)
    • getPipeLine

      public PipeLine getPipeLine()
    • setPipeLine

      public void setPipeLine(PipeLine pipeLine)
      Description copied from interface: IPipe
      Allowing pipe to register things at Configuration time. Must be set before calling configure()
      Specified by:
      setPipeLine in interface IPipe