Refine search
@Override @Nullable public InputStream getResourceAsStream(String path) { Resource resource = this.resourceLoader.getResource(getResourceLocation(path)); if (!resource.exists()) { return null; } try { return resource.getInputStream(); } catch (IOException ex) { if (logger.isWarnEnabled()) { logger.warn("Could not open InputStream for " + resource, ex); } return null; } }
@Override @Nullable public InputStream getResourceAsStream(String name) { Assert.state(this.resourceLoader != null, "ResourceLoaderClassLoadHelper not initialized"); Resource resource = this.resourceLoader.getResource(name); if (resource.exists()) { try { return resource.getInputStream(); } catch (IOException ex) { if (logger.isWarnEnabled()) { logger.warn("Could not load " + resource); } return null; } } else { return getClassLoader().getResourceAsStream(name); } }
@Override public InputStream getResourceAsStream(String path) { Resource resource = this.resourceLoader.getResource(getResourceLocation(path)); if (!resource.exists()) { return null; } try { return resource.getInputStream(); } catch (IOException ex) { logger.warn("Couldn't open InputStream for " + resource, ex); return null; } }
logger.trace("Trying to locate XML entity [" + systemId + "] as resource [" + resourcePath + "]"); Resource resource = this.resourceLoader.getResource(resourcePath); source = new InputSource(resource.getInputStream()); source.setPublicId(publicId); source.setSystemId(systemId);
private static TemplateLoader mustacheTemplateLoader() { ResourceLoader resourceLoader = new DefaultResourceLoader(); String prefix = "classpath:/templates/"; Charset charset = Charset.forName("UTF-8"); return (name) -> new InputStreamReader( resourceLoader.getResource(prefix + name).getInputStream(), charset); }
@Override public void afterPropertiesSet() throws Exception { if (configLocation == null) { return; } Resource resource = resourceLoader.getResource(configLocation); try { this.configMap = (Map<String, CacheConfig>) CacheConfig.fromJSON(resource.getInputStream()); } catch (IOException e) { // try to read yaml try { this.configMap = (Map<String, CacheConfig>) CacheConfig.fromYAML(resource.getInputStream()); } catch (IOException e1) { throw new BeanDefinitionStoreException( "Could not parse cache configuration at [" + configLocation + "]", e1); } } }
@Override public void afterPropertiesSet() throws Exception { if (configLocation == null) { return; } Resource resource = resourceLoader.getResource(configLocation); try { this.configMap = (Map<String, CacheConfig>) CacheConfig.fromJSON(resource.getInputStream()); } catch (IOException e) { // try to read yaml try { this.configMap = (Map<String, CacheConfig>) CacheConfig.fromYAML(resource.getInputStream()); } catch (IOException e1) { throw new BeanDefinitionStoreException( "Could not parse cache configuration at [" + configLocation + "]", e1); } } }
@Override @Nullable public InputStream getResourceAsStream(String name) { Assert.state(this.resourceLoader != null, "ResourceLoaderClassLoadHelper not initialized"); Resource resource = this.resourceLoader.getResource(name); if (resource.exists()) { try { return resource.getInputStream(); } catch (IOException ex) { if (logger.isWarnEnabled()) { logger.warn("Could not load " + resource); } return null; } } else { return getClassLoader().getResourceAsStream(name); } }
logger.trace("Trying to locate XML entity [" + systemId + "] as resource [" + resourcePath + "]"); Resource resource = this.resourceLoader.getResource(resourcePath); source = new InputSource(resource.getInputStream()); source.setPublicId(publicId); source.setSystemId(systemId);
@Override @Nullable public InputStream getResourceAsStream(String path) { Resource resource = this.resourceLoader.getResource(getResourceLocation(path)); if (!resource.exists()) { return null; } try { return resource.getInputStream(); } catch (IOException ex) { if (logger.isWarnEnabled()) { logger.warn("Could not open InputStream for " + resource, ex); } return null; } }
public ConsumerDetails getObject() throws Exception { if ("rsa-cert".equals(typeOfSecret)) { try { Certificate cert = CertificateFactory.getInstance("X.509").generateCertificate(resourceLoader.getResource(secret).getInputStream()); consumer.setSignatureSecret(new RSAKeySecret(cert.getPublicKey())); } catch (IOException e) { throw new BeanCreationException("RSA certificate not found at " + secret + ".", e); } catch (CertificateException e) { throw new BeanCreationException("Invalid RSA certificate at " + secret + ".", e); } catch (NullPointerException e) { throw new BeanCreationException("Could not load RSA certificate at " + secret + ".", e); } } else { consumer.setSignatureSecret(new SharedConsumerSecretImpl(secret)); } return consumer; }
protected String replaceWithResourceIfNecessary(String function) { String func = function; if (this.resourceLoader != null && ResourceUtils.isUrl(function)) { Resource functionResource = resourceLoader.getResource(func); if (!functionResource.exists()) { throw new InvalidDataAccessApiUsageException(String.format("Resource %s not found!", function)); } Scanner scanner = null; try { scanner = new Scanner(functionResource.getInputStream()); return scanner.useDelimiter("\\A").next(); } catch (IOException e) { throw new InvalidDataAccessApiUsageException(String.format("Cannot read map-reduce file %s!", function), e); } finally { if (scanner != null) { scanner.close(); } } } return func; }
/** * Load and print the Spring banner (if one is configured) to UserConsole. * @param environment the Spring environment */ static void printBanner(final Environment environment) { try { final String bannerLocation = environment.getProperty(BANNER_LOCATION_SPRING_PROPERTY_KEY); if (StringUtils.isNotBlank(bannerLocation)) { final ResourceLoader resourceLoader = new DefaultResourceLoader(); final Resource resource = resourceLoader.getResource(bannerLocation); if (resource.exists()) { final String banner = StreamUtils.copyToString( resource.getInputStream(), environment.getProperty( BANNER_CHARSET_SPRING_PROPERTY_KEY, Charset.class, StandardCharsets.UTF_8 ) ); UserConsole.getLogger().info(banner); } } } catch (final Throwable t) { System.err.println("Failed to print banner: " + t.getMessage()); t.printStackTrace(System.err); } } }
for (int j=0;j<length;j++) { Element element = (Element) nodeList.item(j); Resource resource = loader.getResource(element.getAttribute("resource")); ResourceInputStream ris = new ResourceInputStream(resource.getInputStream(), resource.getURL().toString()); resourceList.addEmbeddedResource(ris); element.getParentNode().removeChild(element);
final Resource resource = resourceLoader.getResource(uriString); ); try ( InputStream in = resource.getInputStream(); OutputStream out = new FileOutputStream(cachedResourceVersionDownloadFile) ) {
resourceLoader.getResource(Mockito.anyString()) ).thenReturn(resource); resource.getInputStream() ).thenAnswer( (Answer<InputStream>) invocation -> { resourceLoader2.getResource(Mockito.anyString()) ).thenReturn(resource2); resource2.getInputStream() ).thenAnswer( (Answer<InputStream>) invocation -> {
resourceLoader.getResource(Mockito.anyString()) ).thenReturn(resource); resource.getInputStream() ).thenAnswer( (Answer<InputStream>) invocation -> {
resourceLoader.getResource(Mockito.anyString()) ).thenReturn(resource); resource.getInputStream() ).thenAnswer( (Answer<InputStream>) invocation -> { resourceLoader2.getResource(Mockito.anyString()) ).thenReturn(resource2); resource2.getInputStream() ).thenAnswer( (Answer<InputStream>) invocation -> {
resourceLoader.getResource(Mockito.anyString()) ).thenReturn(resource); resource.getInputStream() ).thenAnswer( (Answer<InputStream>) invocation -> { Mockito.when(resource3.lastModified()).thenReturn(lastModifiedTimeStamp); Mockito.when( resource3.getInputStream() ).thenAnswer( (Answer<InputStream>) invocation -> { resourceLoader3.getResource(Mockito.anyString()) ).thenReturn(resource3);
logger.trace("Trying to locate XML entity [" + systemId + "] as resource [" + resourcePath + "]"); Resource resource = this.resourceLoader.getResource(resourcePath); source = new InputSource(resource.getInputStream()); source.setPublicId(publicId); source.setSystemId(systemId);