Refine search
private void checkConfigFileExists() { if (this.properties.isCheckConfigLocation() && StringUtils.hasText(this.properties.getConfigLocation())) { Resource resource = this.resourceLoader.getResource(this.properties.getConfigLocation()); Assert.state(resource.exists(), "Cannot find config location: " + resource + " (please add config file or check your Mybatis configuration)"); } }
@Override public Class<?> loadClass(String name) throws ClassNotFoundException { Assert.state(this.resourceLoader != null, "ResourceLoaderClassLoadHelper not initialized"); return ClassUtils.forName(name, this.resourceLoader.getClassLoader()); }
private String getFileContent(String filename) throws IOException { try (InputStream inputStream = resourceLoader.getResource("classpath:" + filename).getInputStream()) { return IOUtils.toString(inputStream, Charsets.UTF_8.name()); } }
private void resolveResourceLocations() { if (CollectionUtils.isEmpty(this.locationValues)) { return; } else if (!CollectionUtils.isEmpty(this.locations)) { throw new IllegalArgumentException("Please set either Resource-based \"locations\" or " + "String-based \"locationValues\", but not both."); } Assert.notNull(this.resourceLoader, "ResourceLoader is required when \"locationValues\" are configured."); for (String location : this.locationValues) { Resource resource = this.resourceLoader.getResource(location); this.locations.add(resource); } }
protected Dashboard loadDashboardByJson(String jsonPath) { Resource jsonRes = resourceLoader.getResource(format("classpath:%s", jsonPath)); if (!jsonRes.exists()) { throw new DashboardException(format("There isn't the json file by the path: %s", jsonPath)); } try { String json = IOUtils.toString(jsonRes.getInputStream(), UTF_8); return jsonConverter.dashboardFromJson(json); } catch (Exception e) { throw new DashboardException(format("Error reading the json by the path: %s", jsonPath), e); } }
Assert.notNull(name, "Name must not be null"); Assert.notNull(extension, "Extension must not be null"); String location = name + this.separator + lang + this.separator + country + this.separator + variant + extension; resource = this.resourceLoader.getResource(location); if ((resource == null || !resource.exists()) && country.length() > 0) { String location = name + this.separator + lang + this.separator + country + extension; resource = this.resourceLoader.getResource(location); if ((resource == null || !resource.exists()) && lang.length() > 0) { String location = name + this.separator + lang + extension; resource = this.resourceLoader.getResource(location); if (resource == null || !resource.exists()) { String location = name + extension; resource = this.resourceLoader.getResource(location);
@Override public void setAsText(String text) { if (StringUtils.hasText(text)) { String locationToUse = resolvePath(text).trim(); setValue(this.resourceLoader.getResource(locationToUse)); } else { setValue(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 @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; } }
private void load(PropertySourceLoader loader, String location, Profile profile, DocumentFilter filter, DocumentConsumer consumer) { try { Resource resource = this.resourceLoader.getResource(location); if (resource == null || !resource.exists()) { if (this.logger.isTraceEnabled()) { StringBuilder description = getDescription( if (!StringUtils.hasText( StringUtils.getFilenameExtension(resource.getFilename()))) { if (this.logger.isTraceEnabled()) { StringBuilder description = getDescription(
factory.setDataSource(dataSource); factory.setVfs(SpringBootVFS.class); if (StringUtils.hasText(this.properties.getConfigLocation())) { factory.setConfigLocation(this.resourceLoader.getResource(this.properties.getConfigLocation())); factory.setDatabaseIdProvider(this.databaseIdProvider); if (StringUtils.hasLength(this.properties.getTypeAliasesPackage())) { factory.setTypeAliasesPackage(this.properties.getTypeAliasesPackage()); if (StringUtils.hasLength(this.properties.getTypeEnumsPackage())) { factory.setTypeEnumsPackage(this.properties.getTypeEnumsPackage());
Assert.notNull(context, "Context must not be null"); context.setTempDirectory(getTempDirectory()); if (this.resourceLoader != null) { context.setClassLoader(this.resourceLoader.getClassLoader()); context.setContextPath(StringUtils.hasLength(contextPath) ? contextPath : "/"); context.setDisplayName(getDisplayName()); configureDocumentRoot(context);
@Override @Nullable public URL getResource(String name) { Assert.state(this.resourceLoader != null, "ResourceLoaderClassLoadHelper not initialized"); Resource resource = this.resourceLoader.getResource(name); if (resource.exists()) { try { return resource.getURL(); } catch (IOException ex) { if (logger.isWarnEnabled()) { logger.warn("Could not load " + resource); } return null; } } else { return getClassLoader().getResource(name); } }
@Test public void unZipWithOneEntry() throws Exception { final Resource resource = this.resourceLoader.getResource("classpath:testzipdata/single.zip"); final InputStream is = resource.getInputStream(); byte[] zipdata = IOUtils.toByteArray(is); final Message<byte[]> message = MessageBuilder.withPayload(zipdata).build(); input.send(message); Assert.assertTrue(this.workDir.list().length == 1); File fileInWorkDir = this.workDir.listFiles()[0]; Assert.assertTrue(fileInWorkDir.isFile()); Assert.assertEquals("single.txt", fileInWorkDir.getName()); }
if (!StringUtils.hasLength(name)) { name = null; if (!StringUtils.hasLength(encoding)) { encoding = null; Assert.isTrue(locations.length > 0, "At least one @PropertySource(value) location is required"); boolean ignoreResourceNotFound = propertySource.getBoolean("ignoreResourceNotFound"); try { String resolvedLocation = this.environment.resolveRequiredPlaceholders(location); Resource resource = this.resourceLoader.getResource(resolvedLocation); addPropertySource(factory.createPropertySource(name, new EncodedResource(resource, encoding)));
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 URL getResource(String path) throws MalformedURLException { Resource resource = this.resourceLoader.getResource(getResourceLocation(path)); if (!resource.exists()) { return null; } try { return resource.getURL(); } catch (MalformedURLException ex) { throw ex; } catch (IOException ex) { if (logger.isWarnEnabled()) { logger.warn("Could not get URL for " + resource, ex); } return null; } }
private Banner getImageBanner(Environment environment) { String location = environment.getProperty(BANNER_IMAGE_LOCATION_PROPERTY); if (StringUtils.hasLength(location)) { Resource resource = this.resourceLoader.getResource(location); return resource.exists() ? new ImageBanner(resource) : null; } for (String ext : IMAGE_EXTENSION) { Resource resource = this.resourceLoader.getResource("banner." + ext); if (resource.exists()) { return new ImageBanner(resource); } } return null; }
long refreshTimestamp = (getCacheMillis() < 0 ? -1 : System.currentTimeMillis()); Resource resource = this.resourceLoader.getResource(filename + PROPERTIES_SUFFIX); if (!resource.exists()) { resource = this.resourceLoader.getResource(filename + XML_SUFFIX); if (resource.exists()) { long fileTimestamp = -1; if (getCacheMillis() >= 0) { fileTimestamp = resource.lastModified(); if (propHolder != null && propHolder.getFileTimestamp() == fileTimestamp) { if (logger.isDebugEnabled()) {
@Override @Nullable public Object findTemplateSource(String name) throws IOException { if (logger.isDebugEnabled()) { logger.debug("Looking for FreeMarker template with name [" + name + "]"); } Resource resource = this.resourceLoader.getResource(this.templateLoaderPath + name); return (resource.exists() ? resource : null); }