Package groovy.lang

Examples of groovy.lang.GroovyCodeSource


    * @param name code source name
    * @return GroovyCodeSource
    */
   protected GroovyCodeSource createCodeSource(final InputStream in, final String name)
   {
      GroovyCodeSource gcs = SecurityHelper.doPrivilegedAction(new PrivilegedAction<GroovyCodeSource>() {
         public GroovyCodeSource run()
         {
            return new GroovyCodeSource(in, name, ExtendedGroovyClassLoader.CODE_BASE);
         }
      });
      gcs.setCachable(false);
      return gcs;
   }
View Full Code Here


         throw new TemplateCompilationException(e, groovyText);
      }

      //
      InputStream in = new ByteArrayInputStream(bytes);
      GroovyCodeSource gcs = new GroovyCodeSource(in, templateName, "/groovy/shell");
      GroovyClassLoader loader = new GroovyClassLoader(Thread.currentThread().getContextClassLoader(), config);
      Class<?> scriptClass;
      try
      {
         scriptClass = loader.parseClass(gcs, false);
View Full Code Here

    */
   // Override this method if need other behavior.
   @Deprecated
   protected GroovyCodeSource createCodeSource(final InputStream in, final String name)
   {
      GroovyCodeSource gcs = SecurityHelper.doPrivilegedAction(new PrivilegedAction<GroovyCodeSource>() {
         public GroovyCodeSource run()
         {
            return new GroovyCodeSource(in, name, "/groovy/script");
         }
      });
      gcs.setCachable(false);
      return gcs;
   }
View Full Code Here

            if (groovySourceUrl == null)
            {
                throw new IllegalArgumentException("Groovy code source URL is non-relative, add base url to GroovyClassLoader on NCubeManager.setUrlClassLoader(): " + url);
            }

            GroovyCodeSource gcs = new GroovyCodeSource(groovySourceUrl);
            gcs.setCachable(false);

            setRunnableCode(urlLoader.parseClass(gcs));
        }
        else
        {
View Full Code Here

    @SuppressWarnings("unchecked")
    protected Class<Script> compileScript(final String scriptBaseClass, String scriptSource, final String scriptName) {
        final String script = preProcessScript(scriptSource);

        GroovyCodeSource codeSource = AccessController.doPrivileged(new PrivilegedAction<GroovyCodeSource>() {
            public GroovyCodeSource run() {
                return new GroovyCodeSource(script, scriptName, getScriptCodeBase());
            }
        });

        String currentScriptBaseClass = compilerConfiguration.getScriptBaseClass();
        try {
View Full Code Here

    * @param name code source name
    * @return GroovyCodeSource
    */
   protected GroovyCodeSource createCodeSource(final InputStream in, final String name)
   {
      GroovyCodeSource gcs = SecurityHelper.doPrivilegedAction(new PrivilegedAction<GroovyCodeSource>() {
         public GroovyCodeSource run()
         {
            return new GroovyCodeSource(in, name, ExtendedGroovyClassLoader.CODE_BASE);
         }
      });
      gcs.setCachable(false);
      return gcs;
   }
View Full Code Here

        GroovyObject object = demo.compile("src/examples/groovy/swing/SwingDemo.groovy");
        object.invokeMethod("run", null);
    }

    protected GroovyObject compile(String fileName) throws Exception {
        Class groovyClass = loader.parseClass(new GroovyCodeSource(new File(fileName)));
        GroovyObject object = (GroovyObject) groovyClass.newInstance();
        assertTrue(object != null);
        return object;
    }
View Full Code Here

      * Execute the groovy script contained in file.  If missingPermission
      * is non-null, then this invocation expects an AccessControlException with missingPermission
      * as the reason.  If missingPermission is null, the script is expected to execute successfully.
      */
    protected Class parseClass(File file) {
        GroovyCodeSource gcs = null;
        try {
            gcs = new GroovyCodeSource(file);
        } catch (IOException fnfe) {
            fail(fnfe.toString());
        }
        return parseClass(gcs);
    }
View Full Code Here

      */
    protected void assertExecute(File file, Permission missingPermission) {
        if (!isSecurityAvailable()) {
            return;
        }
        GroovyCodeSource gcs = null;
        try {
            gcs = new GroovyCodeSource(file);
        } catch (IOException fnfe) {
            fail(fnfe.toString());
        }
        parseAndExecute(gcs, missingPermission);
    }
View Full Code Here

            return;
        }
        if (codeBase == null) {
            codeBase = "/groovy/security/test";
        }
        parseAndExecute(new GroovyCodeSource(scriptStr, generateClassName(), codeBase), missingPermission);
    }
View Full Code Here

TOP

Related Classes of groovy.lang.GroovyCodeSource

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.