List of usage examples for org.springframework.util ResourceUtils URL_PROTOCOL_JAR
String URL_PROTOCOL_JAR
To view the source code for org.springframework.util ResourceUtils URL_PROTOCOL_JAR.
Click Source Link
From source file:net.paoding.rose.scanner.ModuleResourceProviderImpl.java
@Override public List<ModuleResource> findModuleResources(LoadScope scope) throws IOException { Local local = new Local(); String[] controllersScope = scope.getScope("controllers"); if (logger.isInfoEnabled()) { logger.info("[moduleResource] starting ..."); logger.info("[moduleResource] call 'findFiles':" + " to find classes or jar files by scope "// + Arrays.toString(controllersScope)); }//w w w .j av a 2 s .co m List<ResourceRef> refers = RoseScanner.getInstance().getJarOrClassesFolderResources(controllersScope); if (logger.isInfoEnabled()) { logger.info("[moduleResource] exits from 'findFiles'"); logger.info( "[moduleResource] going to scan controllers" + " from these folders or jar files:" + refers); } FileSystemManager fileSystem = new FileSystemManager(); for (ResourceRef refer : refers) { Resource resource = refer.getResource(); if (!refer.hasModifier("controllers")) { if (logger.isDebugEnabled()) { logger.debug("[moduleResource] Ignored because not marked as 'controllers'" + " in META-INF/rose.properties or META-INF/MANIFEST.MF: " + resource.getURI()); } continue; } File resourceFile = resource.getFile(); String urlString; if ("jar".equals(refer.getProtocol())) { urlString = ResourceUtils.URL_PROTOCOL_JAR + ":" + resourceFile.toURI() + ResourceUtils.JAR_URL_SEPARATOR; } else { urlString = resourceFile.toURI().toString(); } FileObject rootObject = fileSystem.resolveFile(urlString); if (rootObject == null || !rootObject.exists()) { if (logger.isDebugEnabled()) { logger.debug("[moduleResource] Ignored because not exists: " + urlString); } continue; } if (logger.isInfoEnabled()) { logger.info("[moduleResource] start to scan moduleResource in file: " + rootObject); } try { int oldSize = local.moduleResourceList.size(); deepScanImpl(local, rootObject, rootObject); int newSize = local.moduleResourceList.size(); if (logger.isInfoEnabled()) { logger.info("[moduleResource] got " + (newSize - oldSize) + " modules in " + rootObject); } } catch (Exception e) { logger.error("[moduleResource] error happend when scanning " + rootObject, e); } fileSystem.clearCache(); } afterScanning(local); logger.info("[moduleResource] found " + local.moduleResourceList.size() + " module resources "); return local.moduleResourceList; }
From source file:com.sinosoft.one.mvc.scanner.ModuleResourceProviderImpl.java
public List<ModuleResource> findModuleResources(LoadScope scope) throws IOException { Local local = new Local(); String[] controllersScope = scope.getScope("controllers"); if (logger.isInfoEnabled()) { logger.info("[moduleResource] starting ..."); logger.info("[moduleResource] call 'findFiles':" + " to find classes or jar files by scope "// + Arrays.toString(controllersScope)); }//from www. j a v a2s. c om List<ResourceRef> refers = MvcScanner.getInstance().getJarOrClassesFolderResources(controllersScope); if (logger.isInfoEnabled()) { logger.info("[moduleResource] exits from 'findFiles'"); logger.info( "[moduleResource] going to scan controllers" + " from these folders or jar files:" + refers); } FileSystemManager fileSystem = new FileSystemManager(); for (ResourceRef refer : refers) { Resource resource = refer.getResource(); if (!refer.hasModifier("controllers")) { if (logger.isDebugEnabled()) { logger.debug("[moduleResource] Ignored because not marked as 'controllers'" + " in META-INF/mvc.properties or META-INF/MANIFEST.MF: " + resource.getURI()); } continue; } File resourceFile = resource.getFile(); String urlString; if ("jar".equals(refer.getProtocol())) { urlString = ResourceUtils.URL_PROTOCOL_JAR + ":" + resourceFile.toURI() + ResourceUtils.JAR_URL_SEPARATOR; } else { urlString = resourceFile.toURI().toString(); } FileObject rootObject = fileSystem.resolveFile(urlString); if (rootObject == null || !rootObject.exists()) { if (logger.isDebugEnabled()) { logger.debug("[moduleResource] Ignored because not exists: " + urlString); } continue; } if (logger.isInfoEnabled()) { logger.info("[moduleResource] start to scan moduleResource in file: " + rootObject); } try { int oldSize = local.moduleResourceList.size(); deepScanImpl(local, rootObject, rootObject); int newSize = local.moduleResourceList.size(); if (logger.isInfoEnabled()) { logger.info("[moduleResource] got " + (newSize - oldSize) + " modules in " + rootObject); } } catch (Exception e) { logger.error("[moduleResource] error happend when scanning " + rootObject, e); } fileSystem.clearCache(); } afterScanning(local); logger.info("[moduleResource] found " + local.moduleResourceList.size() + " module resources "); return local.moduleResourceList; }
From source file:com.laxser.blitz.scanner.ModuleResourceProviderImpl.java
@Override public List<ModuleResource> findModuleResources(LoadScope scope) throws IOException { Local local = new Local(); String[] controllersScope = scope.getScope("controllers"); if (logger.isInfoEnabled()) { logger.info("[moduleResource] starting ..."); logger.info("[moduleResource] call 'findFiles':" + " to find classes or jar files by scope "// + Arrays.toString(controllersScope)); }//w w w. jav a2 s . c o m List<ResourceRef> refers = BlitzScanner.getInstance().getJarOrClassesFolderResources(controllersScope); if (logger.isInfoEnabled()) { logger.info("[moduleResource] exits from 'findFiles'"); logger.info( "[moduleResource] going to scan controllers" + " from these folders or jar files:" + refers); } FileSystemManager fileSystem = new FileSystemManager(); for (ResourceRef refer : refers) { Resource resource = refer.getResource(); if (!refer.hasModifier("controllers")) { if (logger.isDebugEnabled()) { logger.debug("[moduleResource] Ignored because not marked as 'controllers'" + " in META-INF/blitz.properties or META-INF/MANIFEST.MF: " + resource.getURI()); } continue; } File resourceFile = resource.getFile(); String urlString; if ("jar".equals(refer.getProtocol())) { urlString = ResourceUtils.URL_PROTOCOL_JAR + ":" + resourceFile.toURI() + ResourceUtils.JAR_URL_SEPARATOR; } else { urlString = resourceFile.toURI().toString(); } FileObject rootObject = fileSystem.resolveFile(urlString); if (rootObject == null || !rootObject.exists()) { if (logger.isDebugEnabled()) { logger.debug("[moduleResource] Ignored because not exists: " + urlString); } continue; } if (logger.isInfoEnabled()) { logger.info("[moduleResource] start to scan moduleResource in file: " + rootObject); } try { int oldSize = local.moduleResourceList.size(); deepScanImpl(local, rootObject, rootObject); int newSize = local.moduleResourceList.size(); if (logger.isInfoEnabled()) { logger.info("[moduleResource] got " + (newSize - oldSize) + " modules in " + rootObject); } } catch (Exception e) { logger.error("[moduleResource] error happend when scanning " + rootObject, e); } fileSystem.clearCache(); } afterScanning(local); logger.info("[moduleResource] found " + local.moduleResourceList.size() + " module resources "); return local.moduleResourceList; }
From source file:org.springframework.extensions.webscripts.ClassPathStore.java
/** * Determine whether the given URL points to a resource in a jar file, * that is, has protocol "jar", "zip", "vfszip", "wsjar" or "code-source". * <p>"zip" and "wsjar" and "vfszip" are used by BEA WebLogic Server and IBM WebSphere * and JBoss, respectively, but can be treated like jar files. The same applies to * "code-source" URLs on Oracle OC4J, provided that the path contains a jar separator. * /* w w w . j a v a 2 s .c om*/ * @param url the URL to check * * @return whether the URL has been identified as a JAR URL */ protected static boolean isJarURL(final URL url) { final String protocol = url.getProtocol(); return (ResourceUtils.URL_PROTOCOL_JAR.equals(protocol) || ResourceUtils.URL_PROTOCOL_VFSZIP.equals(protocol) || ResourceUtils.URL_PROTOCOL_ZIP.equals(protocol) || ResourceUtils.URL_PROTOCOL_VFS.equals(protocol) || ResourceUtils.URL_PROTOCOL_WSJAR.equals(protocol) || (ResourceUtils.URL_PROTOCOL_CODE_SOURCE.equals(protocol) && url.getPath().contains(ResourceUtils.JAR_URL_SEPARATOR))); }
From source file:org.springframework.web.context.support.ServletContextResourcePatternResolver.java
/** * Extract entries from the given jar by pattern. * @param jarFilePath the path to the jar file * @param entryPattern the pattern for jar entries to match * @param result the Set of matching Resources to add to *//*from w w w . ja v a2 s . c o m*/ private void doRetrieveMatchingJarEntries(String jarFilePath, String entryPattern, Set<Resource> result) { if (logger.isDebugEnabled()) { logger.debug("Searching jar file [" + jarFilePath + "] for entries matching [" + entryPattern + "]"); } try { JarFile jarFile = new JarFile(jarFilePath); try { for (Enumeration<JarEntry> entries = jarFile.entries(); entries.hasMoreElements();) { JarEntry entry = entries.nextElement(); String entryPath = entry.getName(); if (getPathMatcher().match(entryPattern, entryPath)) { result.add(new UrlResource(ResourceUtils.URL_PROTOCOL_JAR, ResourceUtils.FILE_URL_PREFIX + jarFilePath + ResourceUtils.JAR_URL_SEPARATOR + entryPath)); } } } finally { jarFile.close(); } } catch (IOException ex) { if (logger.isWarnEnabled()) { logger.warn("Cannot search for matching resources in jar file [" + jarFilePath + "] because the jar cannot be opened through the file system", ex); } } }