Package org.springframework.core.io

Examples of org.springframework.core.io.ByteArrayResource


        return new FileSystemResource(file);
    }

    @Converter
    public static ByteArrayResource toResource(byte[] data) throws IOException {
        return new ByteArrayResource(data);
    }
View Full Code Here


  }

  @Override
  protected void initTemplate() throws IOException {
    String pageName = getUrl();
    template = templateEngine.createTemplate(new ByteArrayResource(contents.getBytes("UTF-8"), pageName), false);
    if (template instanceof GroovyPageTemplate) {
      ((GroovyPageTemplate)template).setAllowSettingContentType(true);
    }
  }
View Full Code Here

            }
            else
            {
                try
                {
                    configResources[i] = new ByteArrayResource(IOUtils.toByteArray(resource.getInputStream()), resource.getResourceName());
                }
                catch (IOException e)
                {
                    throw new RuntimeException(e);
                }
View Full Code Here

        if (location.startsWith(WEB_INF_PREFIX)) {
            location = location.substring(WEB_INF_PREFIX.length());
        }
        if (groovyPages.containsKey(location)) {
            try {
                return new ByteArrayResource(groovyPages.get(location).getBytes("UTF-8"), location);
            } catch (UnsupportedEncodingException e) {
                // continue
            }
        }
       
View Full Code Here

    @Autowired
    private ApplicationContext applicationContext;

    @Override
    public Promise<String> deploy(String springTemplate) {
        Resource templateResource = new ByteArrayResource(springTemplate.getBytes());
        GenericXmlApplicationContext appContext = new GenericXmlApplicationContext();
        appContext.setParent(applicationContext);
        appContext.load(templateResource);
        appContext.refresh();
        ApplicationStack applicationStack = appContext.getBean("applicationStack", ApplicationStack.class);
View Full Code Here

     */
    public Template createTemplate(String txt, String pageName) throws IOException {
        Assert.hasLength(txt, "Argument [txt] cannot be null or blank");
        Assert.hasLength(pageName, "Argument [pageName] cannot be null or blank");

        return createTemplate(new ByteArrayResource(txt.getBytes("UTF-8"), pageName), pageName, pageName != null);
    }
View Full Code Here

                if (scaffoldedtemplateName.toLowerCase().endsWith(".gsp")) {
                    scaffoldedtemplateName = scaffoldedtemplateName.substring(0, scaffoldedtemplateName.length() - 4);
                }
                FastStringWriter sw = new FastStringWriter();
                ReflectionUtils.invokeMethod(generateViewMethod, scaffoldingTemplateGenerator, domainClass, scaffoldedtemplateName, sw);
                t = groovyPagesTemplateEngine.createTemplate(new ByteArrayResource(sw.toString().getBytes("UTF-8"), uri), false);
            }
        }
        return t;
    }
View Full Code Here

    loadContext("type='password' username='admin' access-token-uri='http://somewhere.com'");
  }

  private void loadContext(String attributes) {
    String config = HEADER + String.format(TEMPLATE, attributes) + FOOTER;
    context = new GenericXmlApplicationContext(new ByteArrayResource(config .getBytes()));
  }
View Full Code Here

        {
            _configuration = configuration;

            Resource resource = url != null
                    ? new UrlResource(url)
                    : new ByteArrayResource(("" +
                    "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
                    "<!DOCTYPE beans PUBLIC \"-//SPRING//DTD BEAN//EN\" \"http://www.springframework.org/dtd/spring-beans.dtd\">" +
                    config).getBytes(StandardCharsets.UTF_8));

            _beanFactory = new DefaultListableBeanFactory()
View Full Code Here

    assertEquals("4d0fb8162d39a340637dc42b", photo.getId());
    mockServer.verify();
  }
 
  private Resource getUploadResource(final String filename, String content) {
    Resource res = new ByteArrayResource(content.getBytes()) {
      public String getFilename() throws IllegalStateException {
        return filename;
      };
    };
    return res;
View Full Code Here

TOP

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

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.