Package groovy.lang

Examples of groovy.lang.GroovyCodeSource


    * @param url the URL for loading script.
    * @throws IOException it script can't be loaded.
    */
   public boolean loadScript(URL url) throws IOException
   {
      Object resource = groovyScriptInstantiator.instantiateScript(new GroovyCodeSource(url), groovyClassLoader);
      if (binder.bind(resource))
      {
         // add mapping script URL to name of class.
         scriptsURL2ClassMap.put(new URLScriptKey(url), resource.getClass());
         return true;
View Full Code Here


      }
   }

   private GroovyCodeSource createCodeSource(InputStream in, String name)
   {
      GroovyCodeSource gcs = new GroovyCodeSource(in, name, "/groovy/script/jaxrs");
      gcs.setCachable(false);
      return gcs;
   }
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

    {
        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));
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

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

            GroovyCodeSource gcs = new GroovyCodeSource(groovySourceUrl);
            gcs.setCachable(false);
            return urlLoader.parseClass(gcs);
        }
        else
        {
            String groovySource = expandNCubeShortCuts(buildGroovy(getCmd(), cube.getName(), cmdHash));
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(prepareClassLoader(), config);
        Class<?> scriptClass;
        try {
            scriptClass = loader.parseClass(gcs, false);
        } catch (CompilationFailedException e) {
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

    * @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

        for (File sourceDir : sourceDirs) {
            List<File> groovySources = new ArrayList<File>(FileUtils.listFiles(sourceDir, extensions, true));

            try {
                for (File file : groovySources) {
                    GroovyCodeSource source = sourceMap.get(file);

                    if(source == null){
                        sourceMap.put(file, source = new GroovyCodeSource(file, "UTF-8"));
                    }

                    logger.info("compiling {}...", file);

                    Class aClass = gcl.parseClass(source);
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.