List of usage examples for org.springframework.core.io ClassPathResource ClassPathResource
public ClassPathResource(String path)
From source file:com.jbrisbin.vpc.jobsched.SpringResourceConnector.java
public URLConnection getResourceConnection(String name) throws ResourceException { Resource res = null;/*from w w w . j a v a 2s . c o m*/ if (name.startsWith("classpath:")) { res = new ClassPathResource(name.substring(10)); } else if (name.startsWith("http")) { try { res = new UrlResource(name); } catch (MalformedURLException e) { log.error(e.getMessage(), e); } } else { res = new FileSystemResource(name); } try { return res.getURI().toURL().openConnection(); } catch (IOException e) { log.error(e.getMessage(), e); throw new ResourceException(e); } }
From source file:com.jonschang.investing.Investing.java
private Investing() { beanFactory = new XmlBeanFactory(new ClassPathResource("conf/spring/spring.xml")); }
From source file:nu.yona.server.batch.quartz.QuartzConfig.java
@Bean public SchedulerFactoryBean schedulerFactoryBean(ApplicationContext applicationContext, DataSource dataSource, JobFactory jobFactory) {//from w w w .j ava2 s.c o m SchedulerFactoryBean schedulerFactory = new SchedulerFactoryBean(); schedulerFactory.setConfigLocation(new ClassPathResource("quartz.properties")); schedulerFactory.setAutoStartup(true); schedulerFactory.setDataSource(dataSource); schedulerFactory.setJobFactory(jobFactory); return schedulerFactory; }
From source file:nl.jteam.mahout.gettingstarted.datamodel.ResourceDataModelTest.java
@Test public void testConstructor() throws IOException { ClassPathResource resource = new ClassPathResource("ratings.dat"); FileDataModel fileDataModel = new FileDataModel(resource.getFile()); ResourceDataModel resourceDataModel = new ResourceDataModel(resource); assertEquals(fileDataModel.getDataFile(), resourceDataModel.delegate.getDataFile()); }
From source file:net.javacrumbs.springws.test.lookup.SimpleResourceLookupTest.java
@Test public void testTemplate() throws IOException { SimpleResourceLookup lookup = new SimpleResourceLookup(new ClassPathResource("xml/valid-message2.xml")); Resource res = lookup.lookupResource(null, null); assertNotNull(res);/*from www .j a v a 2 s . c om*/ assertEquals("valid-message2.xml", res.getFilename()); }
From source file:net.javacrumbs.springws.test.common.MessageGeneratorTest.java
@Test public void testNeverCreateEnvelope() throws IOException { MessageGenerator generator = new MessageGenerator(); generator.setNeverCreateEnvelope(true); assertFalse(generator.shouldCreateSoapEnvelope( new ClassPathResource("mock-responses/test/default-response-payload.xml"))); }
From source file:com.eventattend.portal.Factory.UserFactory.java
public static UserController userProfileInfo() throws Exception { ClassPathResource resource = new ClassPathResource("BusinessObjectFactory.xml"); BeanFactory factory = new XmlBeanFactory(resource); return (UserController) factory.getBean("User"); }
From source file:de.ingrid.interfaces.csw.tools.XsltUtilsTest.java
@Test public void testTransform() throws IOException, Exception { XsltUtils xsl = new XsltUtils(); Node result = xsl.transform(/* w w w . ja v a 2 s . c om*/ StringUtils.stringToDocument(FileUtils .convertStreamToString(new ClassPathResource("idf_1_0_test.xml").getInputStream())), "idf_1_0_0_to_iso_metadata.xsl"); System.out.println(StringUtils.nodeToString(result)); result = xsl.transform( StringUtils.stringToDocument(FileUtils.convertStreamToString( new ClassPathResource("0C12204F-5626-4A2E-94F4-514424F093A1.xml").getInputStream())), "idf_1_0_0_to_iso_metadata.xsl"); System.out.println(StringUtils.nodeToString(result)); result = xsl.transform( StringUtils.stringToDocument(FileUtils .convertStreamToString(new ClassPathResource("namespace_test_gmd.xml").getInputStream())), "idf_1_0_0_to_iso_metadata.xsl"); System.out.println(StringUtils.nodeToString(result)); result = xsl.transform( StringUtils.stringToDocument(FileUtils .convertStreamToString(new ClassPathResource("namespace_test_idf.xml").getInputStream())), "idf_1_0_0_to_iso_metadata.xsl"); System.out.println(StringUtils.nodeToString(result)); result = xsl.transform( StringUtils.stringToDocument(FileUtils.convertStreamToString( new ClassPathResource("namespace_test_idf_gmd.xml").getInputStream())), "idf_1_0_0_to_iso_metadata.xsl"); System.out.println(StringUtils.nodeToString(result)); }
From source file:se.trillian.goodies.spring.HostNameBasedPropertyPlaceHolderConfigurerTest.java
@SuppressWarnings("unchecked") public void testConfigurer() throws Exception { HostNameBasedPropertyPlaceHolderConfigurer configurer = new HostNameBasedPropertyPlaceHolderConfigurer() { @Override/* ww w .j a v a2 s. c o m*/ protected String getHostName() { return "foobar-10"; } }; configurer.setLocation(new ClassPathResource("/se/trillian/goodies/spring/spring.properties")); List<String> hostNameFilters = new ArrayList<String>(); hostNameFilters.add("nonmatchingfilter=>$1"); hostNameFilters.add("([a-z]+)-\\d+=>$1"); configurer.setHostNameFilters(hostNameFilters); configurer.setIgnoreUnresolvablePlaceholders(true); ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("context.xml", this.getClass()); context.addBeanFactoryPostProcessor(configurer); context.refresh(); Map<String, String> fruits = (Map<String, String>) context.getBean("fruits"); assertEquals("boquila", fruits.get("fruit1")); assertEquals("currant", fruits.get("fruit2")); assertEquals("blueberry", fruits.get("fruit3")); assertEquals("raspberry", fruits.get("fruit4")); assertEquals("peach", fruits.get("fruit5")); assertEquals("pear", fruits.get("fruit6")); Map<String, String> hostname = (Map<String, String>) context.getBean("hostname"); assertEquals("foobar-10", hostname.get("hostname1")); assertEquals("foobar-10", hostname.get("hostname2")); }
From source file:org.aksw.gerbil.web.config.RootConfig.java
static @Bean public PropertySourcesPlaceholderConfigurer myPropertySourcesPlaceholderConfigurer() { PropertySourcesPlaceholderConfigurer p = new PropertySourcesPlaceholderConfigurer(); Resource[] resourceLocations = new Resource[] { new ClassPathResource("gerbil.properties"), }; p.setLocations(resourceLocations);//from www . j av a 2 s . com return p; }