Package org.apache.xbean.finder

Examples of org.apache.xbean.finder.UrlSet


        }
        super.validate(appModule);
    }

    private void check(final ClassLoader classLoader) {
        UrlSet set;
        final UrlSet openejbSet;
        try {
            openejbSet = new UrlSet(OpenEJB.class.getClassLoader());
            set = new UrlSet(classLoader);
            set = set.exclude(openejbSet);
        } catch (final IOException e) {
            warn(module.getModuleId() + " application", e.getMessage());
            return;
        }

        final List<URL> parentUrls = openejbSet.getUrls();
        final List<URL> currentUrls = set.getUrls();

        final Classes fcl = new Classes(currentUrls.toArray(new URL[currentUrls.size()]));
        final Classes scl = new Classes(parentUrls.toArray(new URL[parentUrls.size()]));
        final Collection<DiffItem> diffs = intersection(fcl, scl);
View Full Code Here


        Collections.reverse(classLoaders);

        for (final ClassLoader cl : classLoaders) {
            streamManager.writeOut("+" + cl.toString());

            UrlSet urls;
            try {
                urls = new UrlSet(cl);
                if (cl.getParent() != null) {
                    urls = urls.exclude(cl.getParent());
                }
            } catch (final IOException e) {
                streamManager.writeErr(INDENT + "` can't get urls of this classloader");
                continue;
            }

            final List<URL> listUrls = urls.getUrls();
            Collections.sort(listUrls, new URLComparator());
            final Iterator<URL> it = listUrls.iterator();
            while (it.hasNext()) {
                final String value = it.next().toExternalForm();
                final StringBuilder builder = new StringBuilder(INDENT);
View Full Code Here

            forceCompleteClean(loader.getParent());
        }
    }

    private static List<URL> urls(final ClassLoader classLoader) {
        UrlSet urlSet = new UrlSet();

        if (classLoader instanceof URLClassLoader) {

            final URLClassLoader urlClassLoader = (URLClassLoader) classLoader;
            try {
                urlSet = new UrlSet(urlClassLoader.getURLs());
            } catch (final NullPointerException npe) { // happen for closeable classloaders like WebappClassLoader when already clean up
                return Collections.emptyList();
            }

        } else {
            try {
                urlSet = new UrlSet(classLoader);
            } catch (final IOException e) {
                DeploymentLoader.logger.warning("Error scanning class loader for JSP tag libraries", e);
            }
        }

        try {
            urlSet = URLs.cullSystemJars(urlSet);
            urlSet = applyBuiltinExcludes(urlSet, Filters.tokens("openejb-jstl-1.2", "myfaces-impl", "javax.faces-2.", "spring-security-taglibs", "spring-webmvc"));
        } catch (final IOException e) {
            DeploymentLoader.logger.warning("Error scanning class loader for JSP tag libraries", e);
        }

        return urlSet.getUrls();
    }
View Full Code Here

    private List<URL> getUrls(StandardContext standardContext) {
        List<URL> urls = null;
        try {
            ClassLoader classLoader = standardContext.getLoader().getClassLoader();
            UrlSet urlSet = new UrlSet(classLoader);
            urlSet = urlSet.exclude(classLoader.getParent());
            urls = urlSet.getUrls();
        } catch (IOException e) {
            logger.warning("Unable to determine URLs in web application " + standardContext.getPath(), e);
        }
        return urls;
    }
View Full Code Here

    private Set<URL> scanClassLoaderForTagLibs(ClassLoader parentClassLoader) throws OpenEJBException {
        Set<URL> urls = new HashSet<URL>();
        if (parentClassLoader == null) return urls;

        UrlSet urlSet;
        try {
            urlSet = new UrlSet(parentClassLoader);
            urlSet = urlSet.excludeJavaEndorsedDirs();
            urlSet = urlSet.excludeJavaExtDirs();
            urlSet = urlSet.excludeJavaHome();
            urlSet = urlSet.exclude(ClassLoader.getSystemClassLoader());
        } catch (IOException e) {
            logger.warning("Error scanning class loader for JSP tag libraries", e);
            return urls;
        }

        for (URL url : urlSet.getUrls()) {
            if (url.getProtocol().equals("jar")) {
                try {
                    String path = url.getPath();
                    if (path.endsWith("!/")) {
                        path = path.substring(0, path.length() - 2);
View Full Code Here

        logger.debug("Using "+CLASSPATH_FILTER_SYSTEMAPPS+" '"+filterSystemApps+"'");
        logger.debug("Using "+CLASSPATH_FILTER_DESCRIPTORS+" '"+filterDescriptors+"'");
        logger.debug("Using "+CLASSPATH_REQUIRE_DESCRIPTOR+" '"+requireDescriptors+"'");

        try {
            UrlSet urlSet = new UrlSet(classLoader);
            UrlSet includes = urlSet.matching(include);
            urlSet = urlSet.exclude(ClassLoader.getSystemClassLoader().getParent());
            urlSet = urlSet.excludeJavaExtDirs();
            urlSet = urlSet.excludeJavaEndorsedDirs();
            urlSet = urlSet.excludeJavaHome();
            urlSet = urlSet.excludePaths(System.getProperty("sun.boot.class.path", ""));
            urlSet = urlSet.exclude(".*/JavaVM.framework/.*");
            urlSet = urlSet.exclude(".*/activeio-core-[\\d.]+(-incubator)?.jar(!/)?");
            urlSet = urlSet.exclude(".*/activemq-(core|ra)-[\\d.]+.jar(!/)?");
            urlSet = urlSet.exclude(".*/annotations-api-6.[01].[\\d.]+.jar(!/)?");
            urlSet = urlSet.exclude(".*/avalon-framework-[\\d.]+.jar(!/)?");
            urlSet = urlSet.exclude(".*/axis2-jaxws-api-[\\d.]+.jar(!/)?");
            urlSet = urlSet.exclude(".*/backport-util-concurrent-[\\d.]+.jar(!/)?");
            urlSet = urlSet.exclude(".*/catalina-[\\d.]+.jar(!/)?");
            urlSet = urlSet.exclude(".*/commons-(logging|cli|pool|lang|collections|dbcp)-[\\d.]+.jar(!/)?");
            urlSet = urlSet.exclude(".*/derby-[\\d.]+.jar(!/)?");
            urlSet = urlSet.exclude(".*/geronimo-(connector|transaction)-[\\d.]+.jar(!/)?");
            urlSet = urlSet.exclude(".*/geronimo-[^/]+_spec-[\\d.]+.jar(!/)?");
            urlSet = urlSet.exclude(".*/geronimo-javamail_([\\d.]+)_mail-[\\d.]+.jar(!/)?");
            urlSet = urlSet.exclude(".*/hsqldb-[\\d.]+.jar(!/)?");
            urlSet = urlSet.exclude(".*/idb-[\\d.]+.jar(!/)?");
            urlSet = urlSet.exclude(".*/idea_rt.jar(!/)?");
            urlSet = urlSet.exclude(".*/jaxb-(impl|api)-[\\d.]+.jar(!/)?");
            urlSet = urlSet.exclude(".*/jmdns-[\\d.]+(-RC\\d)?.jar(!/)?");
            urlSet = urlSet.exclude(".*/juli-[\\d.]+.jar(!/)?");
            urlSet = urlSet.exclude(".*/junit-[\\d.]+.jar(!/)?");
            urlSet = urlSet.exclude(".*/log4j-[\\d.]+.jar(!/)?");
            urlSet = urlSet.exclude(".*/logkit-[\\d.]+.jar(!/)?");
            urlSet = urlSet.exclude(".*/openjpa-(jdbc|kernel|lib|persistence|persistence-jdbc)(-5)?-[\\d.]+.jar(!/)?");
            urlSet = urlSet.exclude(".*/serp-[\\d.]+.jar(!/)?");
            urlSet = urlSet.exclude(".*/servlet-api-[\\d.]+.jar(!/)?");
            urlSet = urlSet.exclude(".*/swizzle-stream-[\\d.]+.jar(!/)?");
            urlSet = urlSet.exclude(".*/wsdl4j-[\\d.]+.jar(!/)?");
            urlSet = urlSet.exclude(".*/xbean-(reflect|naming|finder)-[\\d.]+.jar(!/)?");
            urlSet = urlSet.exclude(".*/xmlParserAPIs-[\\d.]+.jar(!/)?");
            urlSet = urlSet.exclude(".*/xmlunit-[\\d.]+.jar(!/)?");
            UrlSet prefiltered = urlSet;
            urlSet = urlSet.exclude(exclude);
            urlSet = urlSet.include(includes);

            if (filterSystemApps){
                urlSet = urlSet.exclude(".*/openejb-[^/]+(.(jar|ear|war)(!/)?|/target/classes/?)");
            }

            List<URL> urls = urlSet.getUrls();
            int size = urls.size();
            if (size == 0 && include.length() > 0) {
                logger.warning("No classpath URLs matched.  Current settings: " + CLASSPATH_EXCLUDE + "='" + exclude + "', " + CLASSPATH_INCLUDE + "='" + include + "'");
                return;
            } else if (size == 0 && (!filterDescriptors && prefiltered.getUrls().size() == 0)) {
                return;
            } else if (size < 10) {
                logger.debug("Inspecting classpath for applications: " + urls.size() + " urls.");
            } else if (size < 50 && !requireDescriptors) {
                logger.info("Inspecting classpath for applications: " + urls.size() + " urls. Consider adjusting your exclude/include.  Current settings: " + CLASSPATH_EXCLUDE + "='" + exclude + "', " + CLASSPATH_INCLUDE + "='" + include + "'");
            } else if (!requireDescriptors) {
                logger.warning("Inspecting classpath for applications: " + urls.size() + " urls.");
                logger.warning("ADJUST THE EXCLUDE/INCLUDE!!!.  Current settings: " + CLASSPATH_EXCLUDE + "='" + exclude + "', " + CLASSPATH_INCLUDE + "='" + include + "'");
            }

            long begin = System.currentTimeMillis();
            processUrls(urls, classLoader, !requireDescriptors, base, jarList);
            long end = System.currentTimeMillis();
            long time = end - begin;

            UrlSet unchecked = new UrlSet();
            if (!filterDescriptors){
                unchecked = prefiltered.exclude(urlSet);
                if (filterSystemApps){
                    unchecked = unchecked.exclude(".*/openejb-[^/]+(.(jar|ear|war)(./)?|/target/classes/?)");
                }
                processUrls(unchecked.getUrls(), classLoader, false, base, jarList);
            }

            if (logger.isDebugEnabled()) {
                logger.debug("URLs after filtering: "+urlSet.getUrls().size() + unchecked.getUrls().size());
                for (URL url : urlSet.getUrls()) {
                    logger.debug("Annotations path: " + url);
                }
                for (URL url : unchecked.getUrls()) {
                    logger.debug("Descriptors path: " + url);
                }
            }

            if (urls.size() == 0) return;
View Full Code Here

    private static Collection<URL> getUrls(final ClassLoader classLoader, final boolean excludeParent) throws IOException {
        return AnnotationFinder.getUrls(classLoader, excludeParent ? classLoader.getParent() : null);
    }

    private static Collection<URL> getUrls(final ClassLoader classLoader, final ClassLoader excludeParent) throws IOException {
        UrlSet urlSet = new UrlSet(classLoader);
        if (excludeParent != null) {
            urlSet = urlSet.exclude(excludeParent);
        }
        return urlSet.getUrls();
    }
View Full Code Here

            if (skip(url, includeFilter, excludeFilter)) {
                iterator.remove();
            }
        }

        return new UrlSet(urls);
    }
View Full Code Here

        timer.event("urlset");

        final Set<RequireDescriptors> requireDescriptors = options.getAll(DeploymentFilterable.CLASSPATH_REQUIRE_DESCRIPTOR, RequireDescriptors.CLIENT);
        try {
            UrlSet urlSet = new UrlSet(classLoader);

            timer.event("exclude system urls");
            urlSet = URLs.cullSystemJars(urlSet);

            timer.event("classpath filter");

            final UrlSet beforeFiltering = urlSet;

            urlSet = urlSet.filter(classpathFilter);

            // If the user filtered out too much, that's a problem
            if (urlSet.size() == 0) {
                final String message = String.format("Classpath Include/Exclude resulted in zero URLs.  There were %s possible URLs before filtering and 0 after: include=\"%s\", exclude=\"%s\"",
                    beforeFiltering.size(),
                    include,
                    exclude);
                logger.error(message);
                logger.info("Eligible Classpath before filtering:");

                for (final URL url : beforeFiltering) {
                    logger.info(String.format("   %s", url.toExternalForm()));
                }
            }

            // If they are the same size, than nothing was filtered
            // and we know the user did not take action to change the default
            final boolean userSuppliedClasspathFilter = beforeFiltering.size() != urlSet.size();

            if (!userSuppliedClasspathFilter) {

                logger.info("Applying buildin classpath excludes");
                timer.event("buildin excludes");
                urlSet = applyBuiltinExcludes(urlSet);

            }

            DeploymentsResolver.processUrls("NewLoaderLogic1", urlSet.getUrls(), classLoader, EnumSet.allOf(RequireDescriptors.class), base, jarList);

            timer.event("package filter");

            urlSet = filterArchives(packageFilter, classLoader, urlSet);

            timer.event("process urls");

            final List<URL> urls = urlSet.getUrls();

            final long begin = System.currentTimeMillis();
            DeploymentsResolver.processUrls("NewLoaderLogic2", urls, classLoader, requireDescriptors, base, jarList);
            final long end = System.currentTimeMillis();
            final long time = end - begin;

            timer.stop(System.out);

            final UrlSet unchecked = new UrlSet();
            DeploymentsResolver.processUrls("NewLoaderLogic3", unchecked.getUrls(), classLoader, EnumSet.allOf(RequireDescriptors.class), base, jarList);

            if (logger.isDebugEnabled()) {
                final int urlCount = urlSet.getUrls().size() + unchecked.getUrls().size();
                logger.debug("URLs after filtering: " + urlCount);
                for (final URL url : urlSet.getUrls()) {
                    logger.debug("Annotations path: " + url);
                }
                for (final URL url : unchecked.getUrls()) {
                    logger.debug("Descriptors path: " + url);
                }
            }

            if (urls.size() == 0) {
View Full Code Here

    public static UrlSet cullSystemAndOpenEJBJars(final UrlSet original) throws IOException {
        return cullSystemJars(cullOpenEJBJars(original));
    }

    public static UrlSet cullSystemJars(final UrlSet original) throws IOException {
        UrlSet urls = new UrlSet(original.getUrls());
        urls = urls.exclude(ClassLoader.getSystemClassLoader().getParent());
        urls = urls.excludeJvm();
        urls = urls.excludePaths(System.getProperty("sun.boot.class.path", ""));
        urls = urls.exclude(".*/JavaVM.framework/.*");
        return urls;
    }
View Full Code Here

TOP

Related Classes of org.apache.xbean.finder.UrlSet

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.