Package org.springframework.core.io

Examples of org.springframework.core.io.InputStreamResource


            throw new RuntimeException(
                    "Can't locate resource descriptor in the ClassLoader: "
                            + TEST_RESOURCES_DESCRIPTOR);
        }

        BeanFactory factory = new XmlBeanFactory(new InputStreamResource(in));
        CayenneResources resources = (CayenneResources) factory.getBean(
                "TestResources",
                CayenneResources.class);

        resources.setConnectionKey(System.getProperty(CONNECTION_NAME_KEY));
View Full Code Here


            return null;
        }

        if (is != null)
        {
            return new InputStreamResource(is);
        }
        else
        {
            logger.error("Unable to locate Spring resource " + path);
            return null;
View Full Code Here

            String finalString = script.replace("${webapp}", webapp);
            final String classpathPrefix = "classpath:";
            if (finalString.startsWith(classpathPrefix)) {
                final String resourceString = finalString.substring(classpathPrefix.length());
                try {
                    addScript(new InputStreamResource(getClass().getClassLoader().getResourceAsStream(resourceString)));
                } catch (Exception e) {
                    throw new AssertionError("Failed to load data script as a from the classpath: "+resourceString);
                }
            } else {
                // series of hack for different platforms...
                try {
                    addScript(new InputStreamResource(new URL(finalString).openStream()));
                } catch (Exception e) {
                    String fileUrlPrefix = "file:/";
                    if (finalString.startsWith(fileUrlPrefix)) {
                        finalString = finalString.substring(fileUrlPrefix.length());
                    }
                    if (!new File(finalString).exists()) {
                        finalString = finalString.substring(1);
                    }
                    if (new File(finalString).exists()) {
                        addScript(new InputStreamResource(new FileInputStream(finalString)));
                    } else {
                        throw new AssertionError("Failed to load data script as a url: "+finalString);
                    }
                }
            }
View Full Code Here

            xmlReader.setBeanClassLoader(classLoader);

            for (ModuleSource.SpringConfigEntry entry : cfg.getModuleSource().getSpringConfigs(runtime.getMode())) {
                InputStream is = entry.getStream();
                try {
                    xmlReader.loadBeanDefinitions(new InputStreamResource(is, entry.getLocation() + " in " + cfg.getDefinition().getFile().getAbsolutePath()));
                } finally {
                    IOUtils.closeQuietly(is, entry.getLocation());
                }
            }
            applicationContext.refresh();
View Full Code Here

                    Resource inputSource = new FileSystemResource(file);
                    reader.loadBeanDefinitions(inputSource);
                } else {
                    InputStream inputStream = loader.loadInputStream(importFile);
                    try {
                        Resource inputSource = new InputStreamResource(inputStream);
                        reader.loadBeanDefinitions(inputSource);
                    } finally {
                        IOUtils.closeQuietly(inputStream);
                    }
                }
View Full Code Here

    }

    public static void main(String[] args) throws Exception {
  try {
      InputStream in = new FileInputStream("temp");
      Resource resource = new InputStreamResource(in);
      CSVReader csvReader = new CSVReader(new BufferedReader(
        new InputStreamReader(resource.getInputStream())));
      List<String> list = csvReader.readLine();
      while (list.size() > 0) {
    System.out.println(list);
    list = csvReader.readLine();
      }
View Full Code Here

     */
    @Test
    public final void testGenerateSimpleObjectFromCsv() throws Exception {
  try {
      CsvToObjectMapper csvToObjectMapper = new CsvToObjectMapper(
        new InputStreamResource(new ByteArrayInputStream(
          csvFileContent.getBytes())), false,
        "simpleCsvMappingDefinition");
      // assertTrue(csvToObjectMapper.loadNextRecord());
      CsvSimpleTestBean bean = (CsvSimpleTestBean) csvToObjectMapper
        .generateNextObjectFromCsv();
View Full Code Here

     */
    @Test
    public final void testGenerateComplexObjectFromCsv() throws Exception {
  try {
      CsvToObjectMapper csvToObjectMapper = new CsvToObjectMapper(
        new InputStreamResource(new ByteArrayInputStream(
          csvFileContent.getBytes())), false,
        "complexCsvMappingDefinition");
      // assertTrue(csvToObjectMapper.loadNextRecord());
      CsvComplexTestBean bean = (CsvComplexTestBean) csvToObjectMapper
        .generateNextObjectFromCsv();
View Full Code Here

          }
        }
       
        System.out.println("new application context:\n" + applicationContextXML);
       
        applicationContext = new InputStreamResource( new ByteArrayInputStream(applicationContextXML.getBytes()));
     }
     XmlBeanFactory factory = new XmlBeanFactory(applicationContext);
     Runnable runnable = (Runnable) factory.getBean(Runnable.class.getName());
     new Thread( runnable).start();
    }
View Full Code Here

     * @throws org.springframework.beans.BeansException
     *          in case of loading or parsing errors
     * @see #JCABeanFactory(org.springframework.core.io.Resource)
     */
    public JCABeanFactory(InputStream is) throws BeansException {
        this(new InputStreamResource(is, "(no description)"), null);
    }
View Full Code Here

TOP

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

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.