@ComponentProfile(summary="Condition that makes use of the built in nashorn scripting engine for condition evaluation", tag="condition,service") public class ConditionFunction extends ConditionImpl
This makes use of the Invocable
extension to ScriptEngine
, to allow you to define
the function that will be executed to evaluate the condition. The function name should always be
evaluateScript
; take a single parameter (in this case it will be the current
AdaptrisMessage
; and return true or false
. For instance to check a specific
metadata value then you might have this function definition
function evaluateScript(message) {
return message.getMetadataValue('myMetadataKey').equals('myValue');
}
Similar to EmbeddedScriptingService
; the logger is bound as
log
.
In the adapter configuration file this class is aliased as function which is the preferred alternative to the fully qualified classname when building your configuration.
log
Constructor and Description |
---|
ConditionFunction() |
ConditionFunction(java.lang.String func) |
Modifier and Type | Method and Description |
---|---|
boolean |
evaluate(AdaptrisMessage msg) |
java.lang.String |
getDefinition() |
void |
init()
Initialises the component.
|
void |
setDefinition(java.lang.String f) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
close, start, stop
public ConditionFunction()
public ConditionFunction(java.lang.String func)
public boolean evaluate(AdaptrisMessage msg) throws ServiceException
ServiceException
public void init() throws CoreException
ComponentLifecycle
Component initialisation includes config verification, creation of connections etc.
CoreException
- wrapping any underlying Exception
spublic java.lang.String getDefinition()
public void setDefinition(java.lang.String f)