Package org.springframework.core.io

Examples of org.springframework.core.io.ResourceLoader


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


   
    // Set bean properties from init parameters.
    try {
      PropertyValues pvs = new PortletConfigPropertyValues(getPortletConfig(), this.requiredProperties);
      BeanWrapper bw = PropertyAccessorFactory.forBeanPropertyAccess(this);
      ResourceLoader resourceLoader = new PortletContextResourceLoader(getPortletContext());
      bw.registerCustomEditor(Resource.class, new ResourceEditor(resourceLoader, this.environment));
      initBeanWrapper(bw);
      bw.setPropertyValues(pvs, true);
    }
    catch (BeansException ex) {
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));
      initBeanWrapper(bw);
      bw.setPropertyValues(pvs, true);
    }
    catch (BeansException ex) {
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

    }
    return counter;
  }

  public int loadBeanDefinitions(String location) 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 (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 (logger.isDebugEnabled()) {
        logger.debug("Loaded " + loadCount + " bean definitions from location [" + location + "]");
      }
      return loadCount;
View Full Code Here

   
    // Set bean properties from init parameters.
    try {
      PropertyValues pvs = new PortletConfigPropertyValues(getPortletConfig(), this.requiredProperties);
      BeanWrapper bw = new BeanWrapperImpl(this);
      ResourceLoader resourceLoader = new PortletContextResourceLoader(getPortletContext());
      bw.registerCustomEditor(Resource.class, new ResourceEditor(resourceLoader));
      initBeanWrapper(bw);
      bw.setPropertyValues(pvs, true);
    }
    catch (BeansException ex) {
View Full Code Here

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

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

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

  }

  public void testVelocityEngineFactoryBeanWithNonFileResourceLoaderPath() throws Exception {
    VelocityEngineFactoryBean vefb = new VelocityEngineFactoryBean();
    vefb.setResourceLoaderPath("file:/mydir");
    vefb.setResourceLoader(new ResourceLoader() {
      public Resource getResource(String location) {
        if (location.equals("file:/mydir") || location.equals("file:/mydir/test")) {
          return new ByteArrayResource("test".getBytes(), "test");
        }
        try {
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.