Package groovy.lang

Examples of groovy.lang.GroovyCodeSource


                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) {
            SyntaxException syntaxError = e.getErrorCollector().getSyntaxError(0);
            Integer lineNumber = syntaxError == null ? null : syntaxError.getLine();
View Full Code Here


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

        parser.initialize(resource, getClassResolver());

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

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

        try
        {
View Full Code Here

     */
    public Object newInstance(String resource) {
        try {
            String name = resource.startsWith("/") ? resource : "/" + resource;
            File file = new File(this.getClass().getResource(name).toURI());
            return newInstance(classLoader.parseClass(new GroovyCodeSource(file), true));
        } catch (Exception e) {
            throw new GroovyClassInstantiationFailed(classLoader, resource, 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

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

        parser.initialize(resource, getClassResolver());

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

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

        try
        {
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);
        } catch (CompilationFailedException e) {
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

                        Collection failedKeys = new ArrayList();
                        failedKeys.add(SCRIPT_SOURCE_URL_ENCODING_PREF_KEY);
                        throw new ValidatorException("Unsupported encoding: " + this.scriptSourceUriEncoding, failedKeys);
                    }

                    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)
                        {
                            Collection failedKeys = new ArrayList();
                            failedKeys.add(SCRIPT_SOURCE_URL_ENCODING_PREF_KEY);
                            throw new ValidatorException("Unsupported encoding: " + this.scriptSourceUriEncoding, failedKeys);
                        }

                        this.groovyCodeSource = new GroovyCodeSource(new File(decodedScriptSourceUri.substring(5)));
                    }
                    else
                    {
                        Collection failedKeys = new ArrayList();
                        failedKeys.add(SCRIPT_SOURCE_PREF_KEY);
View Full Code Here

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

        File initScript = new File(j.getRootDir(),"init.groovy");
        if(initScript.exists()) {
            execute(initScript);
View Full Code Here

        }
    }

    private static void execute(File initScript) throws IOException {
        LOGGER.info("Executing "+initScript);
        execute(new GroovyCodeSource(initScript));
    }
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.