Skip to content

Instantly share code, notes, and snippets.

@fmamud
Created March 17, 2015 03:06
Show Gist options
  • Save fmamud/38ac21b3338a467d63a4 to your computer and use it in GitHub Desktop.
Save fmamud/38ac21b3338a467d63a4 to your computer and use it in GitHub Desktop.
Java Binding Embedding Groovy
import groovy.lang.Binding;
import groovy.lang.GroovyShell;
public class JavaEmbedGroovy {
public static void main(String[] args) {
Binding binding = new Binding();
binding.setVariable("evento", "FTD");
binding.setVariable("linguagem", "Groovy");
GroovyShell shell = new GroovyShell(binding);
System.out.println("-- Inicio Groovy script --");
Object result = shell.evaluate("println \"$evento $linguagem\"; return 'Haaaaa'");
System.out.println("Resultado: " + result);
System.out.println("-- Fim Groovy script --");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment