JSR223 Sampler
有一个Groovy正在实现的语句
Compilable interface
脚本必须实现JSR223可编译接口(Groovy是其中之一)
java、beanshell和javascript不是)
我试着用
similar code
在JSR223采样器中。
我试图用Compileable检查所有可用的语言:
import javax.script.Compilable;
import javax.script.ScriptEngineFactory;
import javax.script.ScriptEngineManager;
ScriptEngineManager mgr = new ScriptEngineManager();
engineFactories = mgr.getEngineFactories();
for (ScriptEngineFactory engineFactory : engineFactories) {
if (engineFactory instanceof Compilable) {
log.info(engineFactory.getEngineName() + " Script compilation is supported.");
} else {
log.info(engineFactory.getEngineName() + " Script compilation is not supported.");
}
}
Oracle Nashorn Script compilation is not supported.
JEXL Engine Script compilation is not supported.
Groovy Scripting Engine Script compilation is not supported.
JEXL Engine Script compilation is not supported.
Velocity Script compilation is not supported.
BeanShell Engine Script compilation is not supported.
意思
我根据@aristotl更改支票,现在它返回
全部的
支持编译
final ScriptEngine engine = engineFactory.getScriptEngine();
if (engine instanceof Compilable) {
编辑2
try {
((Compilable) engine).compile("");
log.info(engineFactory.getEngineName() + " Script compilation is supported.");
} catch (Error e) {
log.info(engineFactory.getEngineName() + " Script compilation is not supported.");
我得到了一个有趣的结果:Nashorn和JEXL支持它
Groovy Scripting Engine Script compilation is supported.
Oracle Nashorn Script compilation is supported.
JEXL Engine Script compilation is supported.
BeanShell Engine Script compilation is not supported.
JEXL Engine Script compilation is supported.
我检查出什么问题了吗?我需要导入更多JAR才能启用它吗?
我怎么知道脚本引擎是否使用缓存和编译?JMeter的陈述是否错误/过时?