Examples of ClassPathResource


Examples of org.springframework.core.io.ClassPathResource

  public void test() throws Exception {
    parser("context.xml");
  }

  private void parser(String path) throws Exception {
    List<ReconfigBeanDefinitionHolder> holders = new BeanDefinitionReader().load(new ClassPathResource(
        path));
    for (ReconfigBeanDefinitionHolder holder : holders) {
      System.out.println(holder);
    }
  }
View Full Code Here

Examples of org.springframework.core.io.ClassPathResource

@Test
public class DefinitionBindRegistryTest {

  public void testGet() {
    XmlBeanFactory factory = new XmlBeanFactory(new ClassPathResource("/context-registry.xml"));
    BindRegistry registry = new DefinitionBindRegistry(factory);
    List<String> names = registry.getBeanNames(TestDao.class);
    Assert.assertNotNull(names);
    Assert.assertTrue(names.size() == 1);
View Full Code Here

Examples of org.springframework.core.io.ClassPathResource

  public Resource getExpected(String resourceName, boolean rewrite) {
    if (rewrite) {
      return new FileSystemResource("src/test/resources/" + classPath + "/" + resourceName);
    } else {
      return new ClassPathResource(classPath + "/" + resourceName);
    }
  }
View Full Code Here

Examples of org.springframework.core.io.ClassPathResource

  private String beansFile = "smokeTest.xml";
  private ServletServiceAdapterComponent builtComponent;
  private BeanFactory factory;
 
  protected ServletServiceAdapterComponent buildRootComponent() {
    ClassPathResource resource = new ClassPathResource(beansFile);
    factory = new XmlBeanFactory(resource)
    ServletServiceAdapterComponent adapter =
      (ServletServiceAdapterComponent)factory.getBean("servletServiceAdapterComponent");
    builtComponent = adapter;
    return adapter;
View Full Code Here

Examples of org.springframework.core.io.ClassPathResource

    /**
     * Create a CompanyModelReader for the specified resourceName.
     * @param resourceName the name of the resource
     */
    public CompanyModelReader(String resourceName, ClassLoader classLoader) {
        super(new ClassPathResource(resourceName, classLoader));
        configureFactory();
    }
View Full Code Here

Examples of org.springframework.core.io.ClassPathResource

    static GenericApplicationContext getContext() {
        log.info("Creating Spring Application Context ...");
        GenericApplicationContext ctx = new GenericApplicationContext();
        XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(ctx);
        reader.loadBeanDefinitions(new ClassPathResource("/applicationContext.xml"));

        ctx.refresh();
        return ctx;
    }
View Full Code Here

Examples of org.springframework.core.io.ClassPathResource

   
    public static Resource findResource(final String cfgFile) {
        try {
            return AccessController.doPrivileged(new PrivilegedAction<Resource>() {
                public Resource run() {
                    Resource cpr = new ClassPathResource(cfgFile);
                    if (cpr.exists()) {
                        return cpr;
                    }
                    try {
                        //see if it's a URL
                        URL url = new URL(cfgFile);
                        cpr = new UrlResource(url);
                        if (cpr.exists()) {
                            return cpr;
                        }
                    } catch (MalformedURLException e) {
                        //ignore
                    }
                    //try loading it our way
                    URL url = ClassLoaderUtils.getResource(cfgFile, BusApplicationContext.class);
                    if (url != null) {
                        cpr = new UrlResource(url);
                        if (cpr.exists()) {
                            return cpr;
                        }
                    }
                    cpr = new FileSystemResource(cfgFile);
                    if (cpr.exists()) {
                        return cpr;
                    }
                    return null;
                }
            });
View Full Code Here

Examples of org.springframework.core.io.ClassPathResource

        if (encryptionKey.startsWith(EMBEDDED_KEY_PREFIX)) {
            this.blobCrypter = new BasicBlobCrypter(encryptionKey.substring(EMBEDDED_KEY_PREFIX.length()));
        } else if (encryptionKey.startsWith(CLASSPATH_KEY_PREFIX)) {
            try {
                File file = new ClassPathResource(encryptionKey.substring(CLASSPATH_KEY_PREFIX.length())).getFile();
                this.blobCrypter = new BasicBlobCrypter(FileUtils.readFileToString(file, "UTF-8"));
            } catch (IOException e) {
                throw new SecurityException("Unable to load encryption key from classpath resource: " + encryptionKey);
            }
        } else {
View Full Code Here

Examples of org.springframework.core.io.ClassPathResource

                //And again with a classpath reference to an external key file
                {EncryptedBlobSecurityTokenService.CLASSPATH_KEY_PREFIX + "security_token_encryption_key.txt"},

                //And again with a direct filesystem reference to an external key file
                {new ClassPathResource("security_token_encryption_key.txt").getFile().getAbsolutePath()}
        });
    }
View Full Code Here

Examples of org.springframework.core.io.ClassPathResource

        executor.setCategoryRepository(categoryRepository);
        executor.setPageTemplateRepository(pageTemplateRepository);
        executor.setActivityStreamsRepository(activityStreamsRepository);

        importer = new DataImporter();
        importer.setScriptLocations(Arrays.asList((Resource) new ClassPathResource("test-data.json")));
        importer.setDataExecutor(executor);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.