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 = AccessController.doPrivileged(new PrivilegedAction<GroovyCodeSource>() {
         public GroovyCodeSource run()
         {
            return new GroovyCodeSource(in, name, ExtendedGroovyClassLoader.CODE_BASE);
         }
      });
      gcs.setCachable(false);
      return gcs;
   }
View Full Code Here


    // Compile class
    if (scriptClass == null) {
      CompilerConfiguration config = new CompilerConfiguration();
      String script = getScript(loader, fqn);
      GroovyCodeSource gcs = new GroovyCodeSource(new ByteArrayInputStream(script.getBytes()), "myscript", "/groovy/shell");
      GroovyClassLoader gcl = new GroovyClassLoader(loader, config);
      try {
        scriptClass = gcl.parseClass(gcs, false);
      }
      catch (Exception e) {
View Full Code Here

                return compilationUnit;
            }
        };
        String scriptText = source.getResource().getText();
        String scriptName = source.getClassName();
        GroovyCodeSource codeSource = new GroovyCodeSource(scriptText == null ? "" : scriptText, scriptName, "/groovy/script");
        try {
            groovyClassLoader.parseClass(codeSource, false);
        } catch (MultipleCompilationErrorsException e) {
            wrapCompilationFailure(source, e);
        } catch (CompilationFailedException e) {
View Full Code Here

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

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

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

        String url = getUrl();

        if (StringUtilities.hasContent(url))
        {
            url = url.trim();
            GroovyCodeSource gcs;
            if (url.toLowerCase().startsWith("res://"))
            {   // URL to file within classpath
                gcs = new GroovyCodeSource(GroovyBase.class.getClassLoader().getResource(url.substring(6)));
            }
            else
            {   // URL to non-classpath file
                gcs = new GroovyCodeSource(new URL(url));
            }
            gcs.setCachable(false);
            setRunnableCode(groovyClassLoader.parseClass(gcs));
        }
        else
        {
            String groovySource = expandNCubeShortCuts(buildGroovy(getCmd(), cubeName, cmdHash));
View Full Code Here

  @Override
  public Class<? extends T> parse(String name, String source) throws CommandException {
    Class<?> clazz;
    try {
      GroovyCodeSource gcs = new GroovyCodeSource(source, name, "/groovy/shell");
      GroovyClassLoader gcl = new GroovyClassLoader(baseLoader, config);
      clazz = gcl.parseClass(gcs, false);
    }
    catch (NoClassDefFoundError e) {
      throw new CommandException(ErrorKind.INTERNAL, "Could not compile command script " + name, e);
View Full Code Here

        assert input != null;

        GroovyShell shell = new GroovyShell();
        String text = IOUtil.toString(input);
        String location = PolyglotModelUtil.getLocation(options);
        Script script = shell.parse(new GroovyCodeSource(text, location, location));

        /*
        FIXME: Bring this back as pure java
       
        def include = {source ->
View Full Code Here

    @Initializer(after=JOB_LOADED)
    public static void init(Hudson h) throws IOException {
        URL bundledInitScript = h.servletContext.getResource("/WEB-INF/init.groovy");
        if (bundledInitScript!=null) {
            LOGGER.info("Executing bundled init script: "+bundledInitScript);
            execute(new GroovyCodeSource(bundledInitScript));
        }

        File initScript = new File(h.getRootDir(),"init.groovy");
        if(initScript.exists()) {
            LOGGER.info("Executing "+initScript);
            execute(new GroovyCodeSource(initScript));
        }
    }
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

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.