Class AbstractParameter
- All Implemented Interfaces:
FrankElement,HasApplicationContext,HasName,IConfigurable,IScopeProvider,IWithParameters,NameAware,IParameter,org.springframework.beans.factory.Aware,org.springframework.context.ApplicationContextAware
- Direct Known Subclasses:
BooleanParameter,DateParameter,JsonParameter,NumberParameter,Parameter,XmlParameter
A parameter resembles an attribute. However, while attributes get their value at configuration-time, parameters get their value at the time of processing the message. Value can be retrieved from the message itself, a fixed value, or from the pipelineSession. If this does not result in a value (or if neither of these is specified), a default value can be specified. If an XPathExpression, XSLT stylesheet or JSONPathExpression is specified, it will be applied to the message, the value retrieved from the pipelineSession or the fixed value specified. If the transformation produces no output, the default value of the parameter is taken if provided.
Examples:
stored under SessionKey 'TransportInfo':
<transportinfo>
<to>***@zonnet.nl</to>
<to>***@zonnet.nl</to>
<cc>***@zonnet.nl</cc>
</transportinfo>
to obtain all 'to' addressees as a parameter:
sessionKey="TransportInfo"
xpathExpression="transportinfo/to"
type="xml"
Result:
<to>***@zonnet.nl</to>
<to>***@zonnet.nl</to>
N.B. to obtain a fixed value: a non-existing 'dummy' sessionKey in combination with the fixed value in defaultValue is used traditionally.
The current version of parameter supports the value attribute, that is sufficient to set a fixed value.- Author:
- Gerrit van Brakel
- Parameters
- Parameters themselves can have parameters too, for instance if a XSLT transformation is used, that transformation can have parameters.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumstatic enumprotected static final record -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringprotected ParameterList -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidConfigure this component.booleanconsumesSessionVariable(String sessionKey) protected StringgetName()getValue(ParameterValueList alreadyResolvedParameters, Message message, PipeLineSession session, boolean namespaceAware) determines the raw valueprotected ObjectgetValueAsType(Message request, boolean namespaceAware) Converts raw data to configured parameter typebooleanif this returns true, then the input value must be repeatable, as it might be used multiple times.voidsetAuthAlias(String string) Alias used to obtain username and password, used when apatterncontaining {username} or {password} is specifiedvoidsetContextKey(String string) Key ofMessageContextvariable to use as source, instead of theMessagefound from input message or sessionKey itself.voidsetDefaultValue(String string) If the result of sessionKey, xpathExpression and/or stylesheet returns null or an empty string, this value is returnedvoidsetDefaultValueMethods(String string) Comma separated list of methods (defaultValue,sessionKey,pattern,valueorinput) to use as default value.voidsetHidden(boolean b) If set totrue, the value of the parameter will not be shown in the log (replaced by asterisks)voidsetIgnoreUnresolvablePatternElements(boolean b) If settruepattern elements that cannot be resolved to a parameter or sessionKey are silently resolved to an empty stringvoidsetJsonPathExpression(String jsonPathExpression) The JPath expression to extract the parameter value from the input or session-variable.voidsetMaxLength(int i) If set (>=0) and the length of the value of the parameter exceeds this maximum length, the length is trimmed to this maximum lengthvoidsetMinLength(int i) If set (>=0) and the length of the value of the parameter falls short of this minimum length, the value is paddedvoidSet the mode of the parameter, which determines if the parameter is an INPUT, OUTPUT, or INOUT.voidName of the parametervoidsetNamespaceDefs(String namespaceDefs) Namespace definitions for xpathExpression.voidsetPassword(String string) Default password that is used when apatterncontaining {password} is specifiedvoidsetPattern(String string) Value of parameter is determined using substitution and formatting, following MessageFormat syntax with named parameters.voidsetRemoveNamespaces(boolean b) When settruenamespaces (and prefixes) in the input message are removed before the stylesheet/xpathExpression is executedvoidsetSessionKey(String string) Key of a PipelineSession-variable.voidsetSessionKeyJPath(String string) Instead of a fixedsessionKeyit's also possible to use a JPath expression applied to the input message to extract the name of the session-variable.voidsetSessionKeyXPath(String string) Instead of a fixedsessionKeyit's also possible to use a XPath expression applied to the input message to extract the name of the session-variable.voidsetStyleSheetName(String stylesheetName) URL to a stylesheet that wil be applied to the contents of the message or the value of the session-variable.protected voidsetType(ParameterType type) voidsetUsername(String string) Default username that is used when apatterncontaining {username} is specifiedvoidThe value of the parameter, or the base for transformation using xpathExpression, jpathExpression or stylesheet, or formatting.voidsetXpathExpression(String xpathExpression) the XPath expression to extract the parameter value from the (xml formatted) input or session-variable.voidsetXsltVersion(int xsltVersion) If set to2or3a Saxon (net.sf.saxon) xslt processor 2.0 or 3.0 respectively will be used, otherwise xslt processor 1.0 (org.apache.xalan).toString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.springframework.context.ApplicationContextAware
setApplicationContextMethods inherited from interface org.frankframework.core.FrankElement
addConfigWarningMethods inherited from interface org.frankframework.core.HasApplicationContext
getApplicationContext, getConfigurationClassLoaderMethods inherited from interface org.frankframework.parameters.IParameter
getMode, getSessionKey, getType, getValue, isHidden
-
Field Details
-
CONTEXT_KEY_WILDCARD
- See Also:
-
FIXEDUID
- See Also:
-
FIXEDHOSTNAME
- See Also:
-
paramList
-
-
Constructor Details
-
AbstractParameter
public AbstractParameter()
-
-
Method Details
-
addParameter
- Specified by:
addParameterin interfaceIWithParameters
-
getParameterList
- Specified by:
getParameterListin interfaceIWithParameters
-
configure
Description copied from interface:IConfigurableConfigure this component.configure()is called once at startup of the framework in the configure method of the owner of thisIConfigurable. Purpose of this method is to check whether the static configuration of the object is correct. As much as possible class-instantiating should take place in theconfigure(), to improve performance.In the case of a container, this will propagate the configure signal to all components that apply.
- Specified by:
configurein interfaceIConfigurable- Throws:
ConfigurationException- in case it was not able to configure the component.
-
requiresInputValueForResolution
public boolean requiresInputValueForResolution()if this returns true, then the input value must be repeatable, as it might be used multiple times.- Specified by:
requiresInputValueForResolutionin interfaceIParameter
-
consumesSessionVariable
- Specified by:
consumesSessionVariablein interfaceIParameter
-
getValue
public Object getValue(ParameterValueList alreadyResolvedParameters, Message message, PipeLineSession session, boolean namespaceAware) throws ParameterException determines the raw value- Specified by:
getValuein interfaceIParameter- Throws:
ParameterException
-
getValueAsType
protected Object getValueAsType(@Nonnull Message request, boolean namespaceAware) throws ParameterException, IOException Converts raw data to configured parameter type- Throws:
ParameterExceptionIOException
-
getMessageFormat
-
toString
-
setName
Name of the parameter -
getName
-
setType
-
setValue
The value of the parameter, or the base for transformation using xpathExpression, jpathExpression or stylesheet, or formatting.- Specified by:
setValuein interfaceIParameter
-
setSessionKey
Key of a PipelineSession-variable.
If specified, the value of the PipelineSession variable is used as input for the xpathExpression, jpathExpression or stylesheet, instead of the current input message.
If no xpathExpression, jpathExpression or stylesheet are specified, the value itself is returned.
If the value '*' is specified, all existing sessionkeys are added as parameter of which the name starts with the name of this parameter.
If also the name of the parameter has the value '*' then all existing sessionkeys are added as parameter (except tsReceived)- Specified by:
setSessionKeyin interfaceIParameter
-
setContextKey
Key ofMessageContextvariable to use as source, instead of theMessagefound from input message or sessionKey itself. Use a * to get an XML or JSON document containing all values from theMessageContext. -
setSessionKeyXPath
Instead of a fixedsessionKeyit's also possible to use a XPath expression applied to the input message to extract the name of the session-variable. -
setSessionKeyJPath
Instead of a fixedsessionKeyit's also possible to use a JPath expression applied to the input message to extract the name of the session-variable. -
setStyleSheetName
URL to a stylesheet that wil be applied to the contents of the message or the value of the session-variable. -
setXpathExpression
the XPath expression to extract the parameter value from the (xml formatted) input or session-variable. -
setJsonPathExpression
The JPath expression to extract the parameter value from the input or session-variable. The input should be JSON or XML formatted, if it is XML formatter a simple XML-to-JSON conversion is done. WhenjsonPathExpressionis set, then the value of the parameter will be derived using the same order of precedence as withxpathExpression. -
setXsltVersion
public void setXsltVersion(int xsltVersion) If set to2or3a Saxon (net.sf.saxon) xslt processor 2.0 or 3.0 respectively will be used, otherwise xslt processor 1.0 (org.apache.xalan).0will auto-detect- Default value
- 0
-
setNamespaceDefs
Namespace definitions for xpathExpression. Must be in the form of a comma or space separated list ofprefix=namespaceuridefinitions. One entry can be without a prefix, that will define the default namespace. -
setRemoveNamespaces
public void setRemoveNamespaces(boolean b) When settruenamespaces (and prefixes) in the input message are removed before the stylesheet/xpathExpression is executed- Default value
false
-
setDefaultValue
If the result of sessionKey, xpathExpression and/or stylesheet returns null or an empty string, this value is returned -
setDefaultValueMethods
Comma separated list of methods (defaultValue,sessionKey,pattern,valueorinput) to use as default value. Used in the order they appear until a non-null value is found.- Default value
defaultValue
-
setPattern
Value of parameter is determined using substitution and formatting, following MessageFormat syntax with named parameters. The expression can contain references tosession-variablesor otherparametersusing the {name-of-parameter} and is formatted using java.text.MessageFormat.
NB: When referencing otherparametersthese MUST be defined before the parameter using pattern substitution.
If for instancefnameis a parameter or session-variable that resolves to Eric, then the pattern 'Hi {fname}, how do you do?' resolves to 'Hi Eric, do you do?'.
The following predefined reference can be used in the expression too:- {now}: the current system time
- {uid}: an unique identifier, based on the IP address and java.rmi.server.UID
- {uuid}: an unique identifier, based on the IP address and java.util.UUID
- {hostname}: the name of the machine the application runs on
- {username}: username from the credentials found using authAlias, or the username attribute
- {password}: password from the credentials found using authAlias, or the password attribute
- {principal}: Name of the current principal, similar to the
GetPrincipalPipe. - {fixeddate}: fake date, for testing only
- {fixeduid}: fake uid, for testing only
- {fixedhostname}: fake hostname, for testing only
When combining a date or timepatternlike {now} or {fixeddate} with a DATE, TIME, DATETIME or TIMESTAMPtype, the effective value of the attributeformatStringmust match the effective value of the formatString in thepattern. -
setAuthAlias
Alias used to obtain username and password, used when apatterncontaining {username} or {password} is specified -
setUsername
Default username that is used when apatterncontaining {username} is specified -
setPassword
Default password that is used when apatterncontaining {password} is specified -
setIgnoreUnresolvablePatternElements
public void setIgnoreUnresolvablePatternElements(boolean b) If settruepattern elements that cannot be resolved to a parameter or sessionKey are silently resolved to an empty string -
setMinLength
public void setMinLength(int i) If set (>=0) and the length of the value of the parameter falls short of this minimum length, the value is padded- Default value
- -1
-
setMaxLength
public void setMaxLength(int i) If set (>=0) and the length of the value of the parameter exceeds this maximum length, the length is trimmed to this maximum length- Default value
- -1
-
setHidden
public void setHidden(boolean b) If set totrue, the value of the parameter will not be shown in the log (replaced by asterisks)- Default value
false
-
setMode
Set the mode of the parameter, which determines if the parameter is an INPUT, OUTPUT, or INOUT. This parameter only has effect forStoredProcedureQuerySender. An OUTPUT parameter does not need to have a value specified, but does need to have the type specified. Parameter values will not be updated, but output values will be put into the result of theStoredProcedureQuerySender. If not specified, the default is INPUT.- Parameters:
mode- INPUT, OUTPUT or INOUT.
-