List of usage examples for org.springframework.core.io ClassPathResource ClassPathResource
public ClassPathResource(String path)
From source file:com.wedian.site.modules.sys.service.TemplateService.java
@SuppressWarnings("unchecked") @Cacheable("template") public List<Template> getAll() { try {//from w w w. j a v a 2s . c o m File siteXmlFile = new ClassPathResource(CommonAttributes.SITE_XML_PATH).getFile(); Document document = new SAXReader().read(siteXmlFile); List<Template> templates = new ArrayList<Template>(); List<Element> elements = document.selectNodes("/site/template"); for (Element element : elements) { Template template = getTemplate(element); templates.add(template); } return templates; } catch (Exception e) { e.printStackTrace(); return null; } }
From source file:net.osxx.service.impl.TemplateServiceImpl.java
@SuppressWarnings("unchecked") @Cacheable("template") public List<Template> getAll() { try {/*from w w w . j a v a 2s . co m*/ File osxxXmlFile = new ClassPathResource(CommonAttributes.SHOPXX_XML_PATH).getFile(); Document document = new SAXReader().read(osxxXmlFile); List<Template> templates = new ArrayList<Template>(); List<Element> elements = document.selectNodes("/osxx/template"); for (Element element : elements) { Template template = getTemplate(element); templates.add(template); } return templates; } catch (Exception e) { e.printStackTrace(); return null; } }
From source file:doge.photo.DogePhotoManipulatorTest.java
@Test public void testDogePhotoManipulatorService() throws Exception { Photo photo = () -> new ClassPathResource("thehoff.jpg").getInputStream(); Photo manipulated = this.manipulator.manipulate(photo); FileCopyUtils.copy(manipulated.getInputStream(), new FileOutputStream(this.file)); }
From source file:au.id.hazelwood.xmltvguidebuilder.config.ConfigFactoryUnitTest.java
@Test public void testCreate() throws Exception { final ClassPathResource resource = new ClassPathResource( "/au/id/hazelwood/xmltvguidebuilder/config/valid-config.xml"); Config config = configFactory.create(resource.getFile()); assertEquals(1, config.getOffset()); assertEquals(13, config.getDays());//from www .j av a2 s . c om assertEquals(2, config.getChannelConfigs().size()); }
From source file:org.modeshape.example.springsecurity.AppConfig.java
@Bean ModeShapeRepositoryFactory repositoryFactory() { ModeShapeRepositoryFactory factory = new ModeShapeRepositoryFactory(); factory.setConfiguration(new ClassPathResource("repository-config.json")); return factory; }
From source file:com.octo.captcha.engine.bufferedengine.SimpleBufferedEngineContainerTest.java
/** * @see com.octo.captcha.engine.bufferedengine.BufferedEngineContainerTestAbstract#getEngine() *///from ww w .j a v a2 s .c om public BufferedEngineContainer getEngine() { Resource ressource = new ClassPathResource("testSimpleBufferedEngine.xml"); ConfigurableBeanFactory bf = new XmlBeanFactory(ressource); BufferedEngineContainer container = (BufferedEngineContainer) bf.getBean("container"); return container; }
From source file:net.groupbuy.service.impl.TemplateServiceImpl.java
@SuppressWarnings("unchecked") @Cacheable("template") public List<Template> getAll() { try {/*from w w w .j a va 2s.c om*/ File shopxxXmlFile = new ClassPathResource(CommonAttributes.SHOPXX_XML_PATH).getFile(); Document document = new SAXReader().read(shopxxXmlFile); List<Template> templates = new ArrayList<Template>(); List<Element> elements = document.selectNodes("/shopxx/template"); for (Element element : elements) { Template template = getTemplate(element); templates.add(template); } return templates; } catch (Exception e) { e.printStackTrace(); return null; } }
From source file:com.dp2345.service.impl.TemplateServiceImpl.java
@SuppressWarnings("unchecked") @Cacheable("template") public List<Template> getAll() { try {/* ww w . java 2 s . c om*/ File dp2345XmlFile = new ClassPathResource(CommonAttributes.DP2345_XML_PATH).getFile(); Document document = new SAXReader().read(dp2345XmlFile); List<Template> templates = new ArrayList<Template>(); List<Element> elements = document.selectNodes("/dp2345/template"); for (Element element : elements) { Template template = getTemplate(element); templates.add(template); } return templates; } catch (Exception e) { e.printStackTrace(); return null; } }
From source file:br.com.d4j.apostei.api.tests.MongoTestConfiguration.java
@Bean public Jackson2RepositoryPopulatorFactoryBean repositoryPopulator() { Jackson2RepositoryPopulatorFactoryBean factoryBean = new Jackson2RepositoryPopulatorFactoryBean(); factoryBean.setResources(new Resource[] { new ClassPathResource("drivers.json") }); return factoryBean; }
From source file:io.spring.initializr.metadata.InitializrMetadataBuilderTests.java
@Test public void loadDefaultConfig() { InitializrProperties bean = load(new ClassPathResource("application-test-default.yml")); InitializrMetadata metadata = InitializrMetadataBuilder.fromInitializrProperties(bean).build(); assertDefaultConfig(metadata);// w ww . jav a2 s .c o m }