Created
March 17, 2015 03:06
-
-
Save fmamud/38ac21b3338a467d63a4 to your computer and use it in GitHub Desktop.
Java Binding Embedding Groovy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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