List of usage examples for org.springframework.util PathMatcher matchStart
boolean matchStart(String pattern, String path);
From source file:org.eclipse.gemini.blueprint.io.OsgiBundleResourcePatternResolver.java
/** * Searches for the given pattern inside the imported bundle. This translates to pattern matching on the imported * packages.//w ww . j a v a 2s. c o m * * @param importedBundle imported bundle * @param path path used for pattern matching * @param foundPaths collection of found results */ @SuppressWarnings("unchecked") private void findImportedBundleMatchingResource(final ImportedBundle importedBundle, String rootPath, String path, final Collection<String> foundPaths) throws IOException { final boolean trace = logger.isTraceEnabled(); String[] packages = importedBundle.getImportedPackages(); if (trace) logger.trace("Searching path [" + path + "] on imported pkgs " + ObjectUtils.nullSafeToString(packages) + "..."); final boolean startsWithSlash = rootPath.startsWith(FOLDER_SEPARATOR); for (int i = 0; i < packages.length; i++) { // transform the package name into a path String pkg = packages[i].replace(DOT, SLASH) + SLASH; if (startsWithSlash) { pkg = FOLDER_SEPARATOR + pkg; } final PathMatcher matcher = getPathMatcher(); // if the imported package matches the path if (matcher.matchStart(path, pkg)) { Bundle bundle = importedBundle.getBundle(); // 1. look at the Bundle jar root Enumeration<String> entries = bundle.getEntryPaths(pkg); while (entries != null && entries.hasMoreElements()) { String entry = entries.nextElement(); if (startsWithSlash) entry = FOLDER_SEPARATOR + entry; if (matcher.match(path, entry)) { if (trace) logger.trace("Found entry [" + entry + "]"); foundPaths.add(entry); } } // 2. Do a Bundle-Classpath lookup (since the jar might use a different classpath) Collection<String> cpMatchingPaths = findBundleClassPathMatchingPaths(bundle, path); foundPaths.addAll(cpMatchingPaths); } } }