Package org.springframework.core.io

Examples of org.springframework.core.io.DefaultResourceLoader$ClassPathContextResource


    protected Resource createResource(Element resourceDefinition) {
        String path = resourceDefinition.getAttribute(LOCATION_ATTR);
        if (!StringUtils.hasText(path)) {
            throw new ValidationConfigurationException("Resoruce path is required and cannot be empty");
        }
        return new DefaultResourceLoader().getResource(path);
    }
View Full Code Here


    public void setupBeans() throws Exception {
        if (applicationContext != null) {
            return;
        }
        applicationContext = new GenericApplicationContext();
        resourceLoader = new DefaultResourceLoader(configContextClass.getClassLoader());
        for (String beanDefinitionPath : getConfigLocations()) {
            XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(applicationContext);
            Resource resource = resourceLoader.getResource(beanDefinitionPath);
            reader.loadBeanDefinitions(resource);
        }
View Full Code Here

        this.fromExchange = fromExchange;
    }

    public void createResource(String resource) {
        if (resource != null) {
            DefaultResourceLoader resourceLoader = new DefaultResourceLoader();
            Resource tempPropertyResource = resourceLoader.getResource(resource);
            if (tempPropertyResource != null && tempPropertyResource.exists()) {
                propertyResource = tempPropertyResource;
                dirty = true;
            }
        }
View Full Code Here

            return new UrlResource((URL) res);
        }
        if (res instanceof URI) {
            return new UrlResource(((URI) res).toURL());
        }
        return new DefaultResourceLoader().getResource(res.toString());
    }
View Full Code Here

     * @return the {@link org.springframework.test.web.servlet.request.RequestPostProcessor} to use.
     * @throws IOException
     * @throws CertificateException
     */
    public static RequestPostProcessor x509(String resourceName) throws IOException, CertificateException {
        ResourceLoader loader = new DefaultResourceLoader();
        Resource resource = loader.getResource(resourceName);
        InputStream inputStream = resource.getInputStream();
        CertificateFactory certFactory = CertificateFactory.getInstance("X.509");
        X509Certificate certificate = (X509Certificate) certFactory.generateCertificate(inputStream);
        return x509(certificate);
    }
View Full Code Here

    public void init() {
        try {
            Connection conn = dataSource.getConnection();
            Statement st = conn.createStatement();
            st.execute("drop all objects;");
            st.execute("runscript from '" + new DefaultResourceLoader().getResource("schema.sql").getURL().toString() + "'");
            st.close();
            conn.close();
        } catch (SQLException e) {
            e.printStackTrace();
        } catch (IOException e) {
View Full Code Here

*/
public class ClassUtilsTest {

  @Test
  public void testParentLastClassLoading() throws Exception {
    Resource jar = new DefaultResourceLoader().getResource("class-v1.jar");
    SomeClass v2 = new SomeClass();
    assertEquals("Class-v2", System.getProperty(SomeClass.LAST_LOADED));
    assertNotNull(System.getProperty(SomeClass.CLASS_LOADED + ".2"));

    // use v2 CL as a parent
View Full Code Here

    assertFalse(v2.getClass().equals(obj.getClass()));
  }

  // disabled test
  public void testNestedClass() throws Exception {
    Resource jar = new DefaultResourceLoader().getResource("jar-with-classes.jar");

    Object obj = loadFromJar(jar, getClass().getClassLoader(), "test.SomeNestedClass");

    // check the jar classes are preferred
    assertEquals("NestedClass", System.getProperty(SomeClass.LAST_LOADED));
View Full Code Here

    assertFalse(org.springframework.util.ClassUtils.isPresent(obj.getClass().getName(), getClass().getClassLoader()));
  }

  @Test
  public void testNestedLib() throws Exception {
    Resource jar = new DefaultResourceLoader().getResource("jar-with-libs.jar");

    Object obj = loadFromJar(jar, getClass().getClassLoader(), "test.SomeLibClass");

    // check the jar classes are preferred
    assertEquals("LibClass", System.getProperty(SomeClass.LAST_LOADED));
View Full Code Here

    assertFalse(org.springframework.util.ClassUtils.isPresent(obj.getClass().getName(), getClass().getClassLoader()));
  }

  @Test
  public void testMainClassDiscovery() throws Exception {
    Resource jar = new DefaultResourceLoader().getResource("some-tool.jar");
    String mainClass = ExecutionUtils.mainClass(jar);
    assertEquals("test.SomeTool", mainClass);
  }
View Full Code Here

TOP

Related Classes of org.springframework.core.io.DefaultResourceLoader$ClassPathContextResource

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.