Package groovy.lang

Examples of groovy.lang.GroovyClassLoader


  protected final GroovyClassLoader gcl;

  public ScriptContext(ModifiableInputSource mis) { this(GroovyClassLoader.class.getClassLoader(), mis); }
  public ScriptContext(ClassLoader cl, ModifiableInputSource mis) {
    this.mis = mis;
    this.gcl = new GroovyClassLoader(cl);
  }
View Full Code Here


    private void initGroovyLoader(final ClassLoader parentClassLoader) {
        if (groovyLoader == null || groovyLoader.getParent() != parentClassLoader) {
            groovyLoader =
                    (GroovyClassLoader) AccessController.doPrivileged(new PrivilegedAction() {
                        public Object run() {
                            return new GroovyClassLoader(parentClassLoader) {
                                protected Class findClass(String className) throws ClassNotFoundException {
                                    String filename = className.replace('.', File.separatorChar) + ".groovy";
                                    URLConnection dependentScriptConn = null;
                                    try {
                                        dependentScriptConn = rc.getResourceConnection(filename);
View Full Code Here

        } else {
            baseClassLoader = GroovyShell.class.getClassLoader();
        }

        final String scriptName = computeScriptName();
        final GroovyClassLoader classLoader = new GroovyClassLoader(baseClassLoader);
        addClassPathes(classLoader);
       
        final GroovyShell groovy = new GroovyShell(classLoader, new Binding(), configuration);
        parseAndRunScript(groovy, txt, mavenPom, scriptName, null, new AntBuilder(this));
    }
View Full Code Here

        if (javaHome.toLowerCase(Locale.US).endsWith("jre")) {
            javaHome = javaHome.substring(0, javaHome.length() - 4);
        }
        File toolsJar = new File((javaHome + "/lib/tools.jar"));
        if (toolsJar.exists()) {
            GroovyClassLoader loader = cu.getClassLoader();
            loader.addClasspath(toolsJar.getAbsolutePath());
            return loader.loadClass(main);
        }
       
        throw new ClassNotFoundException("unable to locate the java compiler com.sun.tools.javac.Main, please change your classloader settings");
    }
View Full Code Here

        //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

        // cached == SCRIPT should not happen here!
        if (cached == SCRIPT) throw new GroovyBugError("name "+name+" was marked as script, but was not resolved as such");
        if (cached != null) return true;

        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, SCRIPT);
            return false;
        } catch (CompilationFailedException cfe) {
            compilationUnit.getErrorCollector().addErrorAndContinue(new ExceptionMessage(cfe, true, source));
View Full Code Here

  private Settings settings;
  private GroovyClassLoader groovyClassLoader;
 
  GenerateCommand(Settings settings, String filename) throws InargumentException {
    this.settings = settings;
    groovyClassLoader = new GroovyClassLoader(getClass().getClassLoader());
   
    if (filename.startsWith("\"")) {
      if (filename.endsWith("\"")) {
        this.filename = addSuffixIfMissing(filename.substring(1, filename.length()-1));
        return;
View Full Code Here

        //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

     */

    public void setClassLoader(GroovyClassLoader loader) {
        ClassLoader parent = Thread.currentThread().getContextClassLoader();
        if (parent == null) parent = ProcessingUnit.class.getClassLoader();
        this.classLoader = (loader == null ? new GroovyClassLoader(parent, configuration) : loader);
    }
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.