List of usage examples for org.springframework.core.io DefaultResourceLoader DefaultResourceLoader
public DefaultResourceLoader()
From source file:com.newline.core.service.SpringContextHolder.java
public static String getResourceRootRealPath() { String rootRealPath = ""; try {//from www . j a v a 2s.co m rootRealPath = new DefaultResourceLoader().getResource("").getFile().getAbsolutePath(); } catch (IOException e) { } return rootRealPath; }
From source file:com.xyxy.platform.modules.extension.tools.FreeMarkers.java
/** * ??.//from w w w . j a va 2s .c om */ public static Configuration buildConfiguration(String directory) throws IOException { Configuration cfg = new Configuration(); Resource path = new DefaultResourceLoader().getResource(directory); cfg.setDirectoryForTemplateLoading(path.getFile()); return cfg; }
From source file:cn.org.citycloud.srdz.utils.SpringContextHolder.java
public static String getResourceRootRealPath() { String rootRealPath = ""; try {/*from w ww . j av a 2 s .com*/ rootRealPath = new DefaultResourceLoader().getResource("").getFile().getAbsolutePath(); } catch (IOException e) { logger.warn("??"); } return rootRealPath; }
From source file:spring.travel.site.view.ConfiguredMustacheViewResolver.java
public ConfiguredMustacheViewResolver() { super();/* ww w. j a v a 2 s .c o m*/ setContentType("text/html"); MustacheJTemplateFactory mustacheJTemplateFactory = new MustacheJTemplateFactory(); mustacheJTemplateFactory.setResourceLoader(new DefaultResourceLoader()); setTemplateFactory(mustacheJTemplateFactory); setPrefix("/templates/"); setSuffix(".mustache"); setCache(false); }
From source file:com.ctrip.infosec.rule.executor.RulesExecutorServiceTest.java
@Test @Ignore/*w w w . j a v a 2 s .co m*/ public void testRules() throws IOException { String jsonData = IOUtils.toString(new DefaultResourceLoader().getResource("/1_1.txt").getInputStream()); RiskFact fact = JSON.parseObject(jsonData, RiskFact.class); rulesExecutorService.executeSerial(fact); jsonData = IOUtils.toString(new DefaultResourceLoader().getResource("/1.txt").getInputStream()); fact = JSON.parseObject(jsonData, RiskFact.class); rulesExecutorService.executeSyncRules(fact); System.out.println(JSON.toJSONString(fact)); }
From source file:org.eclipse.gemini.blueprint.test.parsing.CaseWithVisibleMethodsBaseTest.java
public String getRootPath() { ResourceLoader fileLoader = new DefaultResourceLoader(); try {/*from w w w . jav a2 s . co m*/ String classFile = CaseWithVisibleMethodsBaseTest.class.getName().replace('.', '/').concat(".class"); Resource res = fileLoader.getResource(classFile); String fileLocation = "file:/" + res.getFile().getAbsolutePath(); String classFileToPlatform = CaseWithVisibleMethodsBaseTest.class.getName() .replace('.', File.separatorChar).concat(".class"); return fileLocation.substring(0, fileLocation.indexOf(classFileToPlatform)); } catch (Exception ex) { } return null; }
From source file:net.chrissearle.flickrvote.service.TestBitlyShortUrlService.java
@Before public void setUp() throws IOException { ConstrettoConfiguration conf = new ConstrettoBuilder().createPropertiesStore() .addResource(new DefaultResourceLoader().getResource("classpath:flickrvote.properties")).done() .createPropertiesStore()/* w w w . j a v a 2 s.co m*/ .addResource(new DefaultResourceLoader().getResource("file:/etc/flickrvote/flickrvote.properties")) .done().getConfiguration(); service = new BitlyShortUrlService(); ((BitlyShortUrlService) service).configure(conf.evaluateToString("bitly.login"), conf.evaluateToString("bitly.key")); }
From source file:com.seovic.io.ClasspathResourceReader.java
/** * Construct reader for a classpath resource. * * @param resourceName resource name/*from www . jav a 2 s . c om*/ * * @throws IOException if an error occurs */ public ClasspathResourceReader(String resourceName) throws IOException { Resource resource = new DefaultResourceLoader().getResource(resourceName); m_reader = new InputStreamReader(resource.getInputStream()); }
From source file:org.constretto.examples.log4j.LogLevelTest.java
@Test public void whenInDevelopmentLogAlot() { ConstrettoConfiguration configuration = new ConstrettoBuilder().addCurrentTag("development") .createPropertiesStore().addResource(new DefaultResourceLoader().getResource("logger.properties")) .done().getConfiguration();/*from w w w . j av a 2 s . c o m*/ configuration.as(Log4JConfigurer.class); log.debug("This should be visible on system.out"); }
From source file:com.lnu.agile.controller.TrackController.java
@RequestMapping(value = RestURIConstants.GET_ALL_TRACK, method = RequestMethod.GET, headers = "Accept=application/json") public TrackInfoArray getAllTracks() { try {//from w w w. j ava 2s. com logger.info("Start getAllTracks"); Resource resource = new DefaultResourceLoader().getResource(PATH); FileParser parser = new XmlToJsonParser(); TrackInfoArray allTracks = parser.parseFile(resource.getFile().getAbsolutePath()); return allTracks; } catch (IOException ex) { java.util.logging.Logger.getLogger(TrackController.class.getName()).log(Level.SEVERE, null, ex); return null; } }