Class ConditionFunction
java.lang.Object
com.adaptris.core.services.conditional.conditions.ConditionImpl
com.adaptris.core.scripting.services.conditional.conditions.ConditionFunction
- All Implemented Interfaces:
ComponentLifecycle,Condition
@ComponentProfile(summary="Condition that makes use of the javascript scripting engine for condition evaluation",
tag="condition,service")
public class ConditionFunction
extends ConditionImpl
A javascript condition.
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.
-
Field Summary
Fields inherited from class com.adaptris.core.services.conditional.conditions.ConditionImpl
log -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanevaluate(AdaptrisMessage msg) Definition of the function to evaluate the conditionvoidinit()voidsetDefinition(String definition) Definition of the function to evaluate the conditionMethods inherited from class com.adaptris.core.services.conditional.conditions.ConditionImpl
getAdditionalLogging, logCondition, setAdditionalLoggingMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.adaptris.core.ComponentLifecycle
close, start, stop
-
Constructor Details
-
ConditionFunction
public ConditionFunction() -
ConditionFunction
-
-
Method Details
-
evaluate
- Throws:
ServiceException
-
init
- Throws:
CoreException
-
getDefinition
Definition of the function to evaluate the condition -
setDefinition
Definition of the function to evaluate the condition
-