List of usage examples for org.springframework.core.io FileSystemResource getURL
@Override public URL getURL() throws IOException
From source file:org.globus.security.stores.ResourceSecurityWrapperStore.java
public void loadWrappers(String[] locations) throws ResourceStoreException { for (String location : locations) { File file = new File(location); FileSystemResource resource = new FileSystemResource(file); try {/*from w ww .j a v a 2s.co m*/ loadWrappers(resource.getURL().toExternalForm()); } catch (IOException ioe) { throw new ResourceStoreException(ioe); } } }
From source file:com.apdplat.platform.spring.APDPlatPersistenceUnitReader.java
/** * Parse the <code>jar-file</code> XML elements. *///w w w. jav a2s . c o m @SuppressWarnings("unchecked") protected void parseJarFiles(Element persistenceUnit, SpringPersistenceUnitInfo unitInfo) throws IOException { List<Element> jars = DomUtils.getChildElementsByTagName(persistenceUnit, JAR_FILE_URL); for (Element element : jars) { logger.info( "apdplatspring jpa2(2. Start to execute custom modifications of APDPlat for Spring JPA )"); String jarHolder = DomUtils.getTextValue(element).trim(); if (jarHolder == null || "".equals(jarHolder.trim())) { continue; } logger.info("??(Content of placeholder is): " + jarHolder); //${}?? String realJars = PropertyHolder.getProperty(jarHolder.substring(2, jarHolder.length() - 1)); logger.info( "???(Content of config file related to placeholder is): " + realJars); String[] jarArray = realJars.split(","); for (String jar : jarArray) { if (StringUtils.hasText(jar)) { FileSystemResource resource = new FileSystemResource(FileUtils.getAbsolutePath(jar)); unitInfo.addJarFileUrl(resource.getURL()); } } } }
From source file:com.apdplat.platform.struts.APDPlatPackageBasedActionConfigBuilder.java
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 {/* w w w .j av a 2 s .com*/ // 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 { Set<URL> includeUrls = new HashSet<URL>(); boolean[] patternUsed = new boolean[includeJars.length]; for (int i = 0; i < includeJars.length; i++) { try { String includeJar = includeJars[i]; FileSystemResource resource = new FileSystemResource(FileUtils.getAbsolutePath(includeJar)); includeUrls.add(resource.getURL()); patternUsed[i] = true; } catch (Exception e) { e.printStackTrace(); } } 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; }