Examples of AntClassLoader


Examples of org.apache.tools.ant.AntClassLoader

        }
        forkedPathChecked = true;
        if (!cmd.haveClasspath()) {
            return;
        }
        AntClassLoader loader = new AntClassLoader(
            getProject(), cmd.createClasspath(getProject()));
        String projectResourceName = LoaderUtils.classNameToResource(
            Project.class.getName());
        URL previous = null;
        try {
            for (Enumeration e = loader.getResources(projectResourceName);
                 e.hasMoreElements();) {
                URL current = (URL) e.nextElement();
                if (previous != null && !current.equals(previous)) {
                    log("WARNING: multiple versions of ant detected "
                        + "in path for junit "
View Full Code Here

Examples of org.apache.tools.ant.AntClassLoader

    protected static String getMainClass(Path path, int type)
        throws BuildException {
        String packagePrefix = null;
        String mainClass = null;

        AntClassLoader l = new AntClassLoader();
        l.setClassPath(path.concatSystemClasspath("ignore"));
        String javaccClass = COM_PACKAGE + COM_JAVACC_CLASS;
        InputStream is = l.getResourceAsStream(javaccClass.replace('.', '/')
                                               + ".class");
        if (is != null) {
            packagePrefix = COM_PACKAGE;
            switch (type) {
            case TASKDEF_TYPE_JAVACC:
                mainClass = COM_JAVACC_CLASS;

                break;

            case TASKDEF_TYPE_JJTREE:
                mainClass = COM_JJTREE_CLASS;

                break;

            case TASKDEF_TYPE_JJDOC:
                mainClass = COM_JJDOC_CLASS;

                break;
            default:
                // Fall Through
            }
        } else {
            javaccClass = ORG_PACKAGE_3_1 + ORG_JAVACC_CLASS;
            is = l.getResourceAsStream(javaccClass.replace('.', '/')
                                       + ".class");
            if (is != null) {
                packagePrefix = ORG_PACKAGE_3_1;
            } else {
                javaccClass = ORG_PACKAGE_3_0 + ORG_JAVACC_CLASS;
                is = l.getResourceAsStream(javaccClass.replace('.', '/')
                                           + ".class");
                if (is != null) {
                    packagePrefix = ORG_PACKAGE_3_0;
                }
            }
View Full Code Here

Examples of org.apache.tools.ant.AntClassLoader

    String getGenicClassName(Path classpath) {

        log("Looking for GenIC class in classpath: "
            + classpath.toString(), Project.MSG_VERBOSE);

        AntClassLoader cl = classpath.getProject().createClassLoader(classpath);

        try {
            cl.loadClass(JonasDeploymentTool.GENIC_CLASS);
            log("Found GenIC class '" + JonasDeploymentTool.GENIC_CLASS
                + "' in classpath.", Project.MSG_VERBOSE);
            return JonasDeploymentTool.GENIC_CLASS;

        } catch (ClassNotFoundException cnf1) {
            log("GenIC class '" + JonasDeploymentTool.GENIC_CLASS
                + "' not found in classpath.",
            Project.MSG_VERBOSE);
        }

        try {
            cl.loadClass(JonasDeploymentTool.OLD_GENIC_CLASS_1);
            log("Found GenIC class '" + JonasDeploymentTool.OLD_GENIC_CLASS_1
                + "' in classpath.", Project.MSG_VERBOSE);
            return JonasDeploymentTool.OLD_GENIC_CLASS_1;

        } catch (ClassNotFoundException cnf2) {
            log("GenIC class '" + JonasDeploymentTool.OLD_GENIC_CLASS_1
                + "' not found in classpath.",
            Project.MSG_VERBOSE);
        }

        try {
            cl.loadClass(JonasDeploymentTool.OLD_GENIC_CLASS_2);
            log("Found GenIC class '" + JonasDeploymentTool.OLD_GENIC_CLASS_2
                + "' in classpath.", Project.MSG_VERBOSE);
            return JonasDeploymentTool.OLD_GENIC_CLASS_2;

        } catch (ClassNotFoundException cnf3) {
View Full Code Here

Examples of org.apache.tools.ant.AntClassLoader

                    rebuild = true;
                }
            }
            if (genericLoader != null
                && genericLoader instanceof AntClassLoader) {
                AntClassLoader loader = (AntClassLoader) genericLoader;
                loader.cleanup();
            }
        }

        return rebuild;
    }
View Full Code Here

Examples of org.apache.tools.ant.AntClassLoader

        classpathDependencies = null;
        Path checkPath = getCheckClassPath();
        if (checkPath != null) {
            // now determine which jars each class depends upon
            classpathDependencies = new Hashtable();
            AntClassLoader loader = getProject().createClassLoader(checkPath);

            Hashtable classpathFileCache = new Hashtable();
            Object nullFileMarker = new Object();
            for (Enumeration e = dependencyMap.keys(); e.hasMoreElements();) {
                String className = (String) e.nextElement();
                Vector dependencyList = (Vector) dependencyMap.get(className);
                Hashtable dependencies = new Hashtable();
                classpathDependencies.put(className, dependencies);
                Enumeration e2 = dependencyList.elements();
                while (e2.hasMoreElements()) {
                    String dependency = (String) e2.nextElement();
                    Object classpathFileObject
                        = classpathFileCache.get(dependency);
                    if (classpathFileObject == null) {
                        classpathFileObject = nullFileMarker;

                        if (!dependency.startsWith("java.")
                            && !dependency.startsWith("javax.")) {
                            URL classURL
                                = loader.getResource(dependency.replace('.', '/') + ".class");
                            if (classURL != null) {
                                if (classURL.getProtocol().equals("jar")) {
                                    String jarFilePath = classURL.getFile();
                                    int classMarker = jarFilePath.indexOf('!');
                                    jarFilePath = jarFilePath.substring(0, classMarker);
View Full Code Here

Examples of org.apache.tools.ant.AntClassLoader

        } else {
            classpath = new Path(getProject());
            classpath = classpath.concatSystemClasspath("only");
            getProject().log("using system classpath: " + classpath, Project.MSG_DEBUG);
        }
        AntClassLoader loader;
        loader = new AntClassLoader(getProject().getCoreLoader(),
                    getProject(),
                    classpath, false);
        String loc = null;
        if (classname != null) {
            //convert a class name into a resource
            resource = classname.replace('.', '/') + ".class";
        }

        if (resource == null) {
            throw new BuildException("One of class or resource is required");
        }

        if (resource.startsWith("/")) {
            resource = resource.substring(1);
        }

        log("Searching for " + resource, Project.MSG_VERBOSE);
        URL url;
        url = loader.getResource(resource);
        if (url != null) {
            //set the property
            loc = url.toExternalForm();
            getProject().setNewProperty(property, loc);
        }
View Full Code Here

Examples of org.apache.tools.ant.AntClassLoader

            try {
                Class c = null;
                if (classpath == null) {
                    c = Class.forName(classname);
                } else {
                    AntClassLoader al
                            = getProject().createClassLoader(classpath);
                    c = Class.forName(classname, true, al);
                }
                dynselector = (FileSelector) c.newInstance();
                final Project p = getProject();
View Full Code Here

Examples of org.apache.tools.ant.AntClassLoader

            Class readerClass = null;
            try {
                // load the parser class
                if (classpath != null) {
                    AntClassLoader loader =
                        getProject().createClassLoader(classpath);
                    readerClass = Class.forName(readerClassName, true, loader);
                } else {
                    readerClass = Class.forName(readerClassName);
                }
View Full Code Here

Examples of org.apache.tools.ant.AntClassLoader

                log("Referenced object is not an AntClassLoader",
                        Project.MSG_ERR);
                return;
            }

            AntClassLoader acl = (AntClassLoader) obj;

            if (acl == null) {
                // Construct a new class loader
                Object parent = null;
                if (parentName != null) {
                    parent = getProject().getReference(parentName);
                    if (!(parent instanceof ClassLoader)) {
                        parent = null;
                    }
                }
                // TODO: allow user to request the system or no parent
                if (parent == null) {
                    parent = this.getClass().getClassLoader();
                }

                if (name == null) {
                    // The core loader must be reverse
                    //reverse=true;
                }
                getProject().log("Setting parent loader " + name + " "
                    + parent + " " + parentFirst, Project.MSG_DEBUG);

                // The param is "parentFirst"
                acl = new AntClassLoader((ClassLoader) parent,
                         getProject(), classpath, parentFirst);

                getProject().addReference(loaderName, acl);

                if (name == null) {
                    // This allows the core loader to load optional tasks
                    // without delegating
                    acl.addLoaderPackageRoot("org.apache.tools.ant.taskdefs.optional");
                    getProject().setCoreLoader(acl);
                }
            }
            if (classpath != null) {
                String[] list = classpath.list();
                for (int i = 0; i < list.length; i++) {
                    File f = new File(list[i]);
                    if (f.exists()) {
                        acl.addPathElement(f.getAbsolutePath());
                        log("Adding to class loader " +  acl + " " + f.getAbsolutePath(),
                                Project.MSG_DEBUG);
                    }
                }
            }
View Full Code Here

Examples of org.apache.tools.ant.AntClassLoader

     */
    private CatalogResolver getCatalogResolver() {

        if (catalogResolver == null) {

            AntClassLoader loader = null;

            loader = getProject().createClassLoader(Path.systemClasspath);

            try {
                Class clazz = Class.forName(APACHE_RESOLVER, true, loader);
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.