org.kitesdk.morphline.scriptengine.java
Class ScriptEvaluator<T>

java.lang.Object
  extended by org.kitesdk.morphline.scriptengine.java.ScriptEvaluator<T>

public class ScriptEvaluator<T>
extends Object

Creates and compiles the given Java code block, wrapped into a Java method with the given return type and parameter types, along with a Java class definition that contains the given import statements.

Compilation is done in main memory, i.e. without writing to the filesystem.

The result is an object that can be executed (and reused) any number of times. This is a high performance implementation, using an optimized variant of https://scripting.dev.java.net/" (JSR 223 Java Scripting). Calling evaluate(Object...) just means calling Method.invoke(Object, Object...) and as such has the same minimal runtime cost, i.e. O(100M calls/sec/core). Instances of this class are thread-safe if the user provided script statements are thread-safe.


Constructor Summary
ScriptEvaluator(String javaImports, String javaCodeBlock, Class<T> returnType, String[] parameterNames, Class[] parameterTypes, String parseLocation)
           
 
Method Summary
 T evaluate(Object... params)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ScriptEvaluator

public ScriptEvaluator(String javaImports,
                       String javaCodeBlock,
                       Class<T> returnType,
                       String[] parameterNames,
                       Class[] parameterTypes,
                       String parseLocation)
                throws ScriptException
Throws:
ScriptException
Method Detail

evaluate

public T evaluate(Object... params)
           throws ScriptException
Throws:
ScriptException


Copyright © 2013–2014. All rights reserved.