Class JavascriptSender
- All Implemented Interfaces:
ICacheEnabled<String,
,String> AdapterAware
,IConfigurable
,IConfigurationAware
,INamedObject
,IScopeProvider
,ISender
,ISenderWithParameters
,IWithParameters
,org.springframework.beans.factory.Aware
,org.springframework.context.ApplicationContextAware
This sender can execute a function of a given Javascript file, the result of the function will be the output of the sender.
The parameters of the Javascript function to run are given as parameters by the adapter configuration
The sender doesn't accept nor uses the given input, instead for each argument for the jsFunctionName
method,
you will need to create a parameter on the sender.
The result of the Javascript function should be of type String, or directly convertible to String from a primitive type or an array of primitive types / strings, as the output of the sender will be of type String.
Failure to ensure the output is a string may mean the result will look like [Object object]
.
- Since:
- 7.4
-
Nested Class Summary
-
Field Summary
Fields inherited from class org.frankframework.senders.AbstractSenderWrapper
adapter, configurationMetrics, senderWrapperProcessor
Fields inherited from class org.frankframework.senders.AbstractSenderWithParameters
parameterNamesMustBeUnique, paramList
Fields inherited from class org.frankframework.senders.AbstractSender
log
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
one or more specifications of senders that will be executed one after another.void
configure()
is called once at startup of the framework in the configure method of the owner of this sender.protected boolean
sendMessage
(Message message, PipeLineSession session) Send a message to some destination (as configured in the Sender object).void
setEngineName
(JavascriptSender.JavaScriptEngines engineName) the name of the JavaScript engine to use.void
setJsFileName
(String jsFileName) the name of the javascript file containing the functions to runvoid
setJsFunctionName
(String jsFunctionName) the name of the javascript function that will be called (first)Methods inherited from class org.frankframework.senders.SenderSeries
consumesSessionVariable, doSendMessage, getSenders, getStatisticsKeeper, isSynchronous, setSender, setSynchronous, start, stop
Methods inherited from class org.frankframework.senders.AbstractSenderWrapper
getCache, getGetInputFromFixedValue, getGetInputFromSessionKey, getStoreInputInSessionKey, getStoreResultInSessionKey, isPreserveInput, setAdapter, setCache, setConfigurationMetrics, setGetInputFromFixedValue, setGetInputFromSessionKey, setPreserveInput, setSenderWrapperProcessor, setStoreInputInSessionKey, setStoreResultInSessionKey
Methods inherited from class org.frankframework.senders.AbstractSenderWithParameters
addParameter, checkStringAttributeOrParameter, getParameterList, getParameterOverriddenAttributeValue, getParameterOverriddenAttributeValue, getParameterValueList
Methods inherited from class org.frankframework.senders.AbstractSender
createBean, getApplicationContext, getConfigurationClassLoader, getLogPrefix, getName, setApplicationContext, setName
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.context.ApplicationContextAware
setApplicationContext
Methods inherited from interface org.frankframework.core.IConfigurationAware
getApplicationContext, getName
Methods inherited from interface org.frankframework.core.INamedObject
getName, setName
Methods inherited from interface org.frankframework.core.IScopeProvider
getConfigurationClassLoader
Methods inherited from interface org.frankframework.core.ISender
sendMessageOrThrow
-
Constructor Details
-
JavascriptSender
public JavascriptSender()
-
-
Method Details
-
configure
Description copied from interface:ISender
configure()
is called once at startup of the framework in the configure method of the owner of this sender. Purpose of this method is to check whether the static configuration of the sender is correct. As much as possible class-instantiating should take place in theconfigure()
oropen()
method, to improve performance.- Specified by:
configure
in interfaceIConfigurable
- Specified by:
configure
in interfaceISender
- Overrides:
configure
in classSenderSeries
- Throws:
ConfigurationException
-
isSenderConfigured
protected boolean isSenderConfigured()- Overrides:
isSenderConfigured
in classSenderSeries
-
sendMessage
@Nonnull public SenderResult sendMessage(@Nonnull Message message, @Nonnull PipeLineSession session) throws SenderException Description copied from interface:ISender
Send a message to some destination (as configured in the Sender object). This method may only be called after theconfigure()
method is called.The following table shows the difference between synchronous and a-synchronous senders:
synchronous a-synchronous ISender.isSynchronous()
returnstrue
false
return value of sendMessage()
isthe reply-message the messageId of the message sent the correlationID specified with sendMessage()
may be ignored is sent with the message a {link TimeOutException} may be thrown if a timeout occurs waiting for a reply should not be expected Multiple objects may try to call this method at the same time, from different threads. Implementations of this method should therefore be thread-safe, or
synchronized
.- Specified by:
sendMessage
in interfaceISender
- Overrides:
sendMessage
in classAbstractSenderWrapper
- Throws:
SenderException
-
addSender
Description copied from class:SenderSeries
one or more specifications of senders that will be executed one after another. Each sender will get the result of the preceding one as input.- Overrides:
addSender
in classSenderSeries
-
setJsFileName
the name of the javascript file containing the functions to run -
setJsFunctionName
the name of the javascript function that will be called (first)- Default value
- main
-
setEngineName
the name of the JavaScript engine to use.- Default value
- J2V8
-
getJsFileName
-
getJsFunctionName
-
getEngine
-