Package groovy.lang

Examples of groovy.lang.GroovyClassLoader$TimestampAdder


        //TODO: don't ignore inner static classes completely
        if (name.indexOf('$') != -1) return type.isResolved();
        ModuleNode module = currentClass.getModule();
        if (module.hasPackageName() && name.indexOf('.') == -1) return type.isResolved();
        // try to find a script from classpath
        GroovyClassLoader gcl = compilationUnit.getClassLoader();
        URL url = null;
        try {
            url = gcl.getResourceLoader().loadGroovySource(name);
        } catch (MalformedURLException e) {
            // fall through and let the URL be null
        }
        if (url != null) {
            if (type.isResolved()) {
View Full Code Here


            cachedClasses.put(name,NO_CLASS);
            return false;
        }

        if (currentClass.getModule().hasPackageName() && name.indexOf('.') == -1) return false;
        GroovyClassLoader loader = compilationUnit.getClassLoader();
        Class cls;
        try {
            // NOTE: it's important to do no lookup against script files
            // here since the GroovyClassLoader would create a new CompilationUnit
            cls = loader.loadClass(name, false, true);
        } catch (ClassNotFoundException cnfe) {
            cachedClasses.put(name, NO_CLASS);
            return resolveToScript(type);
        } catch (CompilationFailedException cfe) {
            compilationUnit.getErrorCollector().addErrorAndContinue(new ExceptionMessage(cfe, true, source));
View Full Code Here

            savedLoader = thread.getContextClassLoader();
            thread.setContextClassLoader(GroovyShell.class.getClassLoader());
        }

        final String scriptName = computeScriptName();
        final GroovyClassLoader classLoader = new GroovyClassLoader(baseClassLoader);
        addClassPathes(classLoader);

        final GroovyShell groovy = new GroovyShell(classLoader, new Binding(), configuration);
        try {
            parseAndRunScript(groovy, txt, mavenPom, scriptName, null, new AntBuilder(this));
View Full Code Here

                if (!found && new File(cpEntry).exists())
                    antLoader.addPathElement(cpEntry);
            }
        }

        GroovyClassLoader loader = new GroovyClassLoader(parent, configuration);
        // in command line we don't need to do script lookups
        loader.setResourceLoader(new GroovyResourceLoader() {
            public URL loadGroovySource(String filename) throws MalformedURLException {
                return null;
            }
        });
View Full Code Here

       
        scriptExtensions.add(getScriptExtension().substring(2)); // first extension will be the one set explicitly on <groovyc>
       
        Path classpath = getClasspath() != null ? getClasspath() : new Path(getProject());
        final String[] pe = classpath.list();
        final GroovyClassLoader loader = new GroovyClassLoader(getClass().getClassLoader());
        for (String file : pe) {
          loader.addClasspath(file);
        }
        scriptExtensions.addAll(SourceExtensionHandler.getRegisteredExtensions(loader));
      }
    }
View Full Code Here

public class GenerateStubsTask
    extends CompileTaskSupport
{
    @Override
    protected void compile() {
        GroovyClassLoader gcl = createClassLoader();
        JavaStubCompilationUnit cu = new JavaStubCompilationUnit(config, gcl, destdir);

        int count = 0;

        String[] list = src.list();
View Full Code Here

        String path = createData();

        System.out.println("Test started");
        for (int i = 0; i != 100; ++i ) {
                System.out.println("Iter " + i);
                final GroovyClassLoader groovyLoader = new GroovyClassLoader ();
                groovyLoader.addClasspath(path);

                Class _script1Class = null;
                try {
                    _script1Class = groovyLoader.loadClass("Script1", true, true);
                } catch (ClassNotFoundException e) {
                    e.printStackTrace();
                }
                final Class script1Class = _script1Class;

                // setup two threads to try a deadlock

                // thread one: newInstance script foo
                final boolean completed [] = new boolean[2] ;
                Thread thread1 = new Thread() {
                    public void run() {
                        try {
                            Script script = (Script) script1Class.newInstance();
                            script.run();
                            completed [0] = true;
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                };

                Thread thread2 = new Thread() {
                    public void run() {
                        try {
                            Class cls = groovyLoader.loadClass("Script2", true, true);
                            Script script = (Script) cls.newInstance();
                            script.run();
                            completed [1] = true;
                        } catch (Exception e) {
                            e.printStackTrace();
View Full Code Here

    static boolean failed;

    public void testInitOrder () throws NoSuchFieldException, IllegalAccessException, ClassNotFoundException {
        System.out.println("GET FIELD");
        final Field f = new GroovyClassLoader().loadClass("org.codehaus.groovy.runtime.X", false, false, false).getField("field");
        System.out.println(failed);
        assertTrue(!failed);
        f.getInt(null);
        System.out.println(failed);
        assertTrue(failed);
View Full Code Here

        Script script = InvokerHelper.createScript(null, new Binding(bindingVariables));
        assertEquals(bindingVariables, script.getBinding().getVariables());
    }

    public void testCreateScriptWithScriptClass() {
        GroovyClassLoader classLoader = new GroovyClassLoader();
        String controlProperty = "text";
        String controlValue = "I am a script";
        String code = controlProperty + " = '" + controlValue + "'";
        GroovyCodeSource codeSource = new GroovyCodeSource(code, "testscript", "/groovy/shell");
        Class scriptClass = classLoader.parseClass(codeSource, false);
        Script script = InvokerHelper.createScript(scriptClass, new Binding(bindingVariables));
        assertEquals(bindingVariables, script.getBinding().getVariables());
        script.run();
        assertEquals(controlValue, script.getProperty(controlProperty));
    }
View Full Code Here

public class JdkDynamicProxyTest extends GroovyTestCase {

    public void testJdkDynamicProxySameLoader() throws Exception {

        // Instantiate all beans.
        final GroovyClassLoader loader = new GroovyClassLoader();
        JdkDynamicProxyServiceBean sb1 = (JdkDynamicProxyServiceBean) JdkDynamicProxyInvocationHandler.getProxiedObject(loader.loadClass("org.codehaus.groovy.runtime.JdkDynamicProxyServiceBeanImpl1").newInstance());
        JdkDynamicProxyServiceBean sb2 = (JdkDynamicProxyServiceBean) JdkDynamicProxyInvocationHandler.getProxiedObject(loader.loadClass("org.codehaus.groovy.runtime.JdkDynamicProxyServiceBeanImpl2").newInstance());

        // Manually wire beans together.
        sb1.setJdkDynamicProxyServiceBean(sb2);
        assertEquals("SERVICE", sb1.doService());
    }
View Full Code Here

TOP

Related Classes of groovy.lang.GroovyClassLoader$TimestampAdder

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.