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

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

Introduction

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

Prototype

@Override
public URL getURL() throws IOException 

Source Link

Document

This implementation returns a URL for the underlying class path resource, if available.

Usage

From source file:org.jbb.lib.logging.LoggingBootstrapper.java

private void copyDefaultConfigurationToFile(File logbackConfigurationFile) {
    ClassPathResource classPathResource = new ClassPathResource(CLASSPATH_DEFAULT_LOG_CONF_FILE_NAME);
    try {//from   w  w w  . java  2s .c o  m
        FileUtils.copyURLToFile(classPathResource.getURL(), logbackConfigurationFile);
    } catch (IOException e) {
        throw new IllegalStateException("Unexpected error during reading default logging configuration file",
                e);
    }
}

From source file:org.jbb.lib.properties.FreshInstallPropertiesCreator.java

private static void getDefaultFromClasspath(File propertyFile) {
    ClassPathResource classPathResource = new ClassPathResource(propertyFile.getName());
    try {//from   www  .j av a 2s . co m
        FileUtils.copyURLToFile(classPathResource.getURL(), propertyFile);
    } catch (IOException e) {
        throw new IllegalStateException(e);
    }
}

From source file:org.jbb.lib.properties.FreshInstallPropertiesCreator.java

private static PropertiesConfiguration getReferenceProperties(File propertyFile) {
    try {/*from  w  w w. j  a v a 2  s .  c o m*/
        ClassPathResource classPathResource = new ClassPathResource(propertyFile.getName());
        FileBasedConfigurationBuilder<PropertiesConfiguration> builder = new FileBasedConfigurationBuilder<>(
                PropertiesConfiguration.class)
                        .configure(new Parameters().properties().setURL(classPathResource.getURL())
                                .setThrowExceptionOnMissing(true).setIncludesAllowed(false));
        return builder.getConfiguration();
    } catch (ConfigurationException | IOException e) {
        throw new IllegalStateException(e);
    }
}

From source file:org.jbb.lib.test.MockCommonsAutoInstallConfig.java

private void copyAutoInstallFile() {
    String fileName = "jbb-autoinstall.properties";
    ClassPathResource autoInstallFile = new ClassPathResource(fileName);
    File targetFile = new File(jbbHomePath + File.separator + fileName);
    try {/*from  ww w  . j a v a 2  s .  co m*/
        FileUtils.copyURLToFile(autoInstallFile.getURL(), targetFile);
    } catch (IOException e) {
        throw new IllegalStateException(e);
    }
}

From source file:piecework.config.WebSecurityConfiguration.java

@Bean
public Policy antisamyPolicy() throws Exception {
    ClassPathResource policyResource = new ClassPathResource("META-INF/piecework/antisamy-piecework-1.4.4.xml");
    URL policyUrl = policyResource.getURL();

    return Policy.getInstance(policyUrl);
}