List of usage examples for org.springframework.core.io Resource exists
boolean exists();
From source file:io.bitsquare.app.BitsquareEnvironment.java
PropertySource<?> filesystemProperties() throws Exception { String location = String.format("file:%s/bitsquare.properties", appDataDir); Resource resource = resourceLoader.getResource(location); if (!resource.exists()) return new PropertySource.StubPropertySource(BITSQUARE_FILESYSTEM_PROPERTY_SOURCE_NAME); return new ResourcePropertySource(BITSQUARE_FILESYSTEM_PROPERTY_SOURCE_NAME, resource); }
From source file:io.tiny.mybatis.MybatisAutoConfiguration.java
@PostConstruct public void checkConfigFileExists() { if (this.properties.isCheckConfigLocation()) { Resource resource = this.resourceLoader.getResource(this.properties.getConfig()); Assert.state(resource.exists(), "Cannot find config location: " + resource + " (please add config file or check your Mybatis " + "configuration)"); }/*from w ww. j a va2 s .co m*/ }
From source file:org.mvnsearch.spring.boot.mybatis.MybatisAutoConfiguration.java
@PostConstruct public void checkConfigFileExists() { Assert.state(properties.getConfig() != null, "Cannot find config location: (please add config file or check your Mybatis configuration)"); if (this.properties.getConfig() != null) { Resource resource = this.resourceLoader.getResource(this.properties.getConfig()); Assert.state(resource.exists(), "Cannot find config location: " + resource + " (please add config file or check your Mybatis configuration)"); }//ww w .j a v a2s .c o m }
From source file:net.falsework.data.orm.mybatis.MybatisAutoConfiguration.java
@PostConstruct public void checkConfigFileExists() { Resource resource = this.resourceLoader.getResource(CONFIG_LOCATION); Assert.state(resource.exists(), "Cannot find config location: " + resource + " (please add config file or check your Mybatis configuration)"); }
From source file:org.mitre.jwt.encryption.impl.KeyStore.java
public void setLocation(Resource location) { if (location != null && location.exists()) { this.location = location; } else {/*from www . jav a2 s . c o m*/ throw new IllegalArgumentException("location must exist"); } }
From source file:org.codehaus.groovy.grails.plugins.searchable.compass.config.mapping.CompassMappingXmlSearchableGrailsDomainClassMappingConfigurator.java
/** * Configure the Mapping in the CompassConfiguration for the given domain class * * @param compassConfiguration the CompassConfiguration instance * @param configurationContext a configuration context, for flexible parameter passing * @param searchableGrailsDomainClasses searchable domain classes to map *///from ww w . j a va 2 s . c o m public void configureMappings(CompassConfiguration compassConfiguration, Map configurationContext, Collection searchableGrailsDomainClasses) { Assert.notNull(resourceLoader, "resourceLoader cannot be null"); if (configurationContext.containsKey(CompassXmlConfigurationSearchableCompassConfigurator.CONFIGURED)) { return; } for (Iterator iter = searchableGrailsDomainClasses.iterator(); iter.hasNext();) { GrailsDomainClass grailsDomainClass = (GrailsDomainClass) iter.next(); Resource resource = getMappingResource(grailsDomainClass); Assert.isTrue(resource.exists(), "expected mapping resource [" + resource + "] to exist but it does not"); try { compassConfiguration.addURL(resource.getURL()); } catch (IOException ex) { String message = "Failed to configure Compass with mapping resource for class [" + grailsDomainClass.getClazz().getName() + "] and resource [" + getMappingResourceName(grailsDomainClass) + "]"; LOG.error(message, ex); throw new IllegalStateException(message + ": " + ex); } } }
From source file:org.zalando.stups.spring.boot.actuator.ExtInfoEndpointConfiguration.java
@Bean public InfoEndpoint infoEndpoint() throws Exception { LinkedHashMap<String, Object> info = new LinkedHashMap<String, Object>(); for (String filename : getAllPropertiesFiles()) { Resource resource = new ClassPathResource("/" + filename); Properties properties = new Properties(); if (resource.exists()) { properties = PropertiesLoaderUtils.loadProperties(resource); String name = resource.getFilename(); info.put(name.replace(PROPERTIES_SUFFIX, PROPERTIES_SUFFIX_REPLACEMENT), Maps.fromProperties(properties)); } else {//from w ww .j a v a2s . c om if (failWhenResourceNotExists()) { throw new RuntimeException("Resource : " + filename + " does not exist"); } else { log.info("Resource {} does not exist", filename); } } } return new InfoEndpoint(info); }
From source file:de.langmi.spring.batch.examples.complex.support.CustomMultiResourcePartitioner.java
/** * Assign the filename of each of the injected resources to an * {@link ExecutionContext}.//www. j a v a 2 s .c o m * * @see Partitioner#partition(int) */ @Override public Map<String, ExecutionContext> partition(int gridSize) { Map<String, ExecutionContext> map = new HashMap<String, ExecutionContext>(gridSize); int i = 0; for (Resource resource : resources) { ExecutionContext context = new ExecutionContext(); Assert.state(resource.exists(), "Resource does not exist: " + resource); try { context.putString(keyName, resource.getURL().toExternalForm()); context.put("outputFileName", createOutputFilename(i, resource)); } catch (IOException e) { throw new IllegalArgumentException("File could not be located for: " + resource, e); } map.put(PARTITION_KEY + i, context); i++; } return map; }
From source file:com.epam.ta.reportportal.core.jasper.JasperReportRender.java
@Autowired public JasperReportRender(ResourceLoader resourceLoader) throws JRException, IOException { Resource reportTemplate = resourceLoader.getResource(REPORT_JRXML_TEMPLATE); com.google.common.base.Preconditions.checkArgument(reportTemplate.exists()); InputStream inputStream = reportTemplate.getInputStream(); JasperDesign jasperDesign = JRXmlLoader.load(inputStream); this.jasperReport = JasperCompileManager.compileReport(jasperDesign); }
From source file:de.langmi.spring.batch.examples.readers.file.multiresourcepartitioner.CustomMultiResourcePartitioner.java
/** * Assign the filename of each of the injected resources to an * {@link ExecutionContext}.//from ww w . j a va2 s . c o m * * @see Partitioner#partition(int) */ @Override public Map<String, ExecutionContext> partition(int gridSize) { Map<String, ExecutionContext> map = new HashMap<String, ExecutionContext>(gridSize); int i = 0; for (Resource resource : resources) { ExecutionContext context = new ExecutionContext(); Assert.state(resource.exists(), "Resource does not exist: " + resource); try { context.putString(inputKeyName, resource.getURL().toExternalForm()); context.put(outputKeyName, createOutputFilename(i, resource)); } catch (IOException e) { throw new IllegalArgumentException("File could not be located for: " + resource, e); } map.put(PARTITION_KEY + i, context); i++; } return map; }