Examples of UrlSet


Examples of com.opensymphony.xwork2.util.finder.UrlSet

        return Thread.currentThread().getContextClassLoader();
    }

    private UrlSet buildUrlSet() throws IOException {
        ClassLoaderInterface classLoaderInterface = getClassLoaderInterface();
        UrlSet urlSet = new UrlSet(classLoaderInterface, this.fileProtocols);

        // excluding the urls found by the parent class loader is desired, but
        // fails in JBoss (all urls are removed)
        if (excludeParentClassLoader) {
            // exclude parent of classloaders
            ClassLoaderInterface parent = classLoaderInterface.getParent();
            // if reload is enabled, we need to step up one level, otherwise the
            // UrlSet will be empty
            // this happens because the parent of the realoding class loader is
            // the web app classloader
            if (parent != null && isReloadEnabled())
                parent = parent.getParent();

            if (parent != null)
                urlSet = urlSet.exclude(parent);

            try {
                // This may fail in some sandboxes, ie GAE
                ClassLoader systemClassLoader = ClassLoader
                        .getSystemClassLoader();
                urlSet = urlSet.exclude(new ClassLoaderInterfaceDelegate(
                        systemClassLoader.getParent()));

            } catch (SecurityException e) {
                if (LOG.isWarnEnabled())
                    LOG.warn("Could not get the system classloader due to security constraints, there may be improper urls left to scan");
            }
        }

        // try to find classes dirs inside war files
        urlSet = urlSet.includeClassesUrl(classLoaderInterface);

        urlSet = urlSet.excludeJavaExtDirs();
        urlSet = urlSet.excludeJavaEndorsedDirs();
        try {
            urlSet = urlSet.excludeJavaHome();
        } catch (NullPointerException e) {
            // This happens in GAE since the sandbox contains no java.home
            // directory
            if (LOG.isWarnEnabled())
                LOG.warn("Could not exclude JAVA_HOME, is this a sandbox jvm?");
        }
        urlSet = urlSet.excludePaths(System.getProperty("sun.boot.class.path",
                ""));
        urlSet = urlSet.exclude(".*/JavaVM.framework/.*");

        if (includeJars == null) {
            urlSet = urlSet.exclude(".*?\\.jar(!/|/)?");
        } else {
            // jar urls regexes were specified
            List<URL> rawIncludedUrls = urlSet.getUrls();
            Set<URL> includeUrls = new HashSet<URL>();
            boolean[] patternUsed = new boolean[includeJars.length];

            for (URL url : rawIncludedUrls) {
                if (fileProtocols.contains(url.getProtocol())) {
                    // it is a jar file, make sure it macthes at least a url
                    // regex
                    for (int i = 0; i < includeJars.length; i++) {
                        String includeJar = includeJars[i];
                        if (Pattern.matches(includeJar, url.toExternalForm())) {
                            includeUrls.add(url);
                            patternUsed[i] = true;
                            break;
                        }
                    }
                } else {
                    // it is not a jar
                    includeUrls.add(url);
                }
            }

            if (LOG.isWarnEnabled()) {
                for (int i = 0; i < patternUsed.length; i++) {
                    if (!patternUsed[i]) {
                        LOG.warn(
                                "The includeJars pattern [#0] did not match any jars in the classpath",
                                includeJars[i]);
                    }
                }
            }
            return new UrlSet(includeUrls);
        }

        return urlSet;
    }
View Full Code Here

Examples of com.opensymphony.xwork2.util.finder.UrlSet

        return Thread.currentThread().getContextClassLoader();
    }

    private UrlSet buildUrlSet() throws IOException {
        ClassLoaderInterface classLoaderInterface = getClassLoaderInterface();
        UrlSet urlSet = new UrlSet(classLoaderInterface, this.fileProtocols);

        // excluding the urls found by the parent class loader is desired, but
        // fails in JBoss (all urls are removed)
        if (excludeParentClassLoader) {
            // exclude parent of classloaders
            ClassLoaderInterface parent = classLoaderInterface.getParent();
            // if reload is enabled, we need to step up one level, otherwise the
            // UrlSet will be empty
            // this happens because the parent of the realoding class loader is
            // the web app classloader
            if (parent != null && isReloadEnabled())
                parent = parent.getParent();

            if (parent != null)
                urlSet = urlSet.exclude(parent);

            try {
                // This may fail in some sandboxes, ie GAE
                ClassLoader systemClassLoader = ClassLoader
                        .getSystemClassLoader();
                urlSet = urlSet.exclude(new ClassLoaderInterfaceDelegate(
                        systemClassLoader.getParent()));

            } catch (SecurityException e) {
                if (LOG.isWarnEnabled())
                    LOG.warn("Could not get the system classloader due to security constraints, there may be improper urls left to scan");
            }
        }

        // try to find classes dirs inside war files
        urlSet = urlSet.includeClassesUrl(classLoaderInterface);

        urlSet = urlSet.excludeJavaExtDirs();
        urlSet = urlSet.excludeJavaEndorsedDirs();
        try {
            urlSet = urlSet.excludeJavaHome();
        } catch (NullPointerException e) {
            // This happens in GAE since the sandbox contains no java.home
            // directory
            if (LOG.isWarnEnabled())
                LOG.warn("Could not exclude JAVA_HOME, is this a sandbox jvm?");
        }
        urlSet = urlSet.excludePaths(System.getProperty("sun.boot.class.path",
                ""));
        urlSet = urlSet.exclude(".*/JavaVM.framework/.*");

        if (includeJars == null) {
            urlSet = urlSet.exclude(".*?\\.jar(!/|/)?");
        } else {
            // jar urls regexes were specified
            List<URL> rawIncludedUrls = urlSet.getUrls();
            Set<URL> includeUrls = new HashSet<URL>();
            boolean[] patternUsed = new boolean[includeJars.length];

            for (URL url : rawIncludedUrls) {
                if (fileProtocols.contains(url.getProtocol())) {
                    // it is a jar file, make sure it macthes at least a url
                    // regex
                    for (int i = 0; i < includeJars.length; i++) {
                        String includeJar = includeJars[i];
                        if (Pattern.matches(includeJar, url.toExternalForm())) {
                            includeUrls.add(url);
                            patternUsed[i] = true;
                            break;
                        }
                    }
                } else {
                    // it is not a jar
                    includeUrls.add(url);
                }
            }

            if (LOG.isWarnEnabled()) {
                for (int i = 0; i < patternUsed.length; i++) {
                    if (!patternUsed[i]) {
                        LOG.warn(
                                "The includeJars pattern [#0] did not match any jars in the classpath",
                                includeJars[i]);
                    }
                }
            }
            return new UrlSet(includeUrls);
        }

        return urlSet;
    }
View Full Code Here

Examples of com.opensymphony.xwork2.util.finder.UrlSet

        return Thread.currentThread().getContextClassLoader();
    }

    private UrlSet buildUrlSet(List<URL> resourceUrls) throws IOException {
        ClassLoaderInterface classLoaderInterface = getClassLoaderInterface();
        UrlSet urlSet = new UrlSet(resourceUrls);
        urlSet.include(new UrlSet(classLoaderInterface, this.fileProtocols));

        //excluding the urls found by the parent class loader is desired, but fails in JBoss (all urls are removed)
        if (excludeParentClassLoader) {
            //exclude parent of classloaders
            ClassLoaderInterface parent = classLoaderInterface.getParent();
            //if reload is enabled, we need to step up one level, otherwise the UrlSet will be empty
            //this happens because the parent of the realoding class loader is the web app classloader
            if (parent != null && isReloadEnabled())
                parent = parent.getParent();

            if (parent != null)
                urlSet = urlSet.exclude(parent);

            try {
                // This may fail in some sandboxes, ie GAE
                ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader();
                urlSet = urlSet.exclude(new ClassLoaderInterfaceDelegate(systemClassLoader.getParent()));

            } catch (SecurityException e) {
                if (LOG.isWarnEnabled())
                    LOG.warn("Could not get the system classloader due to security constraints, there may be improper urls left to scan");
            }
        }

        //try to find classes dirs inside war files
        urlSet = urlSet.includeClassesUrl(classLoaderInterface, new UrlSet.FileProtocolNormalizer() {
            public URL normalizeToFileProtocol(URL url) {
                return fileManager.normalizeToFileProtocol(url);
            }
        });


        urlSet = urlSet.excludeJavaExtDirs();
        urlSet = urlSet.excludeJavaEndorsedDirs();
        try {
          urlSet = urlSet.excludeJavaHome();
        } catch (NullPointerException e) {
          // This happens in GAE since the sandbox contains no java.home directory
            if (LOG.isWarnEnabled())
              LOG.warn("Could not exclude JAVA_HOME, is this a sandbox jvm?");
        }
        urlSet = urlSet.excludePaths(System.getProperty("sun.boot.class.path", ""));
        urlSet = urlSet.exclude(".*/JavaVM.framework/.*");

        if (includeJars == null) {
            urlSet = urlSet.exclude(".*?\\.jar(!/|/)?");
        } else {
            //jar urls regexes were specified
            List<URL> rawIncludedUrls = urlSet.getUrls();
            Set<URL> includeUrls = new HashSet<URL>();
            boolean[] patternUsed = new boolean[includeJars.length];

            for (URL url : rawIncludedUrls) {
                if (fileProtocols.contains(url.getProtocol())) {
                    //it is a jar file, make sure it macthes at least a url regex
                    for (int i = 0; i < includeJars.length; i++) {
                        String includeJar = includeJars[i];
                        if (Pattern.matches(includeJar, url.toExternalForm())) {
                            includeUrls.add(url);
                            patternUsed[i] = true;
                            break;
                        }
                    }
                } else {
                    //it is not a jar
                    includeUrls.add(url);
                }
            }

            if (LOG.isWarnEnabled()) {
                for (int i = 0; i < patternUsed.length; i++) {
                    if (!patternUsed[i]) {
                        LOG.warn("The includeJars pattern [#0] did not match any jars in the classpath", includeJars[i]);
                    }
                }
            }
            return new UrlSet(includeUrls);
        }

        return urlSet;
    }
View Full Code Here

Examples of com.opensymphony.xwork2.util.finder.UrlSet

        return Thread.currentThread().getContextClassLoader();
    }

    private UrlSet buildUrlSet() throws IOException {
        ClassLoaderInterface classLoaderInterface = getClassLoaderInterface();
        UrlSet urlSet = new UrlSet(classLoaderInterface, this.fileProtocols);

        // excluding the urls found by the parent class loader is desired, but
        // fails in JBoss (all urls are removed)
        if (excludeParentClassLoader) {
            // exclude parent of classloaders
            ClassLoaderInterface parent = classLoaderInterface.getParent();
            // if reload is enabled, we need to step up one level, otherwise the
            // UrlSet will be empty
            // this happens because the parent of the realoding class loader is
            // the web app classloader
            if (parent != null && isReloadEnabled())
                parent = parent.getParent();

            if (parent != null)
                urlSet = urlSet.exclude(parent);

            try {
                // This may fail in some sandboxes, ie GAE
                ClassLoader systemClassLoader = ClassLoader
                        .getSystemClassLoader();
                urlSet = urlSet.exclude(new ClassLoaderInterfaceDelegate(
                        systemClassLoader.getParent()));

            } catch (SecurityException e) {
                if (LOG.isWarnEnabled())
                    LOG.warn("Could not get the system classloader due to security constraints, there may be improper urls left to scan");
            }
        }

        // try to find classes dirs inside war files
        urlSet = urlSet.includeClassesUrl(classLoaderInterface);

        urlSet = urlSet.excludeJavaExtDirs();
        urlSet = urlSet.excludeJavaEndorsedDirs();
        try {
            urlSet = urlSet.excludeJavaHome();
        } catch (NullPointerException e) {
            // This happens in GAE since the sandbox contains no java.home
            // directory
            if (LOG.isWarnEnabled())
                LOG.warn("Could not exclude JAVA_HOME, is this a sandbox jvm?");
        }
        urlSet = urlSet.excludePaths(System.getProperty("sun.boot.class.path",
                ""));
        urlSet = urlSet.exclude(".*/JavaVM.framework/.*");

        if (includeJars == null) {
            urlSet = urlSet.exclude(".*?\\.jar(!/|/)?");
        } else {
            // jar urls regexes were specified
            List<URL> rawIncludedUrls = urlSet.getUrls();
            Set<URL> includeUrls = new HashSet<URL>();
            boolean[] patternUsed = new boolean[includeJars.length];

            for (URL url : rawIncludedUrls) {
                if (fileProtocols.contains(url.getProtocol())) {
                    // it is a jar file, make sure it macthes at least a url
                    // regex
                    for (int i = 0; i < includeJars.length; i++) {
                        String includeJar = includeJars[i];
                        if (Pattern.matches(includeJar, url.toExternalForm())) {
                            includeUrls.add(url);
                            patternUsed[i] = true;
                            break;
                        }
                    }
                } else {
                    // it is not a jar
                    includeUrls.add(url);
                }
            }

            if (LOG.isWarnEnabled()) {
                for (int i = 0; i < patternUsed.length; i++) {
                    if (!patternUsed[i]) {
                        LOG.warn(
                                "The includeJars pattern [#0] did not match any jars in the classpath",
                                includeJars[i]);
                    }
                }
            }
            return new UrlSet(includeUrls);
        }

        return urlSet;
    }
View Full Code Here

Examples of org.apache.openejb.finder.UrlSet

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

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

Examples of org.apache.openejb.finder.UrlSet

        ClassLoader webClassLoader = webModule.getClassLoader();

        // get urls in web application
        List<URL> urls = null;
        try {
            UrlSet urlSet = new UrlSet(webClassLoader);
            urlSet = urlSet.exclude(webClassLoader.getParent());
            urls = urlSet.getUrls();
        } catch (IOException e) {
            logger.warning("Unable to determine URLs in classloader", e);
        }

        // clean jar URLs
View Full Code Here

Examples of org.apache.openejb.finder.UrlSet

    }
    private static 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

Examples of org.apache.openejb.finder.UrlSet

    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

Examples of org.apache.openejb.finder.UrlSet

        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(".*/activation-[\\d.]+.jar(!/)?");
            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(".*/asm-(all|commons|util|tree)?[\\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(".*/cglib-(nodep-)?[\\d.]+.jar(!/)?");
            urlSet = urlSet.exclude(".*/commons-(logging|logging-api|cli|pool|lang|collections|dbcp|dbcp-all)-[\\d.]+.jar(!/)?");
            urlSet = urlSet.exclude(".*/cxf-bundle-[\\d.]+(incubator)?.jar(!/)?");
            urlSet = urlSet.exclude(".*/derby-[\\d.]+.jar(!/)?");
            urlSet = urlSet.exclude(".*/ejb31-api-experimental-[\\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(".*/hibernate-(entitymanager-)?[\\d.]+ga.jar(!/)?");
            urlSet = urlSet.exclude(".*/howl-[\\d.-]+.jar(!/)?");
            urlSet = urlSet.exclude(".*/hsqldb-[\\d.]+.jar(!/)?");
            urlSet = urlSet.exclude(".*/idb-[\\d.]+.jar(!/)?");
            urlSet = urlSet.exclude(".*/idea_rt.jar(!/)?");
            urlSet = urlSet.exclude(".*/javaee-api-[\\d.-]+.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(".*/mail-[\\d.]+.jar(!/)?");
            urlSet = urlSet.exclude(".*/openjpa-(jdbc|kernel|lib|persistence|persistence-jdbc)(-5)?-[\\d.]+.jar(!/)?");
            urlSet = urlSet.exclude(".*/openjpa-[\\d.]+.jar(!/)?");
            urlSet = urlSet.exclude(".*/serp-[\\d.]+.jar(!/)?");
            urlSet = urlSet.exclude(".*/servlet-api-[\\d.]+.jar(!/)?");
            urlSet = urlSet.exclude(".*/stax-api-[\\d.]+.jar(!/)?");
            urlSet = urlSet.exclude(".*/swizzle-stream-[\\d.]+.jar(!/)?");
            urlSet = urlSet.exclude(".*/sxc-(jaxb|runtime)-[\\d.]+(-SNAPSHOT)?.jar(!/)?");
            urlSet = urlSet.exclude(".*/wsdl4j-[\\d.]+.jar(!/)?");
            urlSet = urlSet.exclude(".*/wstx-asl-[\\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/(test-)?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 < 20) {
                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

Examples of org.apache.webbeans.util.UrlSet

    @Override
    public void release()
    {
        beanClasses = new HashSet<Class<?>>();
        beanXMLs = new UrlSet();
        beanArchiveJarNames = new HashSet<String>();
        classAnnotations.clear();
    }
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.