List of usage examples for org.springframework.core.io ClassPathResource ClassPathResource
public ClassPathResource(String path)
From source file:com.app.util.DatabaseUtil.java
public static void initializeDatabase(String path) throws DatabaseConnectionException, SQLException { try {//from ww w .j a v a 2 s.co m ReleaseUtil.getReleaseVersion(_APPLICATION_RELEASE_NAME); } catch (SQLException sqle) { Resource resource = new ClassPathResource(path); ScriptUtils.executeSqlScript(getDatabaseConnection(), resource); ReleaseUtil.addRelease(_APPLICATION_RELEASE_NAME, _APPLICATION_VERSION); } }
From source file:ca.n4dev.dev.worktime.config.ApplicationConfig.java
@Bean public static PropertySourcesPlaceholderConfigurer properties() { PropertySourcesPlaceholderConfigurer propertySources = new PropertySourcesPlaceholderConfigurer(); Resource[] resources = new ClassPathResource[] { new ClassPathResource("worktime.properties") }; propertySources.setLocations(resources); propertySources.setIgnoreUnresolvablePlaceholders(true); return propertySources; }
From source file:co.paralleluniverse.galaxy.Server.java
/** * Starts the galaxy server.//from w w w .j av a 2s. c o m * @param configFile The path to the xml (spring) configuration file {@code null} null for default. * @param propertiesFile The name of the properties file containing the grid's properties. * You may, of course use Spring's {@code <context:property-placeholder location="classpath:com/foo/bar.properties"/>} but this parameter is helpful when you want to use the same xml configuration * with different properties for different instances. */ public static void start(String configFile, String propertiesFile) { final ApplicationContext context = SpringContainerHelper.createContext("co.paralleluniverse.galaxy", configFile != null ? new FileSystemResource(configFile) : new ClassPathResource("galaxy.xml"), propertiesFile != null ? new FileSystemResource(propertiesFile) : null, null); MainMemory memory = context.getBean("memory", MainMemory.class); ((AbstractCluster) memory.getCluster()).goOnline(); }
From source file:org.cagrid.gaards.websso.utils.FileHelper.java
public InputStream getFileAsStream(String fileName) throws AuthenticationConfigurationException { ClassPathResource cpr = new ClassPathResource(fileName); if (!cpr.exists()) { throw new AuthenticationConfigurationException("Unable to load " + fileName + " file"); }/*from ww w .j a v a 2s . c om*/ try { return cpr.getInputStream(); } catch (IOException ie) { throw new AuthenticationConfigurationException("Unable to load " + fileName + " file"); } }
From source file:com.thesoftwareguild.flightmaster.configuration.CacheConfig.java
@Bean public EhCacheManagerFactoryBean ehcache() { EhCacheManagerFactoryBean ehCacheManagerFactoryBean = new EhCacheManagerFactoryBean(); ehCacheManagerFactoryBean.setConfigLocation(new ClassPathResource("ehcache.xml")); return ehCacheManagerFactoryBean; }
From source file:edu.berkeley.compbio.ncbitaxonomy.service.NcbiTaxonomyServicesContextFactory.java
public static ApplicationContext makeNcbiTaxonomyServicesContext() throws IOException { File propsFile = PropertiesUtils.findPropertiesFile("NCBI_TAXONOMY_SERVICE_PROPERTIES", ".ncbitaxonomy", "service.properties"); logger.debug("Using properties file: " + propsFile); Properties p = new Properties(); FileInputStream is = null;//from w w w. j ava 2 s .com try { is = new FileInputStream(propsFile); p.load(is); } finally { is.close(); } String dbName = (String) p.get("default"); Map<String, Properties> databases = PropertiesUtils.splitPeriodDelimitedProperties(p); GenericApplicationContext ctx = new GenericApplicationContext(); XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader(ctx); xmlReader.loadBeanDefinitions(new ClassPathResource("ncbitaxonomyclient.xml")); PropertyPlaceholderConfigurer cfg = new PropertyPlaceholderConfigurer(); Properties properties = databases.get(dbName); if (properties == null) { logger.error("Service definition not found: " + dbName); logger.error("Valid names: " + StringUtils.join(databases.keySet().iterator(), ", ")); throw new NcbiTaxonomyRuntimeException("Database definition not found: " + dbName); } cfg.setProperties(properties); ctx.addBeanFactoryPostProcessor(cfg); ctx.refresh(); // add a shutdown hook for the above context... ctx.registerShutdownHook(); return ctx; }
From source file:org.openhims.oauth2.configuration.PropertiesConfiguration.java
public PropertySourcesPlaceholderConfigurer getProperties() { PropertySourcesPlaceholderConfigurer pspc = new PropertySourcesPlaceholderConfigurer(); Resource[] resources = new Resource[] { new ClassPathResource("properties/application.properties"), new ClassPathResource("properties/server.properties") }; pspc.setLocations(resources);/* w ww.j av a 2s . com*/ pspc.setIgnoreUnresolvablePlaceholders(IGNORE_UNRESOLVABLE_PLACEHOLDERS); pspc.setIgnoreResourceNotFound(true); return pspc; }
From source file:org.jasig.cas.authentication.principal.GoogleAccountsServiceTests.java
public static GoogleAccountsService getGoogleAccountsService() throws Exception { final PublicKeyFactoryBean pubKeyFactoryBean = new PublicKeyFactoryBean(); pubKeyFactoryBean.setAlgorithm("DSA"); final PrivateKeyFactoryBean privKeyFactoryBean = new PrivateKeyFactoryBean(); privKeyFactoryBean.setAlgorithm("DSA"); final ClassPathResource pubKeyResource = new ClassPathResource("DSAPublicKey01.key"); final ClassPathResource privKeyResource = new ClassPathResource("DSAPrivateKey01.key"); pubKeyFactoryBean.setLocation(pubKeyResource); privKeyFactoryBean.setLocation(privKeyResource); pubKeyFactoryBean.afterPropertiesSet(); privKeyFactoryBean.afterPropertiesSet(); final DSAPrivateKey privateKey = (DSAPrivateKey) privKeyFactoryBean.getObject(); final DSAPublicKey publicKey = (DSAPublicKey) pubKeyFactoryBean.getObject(); final MockHttpServletRequest request = new MockHttpServletRequest(); final String SAMLRequest = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><samlp:AuthnRequest xmlns:samlp=\"urn:oasis:names:tc:SAML:2.0:protocol\" ID=\"5545454455\" Version=\"2.0\" IssueInstant=\"Value\" ProtocolBinding=\"urn:oasis:names.tc:SAML:2.0:bindings:HTTP-Redirect\" ProviderName=\"https://localhost:8443/myRutgers\" AssertionConsumerServiceURL=\"https://localhost:8443/myRutgers\"/>"; request.setParameter("SAMLRequest", encodeMessage(SAMLRequest)); return GoogleAccountsService.createServiceFrom(request, privateKey, publicKey, "username"); }
From source file:org.beanio.spring.BeanIOStreamFactoryTest.java
@Test(expected = BeanIOConfigurationException.class) public void testMappingNotFound() throws Exception { Resource res = new ClassPathResource("/test/doesnotexist.xml"); BeanIOStreamFactory sf = new BeanIOStreamFactory(); sf.setStreamMappings(Arrays.asList(new Resource[] { res })); sf.createStreamFactory();/* w ww . j ava 2 s . c o m*/ }
From source file:com.consol.citrus.demo.javaland.EmployeeJmsResourceTest.java
@Deployment public static WebArchive createDeployment() throws IOException { return Deployments.employeeJmsRegistry() .addAsResource(new ClassPathResource("wsdl/SmsGateway.wsdl").getFile(), new BasicPath("/wsdl/SmsGateway.wsdl")) .addAsLibraries(CitrusArchiveBuilder.latestVersion().core().javaDsl().mail().ws().jms().build()); }