com.github.pukkaone.jarinvoke.plugin.JarInvokeScriptEngine Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jar-invoke Show documentation
Show all versions of jar-invoke Show documentation
Elasticsearch plugin to invoke Java code
package com.github.pukkaone.jarinvoke.plugin;
import com.github.pukkaone.jarinvoke.Command;
import com.github.pukkaone.jarinvoke.ModuleResolver;
import java.util.Map;
import org.elasticsearch.script.ScriptContext;
import org.elasticsearch.script.ScriptEngine;
/**
* Script engine to invoke Java code.
*/
public class JarInvokeScriptEngine implements ScriptEngine {
public static final String LANGUAGE = "jar-invoke";
private ModuleResolver moduleResolver = new ModuleResolver();
@Override
public String getType() {
return LANGUAGE;
}
@Override
public T compile(
String scriptName,
String scriptSource,
ScriptContext context,
Map params) {
Command command = moduleResolver.parse(scriptSource);
CommandSearchScriptFactory factory = new CommandSearchScriptFactory(command);
return context.factoryClazz.cast(factory);
}
@Override
public void close() {
moduleResolver.close();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy