Package org.springframework.core.io

Examples of org.springframework.core.io.ResourceLoader


        if (locationsResourceName == null) {
            locationsResourceName = defaultModuleResourceName;
        }

        ResourceLoader resourceLoader = getResourceLoader();
        Resource resource = resourceLoader.getResource(locationsResourceName);

        if (!resource.exists()) {
            throw new ConfigurationException("Module definition XML resource '" + resource.getDescription()
                    + "' does not exist");
        }
View Full Code Here


   
    protected Properties getProperties() {
       
        String bootstrapLocationsResource = getResourceName();

        ResourceLoader resourceLoader = getResourceLoader();
        Resource bootStrapResource = null;
       
        if (bootstrapLocationsResource == null) {
            bootStrapResource = resourceLoader.getResource(defaultBootstrapResource);
        }
        else {
            // figure out which resource loader to use
            bootStrapResource = resourceLoader.getResource(bootstrapLocationsResource);
        }
        Properties properties = null;
        if (bootStrapResource == null || !bootStrapResource.exists()) {
            logger.info("Unable to load locations resource from " + bootstrapLocationsResource + ".");
            properties = new Properties();
View Full Code Here

        if (locationsResourceName == null) {
            locationsResourceName = defaultModuleResourceName;
        }

        ResourceLoader resourceLoader = getResourceLoader();
        Resource resource = resourceLoader.getResource(locationsResourceName);
        return resource;
    }
View Full Code Here

   
    protected Properties getProperties() {
       
        String bootstrapLocationsResource = getResourceName();

        ResourceLoader resourceLoader = getResourceLoader();
        Resource bootStrapResource = null;
       
        if (bootstrapLocationsResource == null) {
            bootStrapResource = resourceLoader.getResource(defaultBootstrapResource);
        }
        else {
            // figure out which resource loader to use
            bootStrapResource = resourceLoader.getResource(bootstrapLocationsResource);
        }
        Properties properties = null;
        if (bootStrapResource == null || !bootStrapResource.exists()) {
            logger.info("Unable to load locations resource from " + bootstrapLocationsResource + ".");
            properties = new Properties();
View Full Code Here

    // Set bean properties from init parameters.
    try {
      PropertyValues pvs = new FilterConfigPropertyValues(filterConfig, this.requiredProperties);
      BeanWrapper bw = PropertyAccessorFactory.forBeanPropertyAccess(this);
      ResourceLoader resourceLoader = new ServletContextResourceLoader(filterConfig.getServletContext());
      bw.registerCustomEditor(Resource.class, new ResourceEditor(resourceLoader, this.environment));
      initBeanWrapper(bw);
      bw.setPropertyValues(pvs, true);
    }
    catch (BeansException ex) {
View Full Code Here

   * @see #getResourceLoader()
   * @see #loadBeanDefinitions(org.springframework.core.io.Resource)
   * @see #loadBeanDefinitions(org.springframework.core.io.Resource[])
   */
  public int loadBeanDefinitions(String location, Set<Resource> actualResources) throws BeanDefinitionStoreException {
    ResourceLoader resourceLoader = getResourceLoader();
    if (resourceLoader == null) {
      throw new BeanDefinitionStoreException(
          "Cannot import bean definitions from location [" + location + "]: no ResourceLoader available");
    }

    if (resourceLoader instanceof ResourcePatternResolver) {
      // Resource pattern matching available.
      try {
        Resource[] resources = ((ResourcePatternResolver) resourceLoader).getResources(location);
        int loadCount = loadBeanDefinitions(resources);
        if (actualResources != null) {
          for (Resource resource : resources) {
            actualResources.add(resource);
          }
        }
        if (logger.isDebugEnabled()) {
          logger.debug("Loaded " + loadCount + " bean definitions from location pattern [" + location + "]");
        }
        return loadCount;
      }
      catch (IOException ex) {
        throw new BeanDefinitionStoreException(
            "Could not resolve bean definition resource pattern [" + location + "]", ex);
      }
    }
    else {
      // Can only load single resources by absolute URL.
      Resource resource = resourceLoader.getResource(location);
      int loadCount = loadBeanDefinitions(resource);
      if (actualResources != null) {
        actualResources.add(resource);
      }
      if (logger.isDebugEnabled()) {
View Full Code Here

   * if none specified.
   */
  protected EntityResolver getEntityResolver() {
    if (this.entityResolver == null) {
      // Determine default EntityResolver to use.
      ResourceLoader resourceLoader = getResourceLoader();
      if (resourceLoader != null) {
        this.entityResolver = new ResourceEntityResolver(resourceLoader);
      }
      else {
        this.entityResolver = new DelegatingEntityResolver(getBeanClassLoader());
View Full Code Here

        if (locationsResourceName == null) {
            locationsResourceName = defaultModuleResourceName;
        }

        ResourceLoader resourceLoader = getResourceLoader();
        Resource resource = resourceLoader.getResource(locationsResourceName);

        if (!resource.exists()) {
            throw new ConfigurationException("Module definition XML resource '" + resource.getDescription()
                    + "' does not exist");
        }
View Full Code Here

    String bootstrapLocationsResource = WebModuleUtils.getParamValue(servletContext, LocationConstants.BOOTSTRAP_MODULES_RESOURCE_PARAM);
    if (bootstrapLocationsResource == null) {
      return super.getModuleDefinitionString(servletContext);
    }
    else {
      ResourceLoader resourceLoader = getResourceLoader();
      Resource bootStrapResource = resourceLoader.getResource(bootstrapLocationsResource);

      if (bootStrapResource == null || !bootStrapResource.exists()) {
        logger.info("Unable to load locations resource from " +
            bootstrapLocationsResource + ". Delegating to superclass");
        return super.getModuleDefinitionString(servletContext);
View Full Code Here

    String bootstrapLocationsResource = WebModuleUtils.getParamValue(servletContext, LocationConstants.BOOTSTRAP_MODULES_RESOURCE_PARAM);
    if (bootstrapLocationsResource == null) {
      return super.getParentLocations(servletContext);
    }
    else {
      ResourceLoader resourceLoader = getResourceLoader();
      Resource bootStrapResource = resourceLoader.getResource(bootstrapLocationsResource);

      if (bootStrapResource == null || !bootStrapResource.exists()) {
        logger.info("Unable to load locations resource from " + bootstrapLocationsResource
            + ". Delegating to superclass");
        return super.getParentLocations(servletContext);
View Full Code Here

TOP

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

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.