Package org.springframework.core.io

Examples of org.springframework.core.io.ByteArrayResource


  public Resource read(Class<? extends Resource> clazz, HttpInputMessage inputMessage)
      throws IOException, HttpMessageNotReadableException {

    byte[] body = FileCopyUtils.copyToByteArray(inputMessage.getBody());
    return new ByteArrayResource(body);
  }
View Full Code Here


    @SuppressWarnings("unchecked")
  protected Map<String, String> getModuleSetupProperties(String configurationXML) {
        // try loading the configuration
        XmlBeanFactory beanFactory = null;
        try {
            beanFactory = new XmlBeanFactory(new ByteArrayResource(configurationXML.getBytes()));
        } catch (BeansException be) {
          logger.error("Unable to load Tatool file.", be);
          String[] errors = be.getMessage().split(";");
          throw new CreationException(errors[errors.length-1]);
        }
View Full Code Here

    @SuppressWarnings("unchecked")
    protected Map<String, DataExporter> getModuleExporters(String configurationXML) {
        // try loading the configuration
        XmlBeanFactory beanFactory = null;
        try {
            beanFactory = new XmlBeanFactory(new ByteArrayResource(configurationXML.getBytes()));
        } catch (BeansException be) {
          logger.error("Unable to load Tatool file.", be);
            throw new RuntimeException("Unable to load Tatool file.", be);
        }
       
View Full Code Here

     */
    protected Element loadRootElementFromSpringXML(String configXML) {
        // try loading the configuration
        XmlBeanFactory beanFactory = null;
        try {
            beanFactory = new XmlBeanFactory(new ByteArrayResource(configXML.getBytes()));
        } catch (BeansException be) {
          logger.error("Unable to load Tatool file.", be);
            throw new RuntimeException("Unable to load Tatool file.");
        }
       
View Full Code Here

        + "http://www.springframework.org/schema/beans/spring-beans.xsd\n"
        + "http://www.springframework.org/schema/mvc\n"
        + "http://www.springframework.org/schema/mvc/spring-mvc.xsd\n"
        + "http://www.springframework.org/schema/springfaces\n"
        + "http://www.springframework.org/schema/springfaces/springfaces.xsd\">\n" + content + "\n</beans>";
    return loadApplicationContext(new ByteArrayResource(xml.getBytes()));
  }
View Full Code Here

  @ServiceActivator
  public Resource adapt(JobConfigurationRequest request) throws DuplicateJobException {

    String filename = request.getFilename();
    if (!StringUtils.hasText(request.getXml())) {
      return new ByteArrayResource(EMPTY_BEANS.getBytes(), filename + ":empty-string");
    }
    return new ByteArrayResource(request.getXml().getBytes(), filename);

  }
View Full Code Here

    replay(jobService);
  }

  @Test
  public void testLoadJobs() throws Exception {
    Collection<JobInfo> jobNames = loader.loadJobs(new ByteArrayResource(JOB_XML.getBytes(),
        "http://localhost/jobs/configurations"));
    assertEquals("[job]", jobNames.toString());
  }
View Full Code Here

  @Test
  public void testParentApplicationContext() throws Exception {
    StaticApplicationContext parent = new StaticApplicationContext();
    parent.refresh();
    loader.setApplicationContext(parent);
    Collection<JobInfo> jobNames = loader.loadJobs(new ByteArrayResource(JOB_XML.getBytes(),
        "http://localhost/jobs/configurations"));
    assertEquals("[job]", jobNames.toString());
  }
View Full Code Here

    private DefaultJobLoader jobLoader = new DefaultJobLoader(jobRegistry, stepRegistry);

  @Test
  public void testLoadWithExplicitName() throws Exception {
    GenericApplicationContextFactory factory = new GenericApplicationContextFactory(new ByteArrayResource(
        JOB_XML.getBytes()));
    jobLoader.load(factory);
    assertEquals(1, jobRegistry.getJobNames().size());
    jobLoader.reload(factory);
    assertEquals(1, jobRegistry.getJobNames().size());
View Full Code Here

    }

    @Test
    public void testLoadWithJobThatIsNotAStepLocator() throws DuplicateJobException {
      GenericApplicationContextFactory factory = new GenericApplicationContextFactory(
                new ByteArrayResource(BASIC_JOB_XML.getBytes()));
        try {
            jobLoader.load(factory);
            fail("Should have failed with a ["+UnsupportedOperationException.class.getName()+"] as job does not" +
                    "implement StepLocator.");
        } catch (UnsupportedOperationException e) {
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.