Package org.springframework.core.io

Examples of org.springframework.core.io.ResourceLoader


      log.info("factory bean is {" + factoryBean + "}");

      mimeBean = this.config.getInitParameter(MIME_FACTORY_BEAN_ID);
      log.info("mime bean is {" + mimeBean + "}");

      ResourceLoader loader = new DefaultResourceLoader();
      Resource xmlResource = loader.getResource(factoryXml);
      BeanFactory factory = new XmlBeanFactory(xmlResource);
      this.datasource = (ISystemRoot) factory.getBean(factoryBean);
      this.mimeFactory = (IMimeFactory) factory.getBean(mimeBean);
    } catch (Exception e) {
      this.initializeException = new ServletException(e.getMessage(), e);
View Full Code Here


    return new GenericApplicationContext(beanFactory).getBeanFactory();
  }

  public static ConfigurableListableBeanFactory loadBeanFactory(String string) throws Exception {
    ResourceLoader r = new DefaultResourceLoader();

    return loadBeanFactory(r.getResource(string));
  }
View Full Code Here

        Map<String, Object> variables = new HashMap<>();
        // Add overall variables
        for (String key : inputs.keySet()) {
            variables.put(key, inputs.get(key));
        }
        ResourceLoader loader = new DefaultResourceLoader();

        for (Script script : scripts) {
            NamespacedBinding binding = create();
            // Bind inputs.
            for (String key : variables.keySet()) {
                binding.setVariable(key, variables.get(key));
            }
            binding.startCapture();

            String filename = Strings.isNullOrEmpty(scriptDirectory) ? script.getName() : scriptDirectory
                    + File.separator + script.getName();
            try (InputStream stream = loader.getResource(filename).getInputStream()) {
                List<String> lines = IOUtils.readLines(stream);
                String content = String.join("\n", lines);

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

   *
   * @see #createDataSet(Resource)
   * @see com.github.springtestdbunit.dataset.DataSetLoader#loadDataSet(Class, String) java.lang.String)
   */
  public IDataSet loadDataSet(Class<?> testClass, String location) throws Exception {
    ResourceLoader resourceLoader = getResourceLoader(testClass);
    String[] resourceLocations = getResourceLocations(testClass, location);
    for (String resourceLocation : resourceLocations) {
      Resource resource = resourceLoader.getResource(resourceLocation);
      if (resource.exists()) {
        return createDataSet(resource);
      }
    }
    return null;
View Full Code Here

   * @see #setShowBanner(boolean)
   * @see #printBanner()
   */
  protected void printBanner(Environment environment) {
    String location = environment.getProperty("banner.location", "banner.txt");
    ResourceLoader resourceLoader = this.resourceLoader != null ? this.resourceLoader
        : new DefaultResourceLoader(getClassLoader());
    Resource resource = resourceLoader.getResource(location);
    if (resource.exists()) {
      new ResourceBanner(resource).printBanner(environment,
          this.mainApplicationClass, System.out);
      return;
    }
View Full Code Here

  private boolean isGroovyPresent() {
    return ClassUtils.isPresent("groovy.lang.MetaClass", null);
  }

  private Resource[] findResources(String source) {
    ResourceLoader loader = this.resourceLoader != null ? this.resourceLoader
        : DEFAULT_RESOURCE_LOADER;
    try {
      if (loader instanceof ResourcePatternResolver) {
        return ((ResourcePatternResolver) loader).getResources(source);
      }
      return new Resource[] { loader.getResource(source) };
    }
    catch (IOException ex) {
      throw new IllegalStateException("Error reading source '" + source + "'");
    }
  }
View Full Code Here

  @Test
  public void customResourceLoader() throws Exception {
    TestSpringApplication application = new TestSpringApplication(ExampleConfig.class);
    application.setWebEnvironment(false);
    ResourceLoader resourceLoader = new DefaultResourceLoader();
    application.setResourceLoader(resourceLoader);
    this.context = application.run();
    verify(application.getLoader()).setResourceLoader(resourceLoader);
  }
View Full Code Here

    verify(application.getLoader()).setResourceLoader(resourceLoader);
  }

  @Test
  public void customResourceLoaderFromConstructor() throws Exception {
    ResourceLoader resourceLoader = new DefaultResourceLoader();
    TestSpringApplication application = new TestSpringApplication(resourceLoader,
        ExampleWebConfig.class);
    this.context = application.run();
    verify(application.getLoader()).setResourceLoader(resourceLoader);
  }
View Full Code Here

    System.clearProperty("spring.main.showBanner");
  }

  @Test
  public void loadCustomResource() throws Exception {
    this.event.getSpringApplication().setResourceLoader(new ResourceLoader() {
      @Override
      public Resource getResource(final String location) {
        if (location.equals("classpath:/custom.properties")) {
          return new ByteArrayResource("the.property: fromcustom".getBytes(),
              location) {
View Full Code Here

            log.warn(
                    "XSD validation has been disabled according to the system property: -D{}.  Please be warned: NEVER skipping validation in Production Environment.",
                    PROPERTY_SKIP_VALIDATION);
        }

        ResourceLoader resourceLoader = reader.getResourceLoader();

        if (resourceLoader == null) {
            resourceLoader = new DefaultResourceLoader();
        }

        ClassLoader classLoader = resourceLoader.getClassLoader();

        // schema providers
        ConfigurationPointsImpl cps = new ConfigurationPointsImpl(classLoader);
        SpringPluggableSchemas sps = new SpringPluggableSchemas(resourceLoader);
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.