Package groovy.util

Examples of groovy.util.GroovyScriptEngine$ScriptCacheEntry


        ClassLoader curLoader = Thread.currentThread().getContextClassLoader();

        URL combinedRoots[] = getResourceRoots(extContext, curLoader);

        if (0 < combinedRoots.length) {
            GroovyScriptEngine engine =
                    new GroovyScriptEngine(combinedRoots, curLoader);
//            Class<?> c = Util.loadClass("groovy.util.GroovyScriptEngine", GroovyHelperFactory.class);
//            Constructor<?> ctor = c.getConstructor(URL[].class, ClassLoader.class);
//            GroovyScriptEngine engine = (GroovyScriptEngine)ctor.newInstance(combinedRoots, curLoader);
            loader = new MojarraGroovyClassLoader(engine);
            if (LOGGER.isLoggable(Level.INFO)) {
View Full Code Here


        ClassLoader curLoader = Thread.currentThread().getContextClassLoader();

        URL combinedRoots[] = getResourceRoots(extContext, curLoader);
           
        if (0 < combinedRoots.length) {
            GroovyScriptEngine engine =
                    new GroovyScriptEngine(combinedRoots, curLoader);
            loader = new MojarraGroovyClassLoader(engine);
            if (LOGGER.isLoggable(Level.INFO)) {
                LOGGER.log(Level.INFO,
                        "Groovy support enabled.");
            }
View Full Code Here

 
  private static final Logger LOG = LoggerFactory.getLogger(BlGroovyHandlerBean.class);
 
  public String convertToXml(String message) throws Exception {
    String[] roots = new String[] { basicDataSingleton.getUwsGroovyParserPath() };
    GroovyScriptEngine gse = new GroovyScriptEngine(roots);
    Binding binding = new Binding();
    binding.setProperty("rawMessage", message);
    binding.setProperty("LOG", LOG);
    Object output = gse.run(basicDataSingleton.getUwsGroovyParserFileName(), binding);
    return output.toString();
  }
View Full Code Here

            final Writer out) {
        try {
            parent.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

            String[] roots = new String[] { file.getParentFile().getAbsolutePath() };
            GroovyScriptEngine gse = new GroovyScriptEngine(roots, parent.getClass().getClassLoader());
            Binding binding = new Binding();
            binding.setVariable("session", model.getClientSession().getSession());
            binding.setVariable("binding", model.getClientSession().getSession().getBinding());
            binding.setVariable("out", out);
            gse.run(file.getName(), binding);
        } catch (Exception ex) {
            ClientHelper.showError(null, ex);
        } finally {
            parent.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
        }
View Full Code Here

    /**
     * Hook method to setup the GroovyScriptEngine to use.<br>
     * Subclasses may override this method to provide a custom engine.
     */
    protected GroovyScriptEngine createGroovyScriptEngine(){
        return new GroovyScriptEngine(this);
    }
View Full Code Here

        // only called during init - safe to cast and save.
        URL u = ctx.getExternalContext().getResource(SCRIPT_PATH);

        if (u != null) {

            GroovyScriptEngine engine =
                  new GroovyScriptEngine(new URL[]{u},
                                         Thread.currentThread().getContextClassLoader());
            loader = new MojarraGroovyClassLoader(engine);
            if (LOGGER.isLoggable(Level.INFO)) {
                LOGGER.log(Level.INFO,
                           "Groovy support enabled.");
View Full Code Here

        ClassLoader curLoader = Thread.currentThread().getContextClassLoader();

        URL combinedRoots[] = getResourceRoots(extContext, curLoader);

        if (0 < combinedRoots.length) {
            GroovyScriptEngine engine =
                    new GroovyScriptEngine(combinedRoots, curLoader);
//            Class<?> c = Util.loadClass("groovy.util.GroovyScriptEngine", GroovyHelperFactory.class);
//            Constructor<?> ctor = c.getConstructor(URL[].class, ClassLoader.class);
//            GroovyScriptEngine engine = (GroovyScriptEngine)ctor.newInstance(combinedRoots, curLoader);
            loader = new MojarraGroovyClassLoader(engine);
            if (LOGGER.isLoggable(Level.INFO)) {
View Full Code Here

*/
public class UseGroovyScriptEngine {
  public static void main(String[] args) {
    try {
      String[] roots = new String[] { "/src/main/groovy" };
      GroovyScriptEngine gse = new GroovyScriptEngine(roots);

      Binding binding = new Binding();
      binding.setVariable("name", "Gweneth");

      Object output = gse.run("Hello.groovy", binding);
      assert output.equals("Hello Gweneth");
    } catch (IOException | ResourceException | ScriptException e) {
      System.out.println(e.getMessage());
    }
  }
View Full Code Here

        // only called during init - safe to cast and save.
        URL u = ctx.getExternalContext().getResource(SCRIPT_PATH);

        if (u != null) {

            final GroovyScriptEngine engine =
                  new GroovyScriptEngine(new URL[]{u},
                                         Thread.currentThread().getContextClassLoader());
            loader = AccessController.doPrivileged(
                  new PrivilegedAction<MojarraGroovyClassLoader>() {
                      public MojarraGroovyClassLoader run() {
                          return new MojarraGroovyClassLoader(engine);
View Full Code Here

        ClassLoader curLoader = Thread.currentThread().getContextClassLoader();

        URL combinedRoots[] = getResourceRoots(extContext, curLoader);

        if (0 < combinedRoots.length) {
            GroovyScriptEngine engine =
                    new GroovyScriptEngine(combinedRoots, curLoader);
//            Class<?> c = Util.loadClass("groovy.util.GroovyScriptEngine", GroovyHelperFactory.class);
//            Constructor<?> ctor = c.getConstructor(URL[].class, ClassLoader.class);
//            GroovyScriptEngine engine = (GroovyScriptEngine)ctor.newInstance(combinedRoots, curLoader);
            loader = new MojarraGroovyClassLoader(engine);
            if (LOGGER.isLoggable(Level.INFO)) {
View Full Code Here

TOP

Related Classes of groovy.util.GroovyScriptEngine$ScriptCacheEntry

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.