All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.pukkaone.jarinvoke.plugin.JarInvokeScriptEngine Maven / Gradle / Ivy

There is a newer version: 6.5.4-1
Show newest version
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