Package org.springframework.core.io

Examples of org.springframework.core.io.ResourceLoader


  }

  public void testVelocityConfigurerWithCsvPathAndNonFileAccess() throws IOException, VelocityException {
    VelocityConfigurer vc = new VelocityConfigurer();
    vc.setResourceLoaderPath("file:/mydir,file:/yourdir");
    vc.setResourceLoader(new ResourceLoader() {
      public Resource getResource(String location) {
        if ("file:/yourdir/test".equals(location)) {
          return new DescriptiveResource("");
        }
        return new ByteArrayResource("test".getBytes(), "test");
View Full Code Here


    FreeMarkerConfigurationFactoryBean fcfb = new FreeMarkerConfigurationFactoryBean();
    fcfb.setTemplateLoaderPath("file:/mydir");
    Properties settings = new Properties();
    settings.setProperty("localized_lookup", "false");
    fcfb.setFreemarkerSettings(settings);
    fcfb.setResourceLoader(new ResourceLoader() {
      public Resource getResource(String location) {
        if (!("file:/mydir".equals(location) || "file:/mydir/test".equals(location))) {
          throw new IllegalArgumentException(location);
        }
        return new ByteArrayResource("test".getBytes(), "test");
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

    }


    @Override
    public Map<String, Object> load(Collection<String> loadScripts) {
        ResourceLoader loader = new DefaultResourceLoader();
        Map<String, Object> retVal = new HashMap<>();
        for (String script : loadScripts) {
            try (InputStream stream = loader.getResource(script).getInputStream()) {
                List<String> lines = IOUtils.readLines(stream);
                String content = String.join("\n", lines);

                retVal.putAll(transaction.exec(() -> execute(content)));
            } catch (IOException e) {
View Full Code Here

            return resourceName;
        }

        @Override
        protected void render(Part mailPart, String fileName) {
            ResourceLoader resourceLoader = containingContent.getResourceLoader();

            if (resourceLoader == null) {
                throw new MailBuilderException("Could not find resource \"" + resourceName
                        + "\": no resourceLoader specified");
            }

            Resource resource = resourceLoader.getResource(resourceName);

            if (!resource.exists()) {
                throw new MailBuilderException("Could not find resource \"" + resourceName + "\"");
            }
View Full Code Here

            }
        }
    }

    protected void handleImport(ParserContext parserContext, String uri) {
        final ResourceLoader resourceLoader = parserContext.getReaderContext().getReader().getResourceLoader();
        parserContext.getDelegate().getReaderContext().getReader().loadBeanDefinitions(resourceLoader.getResource(uri));
    }
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) {
      String msg = "Failed to set bean properties on filter '" + filterConfig.getFilterName() + "': "
View Full Code Here

  private ContentService contentService;

  public void testPersistContent() throws Exception {
    String buildName = "BUILD_100600601234";
    ResourceLoader loader = new DefaultResourceLoader();
    Resource resource = loader.getResource("testfile.txt");
    getContentService().persistContent(MudConstants.BUILD_NODE_STRUCTURE, buildName,
        resource.getInputStream());
    InputStream stream = getContentService().getContent(MudConstants.BUILD_NODE_STRUCTURE, buildName);
    getContentService().removeContent(MudConstants.BUILD_NODE_STRUCTURE, buildName);
    assertNotNull(stream);
View Full Code Here

    public void setSettings(SessionSettings settings) {
        this.settings = settings;
    }

    private Resource getResource() {
        ResourceLoader loader = new DefaultResourceLoader();
        return loader.getResource(this.configuration);
    }
View Full Code Here

    /**
     * @see org.springframework.beans.factory.xml.BeanDefinitionParser#parse(Element, ParserContext)
     */
    public BeanDefinition parse(Element element, ParserContext parserContext) {
        final ResourceLoader resourceLoader = parserContext.getReaderContext().getReader().getResourceLoader();

        // read avalon style configuration - it's optional for this element.
        // the schema for the sitemap element ensures that location is never null.
        final String location = getAttributeValue(element, "location", DEFAULT_COCOON_XCONF_LOCATION);
        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.