Package groovy.lang

Examples of groovy.lang.GroovyClassLoader


    }

    public void testJdkDynamicProxyDifferentLoaders() throws Exception {

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

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


    private Class loadScript(String name)
    {
        Class scriptClass = null;

        GroovyClassLoader gcl = new GroovyClassLoader(this.getClass().getClassLoader());

        name = "src/test/" + getClass().getPackage().getName().replace(".", "/") + "/" + name;

        try
        {
            scriptClass = gcl.parseClass(new File(name));
        }
        catch (CompilationFailedException e)
        {
            throw new RuntimeException("Script compilation failed: "
                + e.getMessage());
View Full Code Here

      ((ConfigurableListableBeanFactory) beanFactory).ignoreDependencyType(MetaClass.class);
    }
  }

  public void setBeanClassLoader(ClassLoader classLoader) {
    this.groovyClassLoader = new GroovyClassLoader(classLoader);
  }
View Full Code Here

        compUnit = compilationUnit;
        doAddGlobalTransforms(compilationUnit, true);
    }

    private static void doAddGlobalTransforms(CompilationUnit compilationUnit, boolean isFirstScan) {
        GroovyClassLoader transformLoader = compilationUnit.getTransformLoader();
        Map<String, URL> transformNames = new LinkedHashMap<String, URL>();
        try {
            Enumeration<URL> globalServices = transformLoader.getResources("META-INF/services/org.codehaus.groovy.transform.ASTTransformation");
            while (globalServices.hasMoreElements()) {
                URL service = globalServices.nextElement();
                String className;
                BufferedReader svcIn = new BufferedReader(new InputStreamReader(service.openStream()));
                try {
View Full Code Here

        }
    }
   
    private static void addPhaseOperationsForGlobalTransforms(CompilationUnit compilationUnit,
            Map<String, URL> transformNames, boolean isFirstScan) {
        GroovyClassLoader transformLoader = compilationUnit.getTransformLoader();
        for (Map.Entry<String, URL> entry : transformNames.entrySet()) {
            try {
                Class gTransClass = transformLoader.loadClass(entry.getKey(), false, true, false);
                //no inspection unchecked
                GroovyASTTransformation transformAnnotation = (GroovyASTTransformation) gTransClass.getAnnotation(GroovyASTTransformation.class);
                if (transformAnnotation == null) {
                    compilationUnit.getErrorCollector().addWarning(new WarningMessage(
                        WarningMessage.POSSIBLE_ERRORS,
View Full Code Here

      ((ConfigurableListableBeanFactory) beanFactory).ignoreDependencyType(MetaClass.class);
    }
  }

  public void setBeanClassLoader(ClassLoader classLoader) {
    this.groovyClassLoader = new GroovyClassLoader(classLoader);
  }
View Full Code Here

   * Return the GroovyClassLoader used by this script factory.
   */
  public GroovyClassLoader getGroovyClassLoader() {
    synchronized (this.scriptClassMonitor) {
      if (this.groovyClassLoader == null) {
        this.groovyClassLoader = new GroovyClassLoader(ClassUtils.getDefaultClassLoader());
      }
      return this.groovyClassLoader;
    }
  }
View Full Code Here

    this.groovyObjectCustomizer = groovyObjectCustomizer;
  }


  public void setBeanClassLoader(ClassLoader classLoader) {
    this.groovyClassLoader = new GroovyClassLoader(classLoader);
  }
View Full Code Here

public class GroovyClassLoadingTests extends TestCase {

  public void testClassLoading() throws Exception {
    StaticApplicationContext context = new StaticApplicationContext();

    GroovyClassLoader gcl = new GroovyClassLoader();
    Class class1 = gcl.parseClass("class TestBean { def myMethod() { \"foo\" } }");
    Class class2 = gcl.parseClass("class TestBean { def myMethod() { \"bar\" } }");

    context.registerBeanDefinition("testBean", new RootBeanDefinition(class1));
    Object testBean1 = context.getBean("testBean");
    Method method1 = class1.getDeclaredMethod("myMethod", new Class[0]);
    Object result1 = ReflectionUtils.invokeMethod(method1, testBean1);
View Full Code Here

        try {
            // store the route definition
            File file = storeRoute(route, LANGUAGE_GROOVY);

            // load the definition class into a RouteBuilder instance
            GroovyClassLoader classLoader = new GroovyClassLoader();
            Class clazz = classLoader.parseClass(file);
            RouteBuilder builder = (RouteBuilder)clazz.newInstance();
            LOG.info("Loaded builder: " + builder);

            postRoutes(builder);
View Full Code Here

TOP

Related Classes of groovy.lang.GroovyClassLoader

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.