Package groovy.lang

Examples of groovy.lang.GroovyCodeSource


        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


                    catch (UnsupportedEncodingException encodingEx)
                    {
                        throw new PortletException("Unsupported encoding: " + this.scriptSourceUriEncoding);
                    }

                    this.groovyCodeSource = new GroovyCodeSource(new File(decodedScriptSourceUri.substring(5)));
                }
                else if (this.scriptSourceUri.startsWith("classpath:"))
                {
                    String resourceURL = this.groovyClassLoader.getResource(this.scriptSourceUri.substring(10))
                            .toString();

                    if (resourceURL.startsWith("file:"))
                    {
                        String decodedScriptSourceUri = resourceURL;

                        try
                        {
                            decodedScriptSourceUri = URLDecoder.decode(resourceURL, this.scriptSourceUriEncoding);
                        }
                        catch (UnsupportedEncodingException encodingEx)
                        {
                            throw new PortletException("Unsupported encoding: " + this.scriptSourceUriEncoding);
                        }

                        this.groovyCodeSource = new GroovyCodeSource(new File(decodedScriptSourceUri.substring(5)));
                    }
                    else
                    {
                        throw new PortletException(SCRIPT_SOURCE_INIT_PARAM
                                + " with 'classpath:' prefix should indicate to a local resource");
                    }
                }
                else
                {
                    this.groovyCodeSource = new GroovyCodeSource(new File(config.getPortletContext().getRealPath(
                            this.scriptSourceUri)));
                }
            }
            catch (FileNotFoundException e)
            {
View Full Code Here

    protected ModuleDescriptor parseResource(Resource resource, SAXParser parser,
            DescriptorParser contentHandler) throws SAXException, IOException
    {
        HiveMindBuilder builder = new HiveMindBuilder(contentHandler);

        GroovyCodeSource source = new GroovyCodeSource(resource.getResourceURL());
        Script script;

        try
        {
            script = getGroovyShell().parse(source);
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

        ErrorHandler handler = new DefaultErrorHandler();
        DescriptorParser parser = new DescriptorParser(handler);

        parser.initialize(resource, new DefaultClassResolver());

        GroovyCodeSource source = new GroovyCodeSource(resource.getResourceURL());

        Script script = new GroovyShell().parse(source);

        try
        {
View Full Code Here

        ErrorHandler handler = new DefaultErrorHandler();
        DescriptorParser parser = new DescriptorParser(handler);

        parser.initialize(resource, new DefaultClassResolver());

        GroovyCodeSource source = new GroovyCodeSource(resource.getResourceURL());

        Script script = new GroovyShell().parse(source);

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

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

    log.debug("Compile: {}", url);

    Object result;
    try {
      result = shell.evaluate(new GroovyCodeSource(url));
    }
    catch (IOException e) {
      throw Throwables.propagate(e);
    }
View Full Code Here

      mapping.configure(loader);

      // Obtain script class
      URL url = PrivilegedSystemHelper.getResource("jarjar/" + name);
      Assert.assertNotNull(url);
      GroovyCodeSource gcs;
      try
      {
         gcs = new GroovyCodeSource(url);
      }
      catch (IOException e)
      {
         AssertionFailedError err = new AssertionFailedError();
         err.initCause(e);
View Full Code Here

    */
   // Override this method if need other behavior.
   @Deprecated
   protected GroovyCodeSource createCodeSource(final InputStream in, final String name)
   {
      GroovyCodeSource gcs = AccessController.doPrivileged(new PrivilegedAction<GroovyCodeSource>() {
         public GroovyCodeSource run()
         {
            return new GroovyCodeSource(in, name, "/groovy/script");
         }
      });
      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.