List of usage examples for org.springframework.core.io Resource getURL
URL getURL() throws IOException;
From source file:org.urbantower.j4s.SpringWebAppContext.java
@Override public void setDescriptor(String descriptor) { try {/* w w w. j a va 2s . co m*/ if (context != null) { Resource resource = context.getResource(descriptor); super.setDescriptor(resource.getURL().toString()); } else { temporaryDescriptor = descriptor; } } catch (IOException e) { e.printStackTrace(); } }
From source file:de.contentreich.alfresco.Log4JInit.java
private void importLogSettings(Method method, String springUrl, ResourcePatternResolver resolver) { Resource[] resources = null;/*from w w w .ja va 2 s .com*/ try { resources = resolver.getResources(springUrl); } catch (Exception e) { logger.warn("Failed to find additional Logger configuration: " + springUrl); } for (Resource resource : resources) { try { URL url = resource.getURL(); method.invoke(null, url); } catch (Throwable e) { if (logger.isDebugEnabled()) { logger.debug("Failed to add extra Logger configuration: \n" + " URL: " + springUrl + "\n" + " Error: " + e.getMessage(), e); } } } }
From source file:org.urbantower.j4s.SpringWebAppContext.java
@Override public void setResourceBase(String resourceBase) { try {/*from w w w .ja v a 2 s .co m*/ if (context != null) { Resource resource = context.getResource(resourceBase); super.setResourceBase(resource.getURL().toString()); } else { temporaryResourceBase = resourceBase; } } catch (IOException e) { e.printStackTrace(); } }
From source file:org.fenixedu.start.service.ProjectService.java
private String getFilePath(Resource resource, String type) throws IOException { String path = URLDecoder.decode(resource.getURL().getPath(), "UTF-8"); return path.substring(path.indexOf("/templates/" + type + "/") + ("/templates/" + type + "/").length()); }
From source file:guru.qas.martini.jmeter.sampler.FeatureMarshaller.java
protected String getResourcePath() throws IOException { Martini martini = result.getMartini(); Recipe recipe = martini.getRecipe(); Resource resource = recipe.getSource(); URL url = null == resource ? null : resource.getURL(); return null == url ? null : url.getPath(); }
From source file:com.garrettwu.spring.view.soy.AbstractTemplateManager.java
/** * Gets all the templates within the template root. * * @return The template resources./*from w w w . j a v a2 s . c o m*/ * @throws IOException If the templates cannot be loaded. */ protected Collection<URL> getTemplateResources() throws IOException { PathMatchingResourcePatternResolver resourceResolver = new PathMatchingResourcePatternResolver(); Collection<URL> resourceUrls = new ArrayList<URL>(); for (Resource resource : resourceResolver.getResources(mTemplateResourceRoot + "/**")) { resourceUrls.add(resource.getURL()); } return resourceUrls; }
From source file:com.thoughtworks.go.spark.spa.spring.VelocityTemplateEngineFactory.java
private String toFiles(Resource[] velocityResource) throws IOException { ArrayList<String> files = new ArrayList<>(); for (Resource resource : velocityResource) { String absolutePath = new File(resource.getURL().getFile()).getAbsolutePath(); files.add(absolutePath);/*from w ww. j a v a 2 s. c o m*/ } return StringUtils.join(files, ","); }
From source file:org.apache.cxf.dosgi.singlebundle.SPIActivator.java
protected void register(final Bundle bundle) { Map<String, Callable<Class>> map = factories.get(bundle.getBundleId()); Vector<URL> v = new Vector<URL>(); try {/* w ww . ja v a 2s. c o m*/ Resource[] resources = new OsgiBundleResourcePatternResolver(bundle) .getResources("classpath*:META-INF/services/*"); for (Resource r : resources) { v.add(r.getURL()); } } catch (IOException e1) { e1.printStackTrace(); } Enumeration<URL> e = v.elements(); if (e != null) { while (e.hasMoreElements()) { final URL u = (URL) e.nextElement(); final String url = u.toString(); if (url.endsWith("/")) { continue; } final String factoryId = url.substring(url.lastIndexOf("/") + 1); if (map == null) { map = new HashMap<String, Callable<Class>>(); factories.put(bundle.getBundleId(), map); } map.put(factoryId, new Callable<Class>() { public Class call() throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(u.openStream(), "UTF-8")); String factoryClassName = br.readLine(); br.close(); return bundle.loadClass(factoryClassName); } }); } } if (map != null) { for (Map.Entry<String, Callable<Class>> entry : map.entrySet()) { OsgiLocator.register(entry.getKey(), entry.getValue()); } } }
From source file:org.hsweb.web.mybatis.MybatisProperties.java
public Resource[] resolveMapperLocations() { Map<String, Resource> resources = new HashMap<>(); Set<String> locations; if (this.getMapperLocations() == null) locations = new HashSet<>(); else//from w w w . j a va 2s . c o m locations = Arrays.stream(getMapperLocations()).collect(Collectors.toSet()); locations.add(defaultMapperLocation); for (String mapperLocation : locations) { Resource[] mappers; try { mappers = new PathMatchingResourcePatternResolver().getResources(mapperLocation); for (Resource mapper : mappers) { resources.put(mapper.getURL().toString(), mapper); } } catch (IOException e) { } } //??? if (mapperLocationExcludes != null && mapperLocationExcludes.length > 0) { for (String mapperLocationExclude : mapperLocationExcludes) { try { Resource[] excludesMappers = new PathMatchingResourcePatternResolver() .getResources(mapperLocationExclude); for (Resource excludesMapper : excludesMappers) { resources.remove(excludesMapper.getURL().toString()); } } catch (IOException e) { } } } Resource[] mapperLocations = new Resource[resources.size()]; mapperLocations = resources.values().toArray(mapperLocations); return mapperLocations; }
From source file:org.pdfsam.configuration.PdfsamEnterpriseConfig.java
@Bean(name = "logo") public Group logo() throws IOException { Resource resource = new ClassPathResource("/fxml/LogoEnterprise.fxml"); return FXMLLoader.load(resource.getURL()); }