| Modifier and Type | Class and Description |
|---|---|
static class |
JavascriptEngine.Builder |
DEFAULT_INPUT_NAME, inputName, javascriptFilesToLoad, parsedRules, poolSize, throwExceptionIfCompilationFails, uniqueOutcomes| Constructor and Description |
|---|
JavascriptEngine(Collection<Rule> rules,
boolean throwExceptionIfCompilationFails,
String... javascriptFilesToLoad)
Creates the engine with a pool size of .
|
JavascriptEngine(Collection<Rule> rules,
String inputName,
boolean throwExceptionIfCompilationFails,
Integer poolSize,
boolean preloadPool,
String... javascriptFilesToLoad)
See {@link #JavascriptEngine(Collection, boolean, String...)
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
compile() |
<Input> List<Rule> |
getMatchingRules(String nameSpacePattern,
Input input) |
protected org.apache.commons.pool2.impl.GenericObjectPoolConfig |
getPoolConfig()
Subclasses may override this.
|
int[] |
getPoolSize() |
executeAllActions, executeAllActions, executeBestAction, executeBestAction, getBestOutcome, getBestOutcome, getMatchingRules, initpublic JavascriptEngine(Collection<Rule> rules, boolean throwExceptionIfCompilationFails, String... javascriptFilesToLoad) throws DuplicateNameException, CompileException, ParseException
rules - The rules which define the system. Please note that rules may access the input using
bean notation (e.g. "input.people[0].name") OR
Java notation (e.g. "input.getPeople().get(0).getName()").throwExceptionIfCompilationFails - if true, and a rule cannot be compiled, then a CompileException will be thrown.javascriptFilesToLoad - optional list of scripts to load - either script names found on classpath, or actual scripts.DuplicateNameException - thrown if any rules have the same name within a namespaceCompileException - thrown if throwExceptionIfCompilationFails is true, and a rule fails to compile, because its expression is invalidParseException - Thrown if a subrule which is referenced in a rule cannot be resolved.public JavascriptEngine(Collection<Rule> rules, String inputName, boolean throwExceptionIfCompilationFails, Integer poolSize, boolean preloadPool, String... javascriptFilesToLoad) throws DuplicateNameException, CompileException, ParseException
inputName - the name of the input in scripts, normally "input", but you can specify your own name here.jsonifyInput - if true, then the input can be accessed using bean notation, such as "input.passengers[0].name" rather
than using Java notation such as "input.getPassengers().get(0).getName()".poolSize - the maximum size of the pool. You can override more of the pool configuration by overriding the method getPoolConfig().preloadPool - if true, then before the constructor returns, it fills the pool.DuplicateNameExceptionCompileExceptionParseExceptionpublic int[] getPoolSize()
protected org.apache.commons.pool2.impl.GenericObjectPoolConfig getPoolConfig()
poolSize.protected void compile()
throws CompileException
compile in class EngineCompileExceptionpublic <Input> List<Rule> getMatchingRules(String nameSpacePattern, Input input)
getMatchingRules in class EngineInput - the type of inputnameSpacePattern - optional. if not null, then only rules with matching namespaces are evaluated.input - the Object containing all inputs to the expression language rule.Rule.getPriority(), with the highest priority rules first in the list.Copyright © 2017 Ant Kutschera. All rights reserved.