Examples of GroovyClassLoader


Examples of groovy.lang.GroovyClassLoader

     * @param cc
     * @return the new expanded classloader
     */
    private ClassLoader expandClassLoader(ClassLoader cl, CompilerConfiguration cc) {
        if ((classpath != null) && classpath.size() > 0) {
            cl = new GroovyClassLoader(cl, cc);
            for(GroovyScriptPath path : classpath) {
                ((GroovyClassLoader)cl).addURL(path.asURL());
            }
        }
        List<GroovyScriptPath> globalClasspath = getDescriptor().getDefaultClasspath();
        if ((globalClasspath != null) && (globalClasspath.size() > 0)) {
            if (!(cl instanceof GroovyClassLoader)) {
                cl = new GroovyClassLoader(cl, cc);
            }
            for(GroovyScriptPath path : globalClasspath) {
                ((GroovyClassLoader)cl).addURL(path.asURL());
            }
        }
View Full Code Here

Examples of groovy.lang.GroovyClassLoader

                    "    }\n" +
                    "    return v\n" +
                    "  }\n" +
                    "}";

            GroovyClassLoader loader = new GroovyClassLoader(getClass().getClassLoader());
            groovyClass = loader.parseClass(groovyString);
            try {
                match = groovyClass.getDeclaredMethod("match");
                metaField = groovyClass.getField("meta");
            } catch (NoSuchFieldException e) {
                // can never occur as we control the groovy string
View Full Code Here

Examples of groovy.lang.GroovyClassLoader

            Class<GroovyClassLoader> classLoaderClass = annotationFinder().getAnnotatedValue(UsingGroovy.class,
                    Class.class, "classLoader");
            Class<GroovyResourceFinder> resourceFinderClass = annotationFinder().getAnnotatedValue(UsingGroovy.class,
                    Class.class, "resourceFinder");
            try {
                GroovyClassLoader classLoader = super.instanceOf(classLoaderClass, classLoaderClass);
                GroovyResourceFinder resourceFinder = super.instanceOf(resourceFinderClass, resourceFinderClass);
                context = createGroovyContext(classLoader, resourceFinder);
            } catch (Exception e) {
                annotationMonitor().elementCreationFailed(GroovyContext.class, e);
            }
View Full Code Here

Examples of groovy.lang.GroovyClassLoader

public class BytecodeGroovyClassLoaderBehaviour {

    @Test
    public void shouldCacheBytes() throws IOException {
        GroovyClassLoader classLoader = new BytecodeGroovyClassLoader();
        assertNotNull((Class<?>) classLoader.parseClass("class Hello { }"));
        InputStream bytecode = classLoader.getResourceAsStream("Hello.class");
        assertNotNull(bytecode);
        bytecode.close();
    }
View Full Code Here

Examples of groovy.lang.GroovyClassLoader

   @Override
   public ClassLoader getClassLoader()
   {
      if (classLoader == null && super.getClassLoader() != null)
      {
         this.classLoader = new GroovyClassLoader(super.getClassLoader());
      }
      return classLoader;
   }
View Full Code Here

Examples of groovy.lang.GroovyClassLoader

  public CompiledScript compile(String scriptName, String scriptCode) throws ScriptCompilerException
  {
    try
    {
      GroovyClassLoader gcl = new GroovyClassLoader();
      Class scriptClass = gcl.parseClass(scriptCode);
      if (scriptClass == null)
      {
        throw new ScriptCompilerException("No compiled script code in script \"" + scriptName + "\"");
      }
      return new CompiledGroovyScript(scriptName, gcl.parseClass(scriptCode));
    }
    catch (CompilationFailedException x)
    {
      throw new ScriptCompilerException("Unable to compile script", x);
    }
View Full Code Here

Examples of groovy.lang.GroovyClassLoader

  {
    try
    {
//      GroovyShell gs = new GroovyShell();
//      gs.parse(scriptCode);
      GroovyClassLoader gcl = new GroovyClassLoader();
      Class scriptClass = gcl.parseClass(scriptCode);
      if (scriptClass == null)
      {
        throw new ScriptCompilerException("No compiled script code");
      }
    }
View Full Code Here

Examples of groovy.lang.GroovyClassLoader

            throw new GeneralException("Error loading Groovy script at [" + location + "]: ", e);
        }
    }

    public static Class<?> loadClass(String path) throws ClassNotFoundException {
        return new GroovyClassLoader().loadClass(path);
    }
View Full Code Here

Examples of groovy.lang.GroovyClassLoader

    public static Class<?> loadClass(String path) throws ClassNotFoundException {
        return new GroovyClassLoader().loadClass(path);
    }

    public static Class<?> parseClass(InputStream in, String location) throws IOException {
        return new GroovyClassLoader().parseClass(UtilIO.readString(in), location);
    }
View Full Code Here

Examples of groovy.lang.GroovyClassLoader

    public static Class<?> parseClass(InputStream in, String location) throws IOException {
        return new GroovyClassLoader().parseClass(UtilIO.readString(in), location);
    }

    public static Class<?> parseClass(String text) {
        return new GroovyClassLoader().parseClass(text);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.