List of usage examples for org.springframework.core.io ClassPathResource ClassPathResource
public ClassPathResource(String path)
From source file:playground.ResourceController.java
@GetMapping(path = "/file") Resource resource(@RequestParam(value = "name", required = false) String name) { return new ClassPathResource("static/" + name); }
From source file:br.eb.ime.labprog3.tam.MenorCaminhoController.java
@RequestMapping(value = "menorcaminho") public String menorCaminho(ModelMap map, HttpServletRequest request) { String fileNameTrechos = "../../resources/xml/rotas.xml"; String fileNameAeroportos = "../../resources/xml/aeroportos.xml"; Resource resource = null;// www . j a va2s . c o m TrechoDAO daoTrecho = null; AeroportoDAO daoAeroporto = null; resource = new ClassPathResource(fileNameTrechos); try { daoTrecho = new TrechoDAO(resource.getFile()); } catch (IOException ex) { Logger.getLogger(MenorCaminhoController.class.getName()).log(Level.SEVERE, null, ex); } resource = new ClassPathResource(fileNameAeroportos); try { daoAeroporto = new AeroportoDAO(resource.getFile()); } catch (IOException ex) { Logger.getLogger(MenorCaminhoController.class.getName()).log(Level.SEVERE, null, ex); } List<Aeroporto> listaDeAeroportos = daoAeroporto.listarAeroportos(); List<Trecho> listaDeTrechos = daoTrecho.listarTrechos(); GeradorGrafoDijkstra geradorDeGrafo = new GeradorGrafoDijkstra(daoAeroporto.listarAeroportos(), daoTrecho.listarTrechos()); int origem = -1; int destino = -1; try { origem = Integer.parseInt(request.getParameter("origem")); destino = Integer.parseInt(request.getParameter("destino")); } catch (Exception e) { return "erro"; } if (origem < 0 || destino < 0) return "erro"; List<Aeroporto> listaDeAeroportosDestino = geradorDeGrafo.geraMenorCaminho(origem, destino); List<Trecho> listaDeTrechosDestino = new ArrayList<>(); map.addAttribute("aeroportoOrigem", listaDeAeroportos.get(origem - 1)); map.addAttribute("aeroportoDestino", listaDeAeroportos.get(destino - 1)); if (listaDeAeroportosDestino.size() == 1) { map.addAttribute("visibility", 0); if (listaDeAeroportos.get(origem - 1).getId() == listaDeAeroportos.get(destino - 1).getId()) map.addAttribute("visibility", 1); } else { for (int i = 0; i < listaDeAeroportosDestino.size() - 1; i++) { Aeroporto aeroportoOrigem = listaDeAeroportosDestino.get(i); for (int j = 0; j < listaDeTrechos.size(); j++) { Trecho trecho = listaDeTrechos.get(j); if (trecho.getIdAeroportoOrigem() == aeroportoOrigem.getId()) { Aeroporto aeroportoDestino = listaDeAeroportosDestino.get(i + 1); trecho.setAeroportoOrigemNome(aeroportoOrigem.getNome()); if (trecho.getIdAeroportoDestino() == aeroportoDestino.getId()) { trecho.setAeroportoDestinoNome(aeroportoDestino.getNome()); listaDeTrechosDestino.add(trecho); } } } } map.addAttribute("visibility", 2); } map.addAttribute("listaDeAeroportos", listaDeAeroportos); map.addAttribute("listaDeTrechos", listaDeTrechosDestino); return "menorcaminho"; }
From source file:com.intelligentsia.dowsers.entity.manager.ContactConfigurationLightTest.java
@Override public Resource getResource() { return new ClassPathResource("dowsers-context-sample2.xml"); }
From source file:com.gong.illidan.config.cache.CacheConfiguration.java
@Bean public EhCacheManagerFactoryBean ehCacheManagerFactoryBean() { EhCacheManagerFactoryBean cacheManagerFactoryBean = new EhCacheManagerFactoryBean(); cacheManagerFactoryBean.setConfigLocation(new ClassPathResource("conf/ehcache.xml")); cacheManagerFactoryBean.setShared(true); return cacheManagerFactoryBean; }
From source file:uk.ac.ebi.ricordo.rdfconverter.util.MappingExtractor.java
private void populateIdentMap(String mappingFile) { try {/*from w w w . j av a 2 s .c o m*/ Resource resource = new ClassPathResource(mappingFile); BufferedReader reader = new BufferedReader(new InputStreamReader(resource.getInputStream())); String line = null; while ((line = reader.readLine()) != null) { int splitPoint = line.lastIndexOf(" "); //String [] stringMap = line.split("|"); identMap.put(line.substring(0, splitPoint), line.substring(splitPoint + 1)); } } catch (IOException e) { e.printStackTrace(); } }
From source file:CategorieTest.java
@Test public void testJDBCTemplate() { ListableBeanFactory bf;//w w w . j av a 2s . co m bf = new XmlBeanFactory(new ClassPathResource("applicationContext.xml")); ICategorieDao m = (ICategorieDao) bf.getBean("categorieDao"); System.out.print("Je suis ici"); List<Categorie> u = m.findAllC(); System.out.print("Je suis ici"); for (Categorie p : u) { System.out.println("nom=" + p.getCat_id()); } }
From source file:org.bambooframework.dao.impl.cfg.BeansConfigurationHelper.java
public static DaoEngineConfiguration parseDaoEngineConfigurationFromResource(String resource, String beanName) { Resource springResource = new ClassPathResource(resource); return parseDaoEngineConfiguration(springResource, beanName); }
From source file:com.tacitknowledge.flip.spring.config.InterceptHandlerParserTest.java
@Before public void setUp() { context = new XmlBeanFactory(new ClassPathResource("test-intercept-handlers-context.xml")); }
From source file:org.obiba.onyx.magma.DefaultCustomVariablesRegistryTest.java
@Before public void setUp() { sut = new DefaultCustomVariablesRegistry(); sut.setResource(new ClassPathResource("DefaultCustomVariablesRegistryTest/custom-variables.xml")); sut.initSourceMap();/*from w w w . j av a2 s . co m*/ }
From source file:com.commercehub.dropwizard.mongeez.CloseableMongeez.java
public CloseableMongeez(ManagedMongoClient mongoClient, String dbName, String file) { this.mongoClient = mongoClient; setMongo(mongoClient);/* w w w . j av a2s. co m*/ setDbName(dbName); setFile(new ClassPathResource(file)); }