Package org.springframework.core.io

Examples of org.springframework.core.io.Resource


        if (null == cfgFiles) {
            cfgFiles = new String[] {Configurer.DEFAULT_USER_CFG_FILE};
            usingDefault = true;
        }
        for (String cfgFile : cfgFiles) {
            Resource cpr = findResource(cfgFile);
            if (cpr != null && cpr.exists()) {
                resources.add(cpr);
                LogUtils.log(LOG, Level.INFO, "USER_CFG_FILE_IN_USE", cfgFile);
            } else {
                if (!usingDefault) {
                    LogUtils.log(LOG, Level.WARNING, "USER_CFG_FILE_NOT_LOADED", cfgFile);
View Full Code Here


        res = resources.toArray(res);
        return res;
    }
   
    protected Resource findResource(String cfgFile) {
        Resource cpr = new ClassPathResource(cfgFile);
        if (cpr.exists()) {
            return cpr;
        }
        try {
            //see if it's a URL
            URL url = new URL(cfgFile);
            cpr = new UrlResource(url);
            if (cpr.exists()) {
                return cpr;
            }
        } catch (MalformedURLException e) {
            //ignore
        }
        //try loading it our way
        URL url = ClassLoaderUtils.getResource(cfgFile, this.getClass());
        if (url != null) {
            cpr = new UrlResource(url);
            if (cpr.exists()) {
                return cpr;
            }
        }
        cpr = new FileSystemResource(cfgFile);
        if (cpr.exists()) {
            return cpr;
        }
        return null;
    }
View Full Code Here

            if (resCon.getLastModified() > fixCon.getLastModified()) {
                throw new StaleFastinfosetException();
            }
        }
       
        Resource newResource = new UrlResource(fixmlUrl);
        Document doc = TunedDocumentLoader.loadFastinfosetDocument(fixmlUrl);
        if (doc == null) {
            //something caused FastinfoSet to not be able to read the doc
            throw new StaleFastinfosetException();
        }
View Full Code Here

    * @throws Exception
    */
   @Test
   public final void infinispanEmbeddedCacheManagerFactoryBeanShouldCreateACustomizedCacheManagerIfGivenADefaultConfigurationLocation()
            throws Exception {
      final Resource infinispanConfig = new ClassPathResource(NAMED_ASYNC_CACHE_CONFIG_LOCATION,
               getClass());

      final InfinispanEmbeddedCacheManagerFactoryBean objectUnderTest = new TestInfinispanEmbeddedCacheManagerFactoryBean();
      objectUnderTest.setConfigurationFileLocation(infinispanConfig);
      objectUnderTest.afterPropertiesSet();
View Full Code Here

  }

  public SpringApplicationServiceConfig(final String xmlLocation) throws IOException, ClassNotFoundException, JAXBException {
    Assert.hasText(xmlLocation, "xmlResourcePath is required");
    final PathMatchingResourcePatternResolver resourceResolver = new PathMatchingResourcePatternResolver();
    final Resource resource = resourceResolver.getResource(xmlLocation);

    try (InputStream xml = resource.getInputStream()) {
      init(xml);
    }
  }
View Full Code Here

    * @throws Exception
    */
   @Test
   public final void springEmbeddedCacheManagerFactoryBeanShouldCreateACustomizedCacheManagerIfGivenADefaultConfigurationLocation()
            throws Exception {
      final Resource infinispanConfig = new ClassPathResource(NAMED_ASYNC_CACHE_CONFIG_LOCATION,
               getClass());

      final SpringEmbeddedCacheManagerFactoryBean objectUnderTest = new SpringEmbeddedCacheManagerFactoryBean();
      objectUnderTest.setConfigurationFileLocation(infinispanConfig);
      objectUnderTest.afterPropertiesSet();
View Full Code Here

*/
public class ValidatorComponent extends ResourceBasedComponent {

    protected Endpoint<Exchange> createEndpoint(String uri, String remaining, Map parameters) throws Exception {
        SpringValidator validator = new SpringValidator();
        Resource resource = resolveMandatoryResource(remaining);
        validator.setSchemaResource(resource);
        if (log.isDebugEnabled()) {
            log.debug(this + " using schema resource: " + resource);
        }
        configureValidator(validator, uri, remaining, parameters);
View Full Code Here

    public void setResourceLoader(ResourceLoader resourceLoader) {
        this.resourceLoader = resourceLoader;
    }

    protected Resource resolveMandatoryResource(String uri) {
        Resource resource = getResourceLoader().getResource(uri);
        if (resource == null) {
            throw new IllegalArgumentException("Could not find resource for URI: " + uri + " using: " + getResourceLoader());
        } else {
            return resource;
        }
View Full Code Here

    public void setXmlConverter(XmlConverter xmlConverter) {
        this.xmlConverter = xmlConverter;
    }

    protected Endpoint<Exchange> createEndpoint(String uri, String remaining, Map parameters) throws Exception {
        Resource resource = resolveMandatoryResource(remaining);
        if (log.isDebugEnabled()) {
            log.debug(this + " using schema resource: " + resource);
        }
        XsltBuilder xslt = newInstance(XsltBuilder.class);

        // lets allow the converter to be configured
        XmlConverter converter = null;
        String converterName = getAndRemoveParameter(parameters, "converter", String.class);       
        if (converterName != null) {
            converter = mandatoryLookup(converterName, XmlConverter.class);
        }
        if (converter == null) {
            converter = getXmlConverter();
        }
        if (converter != null) {
            xslt.setConverter(converter);
        }
       
        String transformerFactoryClassName = getAndRemoveParameter(parameters, "transformerFactoryClass", String.class);
        TransformerFactory factory = null;
        if (transformerFactoryClassName != null) {
            Class factoryClass = ObjectHelper.loadClass(transformerFactoryClassName);
            if (factoryClass != null) {
                factory = (TransformerFactory) newInstance(factoryClass);
            } else {
                log.warn("Can't find the TransformerFactoryClass with the class name " + transformerFactoryClassName);
            }
        }
       
        String transformerFactoryName = getAndRemoveParameter(parameters, "transformerFactory", String.class);       
        if (transformerFactoryName != null) {
            factory = mandatoryLookup(transformerFactoryName, TransformerFactory.class);
        }
       
        if (factory != null) {
            xslt.getConverter().setTransformerFactory(factory);
        }
        xslt.setTransformerInputStream(resource.getInputStream());
        configureXslt(xslt, uri, remaining, parameters);
        return new ProcessorEndpoint(uri, this, xslt);
    }
View Full Code Here

        in.setHeader("camelFlatpackCounter", counter);
        return answer;
    }

    public Parser createParser(Exchange exchange) throws InvalidPayloadException, IOException {
        Resource resource = getResource();
        ObjectHelper.notNull(resource, "endpoint.resource");
        Reader bodyReader = ExchangeHelper.getMandatoryInBody(exchange, Reader.class);
        return createParser(resource, bodyReader);
    }
View Full Code Here

TOP

Related Classes of org.springframework.core.io.Resource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.