public class EvalScriptEngine
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
protected java.lang.ClassLoader |
classLoader |
protected ClassDirectory |
directory |
protected java.util.Properties |
properties |
protected groovy.lang.GroovyShell |
shell |
| Constructor and Description |
|---|
EvalScriptEngine()
Construct a new script engine.
|
EvalScriptEngine(java.lang.ClassLoader loader)
Construct a new script engine.
|
EvalScriptEngine(java.lang.ClassLoader loader,
java.util.Properties props)
Construct a new script engine.
|
| Modifier and Type | Method and Description |
|---|---|
EvalProject |
createProject()
Create a new eval project.
|
<T> java.lang.Class<? extends org.apache.commons.lang3.builder.Builder> |
getBuilderForType(java.lang.Class<T> type)
Get a command for a type.
|
protected void |
loadExternalMethods()
Register a default set of external methods.
|
EvalProject |
loadProject(java.io.File file)
Load a set of evaluations from a script file.
|
java.lang.Object |
loadProject(java.io.Reader in)
Load a set of evaluations from an input stream.
|
java.lang.Class<? extends org.apache.commons.lang3.builder.Builder> |
lookupBuilder(java.lang.String name)
Find a builder with a particular name if it exists.
|
java.lang.Class<?> |
lookupMethod(java.lang.String name)
Look up a registered method of any type.
|
java.lang.Class<? extends EvalTask> |
lookupTask(java.lang.String name)
Find a task with a particular name if it exists.
|
<T> void |
registerCommand(java.lang.Class<T> type,
java.lang.Class<? extends org.apache.commons.lang3.builder.Builder> command)
Register a builder class for a type.
|
java.lang.Object |
runScript(EvalScript script,
EvalProject project)
Run an evaluation config script and get the evaluations it produces.
|
java.lang.Object |
runScript(java.io.File file,
EvalProject project)
Run a script from a file.
|
java.lang.Object |
runScript(java.io.Reader in,
EvalProject project)
Run a script from a reader.
|
protected java.lang.ClassLoader classLoader
protected ClassDirectory directory
protected groovy.lang.GroovyShell shell
@Nullable protected final java.util.Properties properties
public EvalScriptEngine()
public EvalScriptEngine(java.lang.ClassLoader loader)
loader - The class loader to use.public EvalScriptEngine(java.lang.ClassLoader loader,
@Nullable
java.util.Properties props)
loader - The class loader to use.props - Additional properties to use when creating new projects.EvalProject.EvalProject(java.util.Properties)public EvalProject createProject()
public java.lang.Object runScript(java.io.File file,
EvalProject project)
throws java.io.IOException,
TaskExecutionException
file - The file to run.project - The project to run the script against.java.io.IOException - if the file cannot be read.TaskExecutionExceptionpublic java.lang.Object runScript(java.io.Reader in,
EvalProject project)
throws java.io.IOException
in - The reader to read.project - The project to run the script against.java.io.IOException@Nullable public java.lang.Object runScript(EvalScript script, EvalProject project) throws TaskExecutionException
script - The script to run (as loaded by Groovy)project - The project to run the script on.TaskExecutionException - if the script is invalid or produces an error.public EvalProject loadProject(java.io.File file) throws TaskExecutionException, java.io.IOException
file - A Groovy script to configure the evaluator.TaskExecutionException - if there is a configuration errorjava.io.IOException - if there is an error reading the filepublic java.lang.Object loadProject(java.io.Reader in)
throws TaskExecutionException,
java.io.IOException
in - The input streamTaskExecutionException - if there is a configuration errorjava.io.IOExceptionpublic java.lang.Class<?> lookupMethod(@Nonnull
java.lang.String name)
name - The method name.null if it the method is not found.@CheckForNull @Nullable public java.lang.Class<? extends EvalTask> lookupTask(@Nonnull java.lang.String name)
name - The name of the commandnull if no such factory exists.@CheckForNull
@Nullable
public java.lang.Class<? extends org.apache.commons.lang3.builder.Builder> lookupBuilder(@Nonnull
java.lang.String name)
name - The name of the commandnull if no such factory exists.public <T> java.lang.Class<? extends org.apache.commons.lang3.builder.Builder> getBuilderForType(java.lang.Class<T> type)
BuiltBy annotation.type - A type that needs to be built.type, or null if none can be found.registerCommand(java.lang.Class<T>, java.lang.Class<? extends org.apache.commons.lang3.builder.Builder>)public <T> void registerCommand(java.lang.Class<T> type,
java.lang.Class<? extends org.apache.commons.lang3.builder.Builder> command)
BuiltBy annotation.T - The type to build (type parameter).type - The type to build.command - A class that can build instances of type.protected void loadExternalMethods()