if (!location.exists()) { if (path.endsWith("!/")) path = path.substring(0, path.length() - 2); if (path.startsWith("file:")) path = path.substring(5); location = new File(path); }
    public boolean loadImplementationsFromContextClassloader(Class<? extends T> parentType) {        ClassLoader loader = Thread.currentThread().getContextClassLoader();        // If it's not a URLClassLoader, we can't deal with it!        if (!(loader instanceof URLClassLoader)) {            log.error("The current ClassLoader is not castable to a URLClassLoader. ClassLoader ",                    "is of type [", loader.getClass().getName(), "]. Cannot scan ClassLoader for ",                    "implementations of ", parentType.getClass().getName(), ".");            return false;        }        else {            URLClassLoader urlLoader = (URLClassLoader) loader;            URL[] urls = urlLoader.getURLs();            for (URL url : urls) {                String path = url.getFile();                try { path = URLDecoder.decode(path, "UTF-8"); }                catch (UnsupportedEncodingException e) { /* UTF-8 is a required encoding */ }                File location = new File(path);                // Only process the URL if it matches one of our filter strings                if ( matchesAny(path, locationFilters) ) {                    log.info("Checking URL '", path, "' for instances of ", parentType.getName());                    if (location.isDirectory()) {                        loadImplementationsInDirectory(parentType, null, location);                    }                    else {                        loadImplementationsInJar(parentType, null, path);                    }                }            }            return true;        }    }