Example usage for org.springframework.core.io ClassPathResource ClassPathResource

List of usage examples for org.springframework.core.io ClassPathResource ClassPathResource

Introduction

In this page you can find the example usage for org.springframework.core.io ClassPathResource ClassPathResource.

Prototype

public ClassPathResource(String path) 

Source Link

Document

Create a new ClassPathResource for ClassLoader usage.

Usage

From source file:no.difi.sdp.client.SikkerDigitalPostKlientIntegrationTest.java

private Noekkelpar avsenderNoekkelpar() {
    try {/*from   w  w w .j a  v a2s .  c  o  m*/
        String alias = "meldingsformidler";
        String passphrase = "abcd1234";
        String keyStoreFile = "/keystore.jce";

        KeyStore keyStore = KeyStore.getInstance("JCEKS");
        keyStore.load(new ClassPathResource(keyStoreFile).getInputStream(), passphrase.toCharArray());
        return Noekkelpar.fraKeyStore(keyStore, alias, passphrase);
    } catch (Exception e) {
        throw new RuntimeException("Kunne ikke laste nkkelpar for kjring av tester. "
                + "For  kjre integrasjonstester m det ligge inne et gyldig virksomhetssertifikat for test (med tilhrende certificate chain). "
                + "Keystore med tilhrende alias og passphrase settes i " + this.getClass().getSimpleName()
                + ".", e);
    }
}

From source file:org.nabucco.alfresco.enhScriptEnv.repo.script.registry.RepositoryVersionRegisterableScriptClasspathScanner.java

/**
 *
 * {@inheritDoc}//from w w  w .j  a va 2  s  . com
 */
@Override
protected RegisterableScript<ScriptLocation> getScript(final String resourcePath) {
    final RegisterableScript<ScriptLocation> result;
    if (resourcePath.matches("^(classpath(\\*)?:)+.*$")) {
        final ClasspathRegisterableScript script = new ClasspathRegisterableScript();
        final String simplePath = resourcePath.replaceAll("classpath(\\*)?:", "");
        final ClassPathResource classpathResource = new ClassPathResource(simplePath);
        script.setScriptResource(classpathResource);
        result = script;
    } else {
        LOGGER.warn("Can't create script from {} - needs to be a classpath resource", resourcePath);
        result = null;
    }
    return result;
}

From source file:org.dawnsci.marketplace.config.DatabaseConfiguration.java

private DatabasePopulator createDatabasePopulator() {
    ResourceDatabasePopulator databasePopulator = new ResourceDatabasePopulator();
    databasePopulator.setContinueOnError(true);
    // populate the database with required tables
    databasePopulator.addScript(new ClassPathResource("schema.sql"));
    return databasePopulator;
}

From source file:io.spring.initializr.metadata.InitializrMetadataBuilderTests.java

@Test
public void mergeIdenticalConfig() {
    InitializrProperties bean = load(new ClassPathResource("application-test-default.yml"));
    InitializrMetadata metadata = InitializrMetadataBuilder.fromInitializrProperties(bean)
            .withInitializrProperties(bean, true).build();
    assertDefaultConfig(metadata);//from   w  ww.  j a  v a  2 s  .  c om
}

From source file:de.thm.arsnova.config.ExtraConfig.java

@Bean
public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
    final PropertySourcesPlaceholderConfigurer configurer = new PropertySourcesPlaceholderConfigurer();
    configurer.setLocations(new Resource[] { new ClassPathResource("arsnova.properties.example"),
            new FileSystemResource("/etc/arsnova/arsnova.properties"), });
    configurer.setIgnoreResourceNotFound(true);
    configurer.setIgnoreUnresolvablePlaceholders(false);
    return configurer;
}

From source file:ch.algotrader.hibernate.InMemoryDBTest.java

@Before
public void setup() throws Exception {

    ResourceDatabasePopulator dbPopulator = new ResourceDatabasePopulator();
    dbPopulator.addScript(new ClassPathResource("/db/h2/h2.sql"));
    DatabasePopulatorUtils.execute(dbPopulator, EmbeddedTestDB.DATABASE.getDataSource());

    this.sessionFactory = EmbeddedTestDB.DATABASE.getSessionFactory();

    this.session = this.sessionFactory.openSession();

    TransactionSynchronizationManager.bindResource(this.sessionFactory, new SessionHolder(this.session));
}

From source file:com.rakesh.rp3599.config.EhCacheConfiguration.java

@Bean
public EhCacheManagerFactoryBean ehCacheManagerFactoryBean() {

    EhCacheManagerFactoryBean cacheManagerFactoryBean = new EhCacheManagerFactoryBean();
    cacheManagerFactoryBean.setConfigLocation(new ClassPathResource("ehcache.xml"));
    cacheManagerFactoryBean.setShared(true);

    return cacheManagerFactoryBean;
}

From source file:org.pdfsam.configuration.PdfsamConfig.java

@Bean
public ImageView payoff() throws IOException {
    return new ImageView(new ClassPathResource("/images/payoff.png").getURL().toExternalForm());
}

From source file:wsconfig.PaysRepository.java

/**
 * Renvoye un pays trouv dans la base de donne
 * @param id L'ID du pays que l'on veut trouver
 * @return Le pays correspondant/*from   ww  w  .  j  a  va2  s. co  m*/
 */
public Pays findPays(int id) {

    ListableBeanFactory bf;
    bf = new XmlBeanFactory(new ClassPathResource("applicationContext.xml"));
    IPaysMetier instance = (IPaysMetier) bf.getBean("paysMetier");

    Pays result = new Pays();
    try {
        result = instance.findPays(id);
        System.out.println("libelle get : " + result.getLibelleFr() + " ID: " + result.getID());
    } catch (PaysNotFoundException e) {
        e.printStackTrace();
    }
    return result;
}