List of usage examples for org.springframework.context ApplicationContext getResource
Resource getResource(String location);
From source file:de.alpharogroup.duplicate.files.spring.SpringApplicationContext.java
/** * Instantiates a new spring application context. *//*from www .j a v a 2 s. c o m*/ private SpringApplicationContext() { String rootContextDirectoryClassPath = "/ctx"; String applicationContextPath = rootContextDirectoryClassPath + "/application-context.xml"; ApplicationContext ac = new ClassPathXmlApplicationContext(applicationContextPath); Resource resource = ac.getResource("classpath:conf/log4j/log4jconfig.xml"); try { DOMConfigurator.configure(resource.getURL()); } catch (FactoryConfigurationError e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } applicationContext = ac; }
From source file:de.alpharogroup.duplicate.files.actions.ShowLicenseFrameAction.java
/** * Load license./* ww w.java 2 s . co m*/ * * @return the string */ private String loadLicense() { ApplicationContext ctx = SpringApplicationContext.getInstance().getApplicationContext(); Resource resource = ctx.getResource("classpath:LICENSE.txt"); InputStream is = null; StringBuffer license = new StringBuffer(); try { String thisLine; is = resource.getInputStream(); BufferedReader br = new BufferedReader(new InputStreamReader(is)); while ((thisLine = br.readLine()) != null) { license.append(thisLine + "\n"); } } catch (IOException ex) { ex.printStackTrace(); } finally { try { StreamExtensions.close(is); } catch (IOException e) { e.printStackTrace(); } } return license.toString(); }
From source file:de.alpharogroup.mystic.crypt.spring.SpringApplicationContext.java
/** * Instantiates a new spring application context. *//* ww w.ja v a2 s .c om*/ private SpringApplicationContext() { final String rootContextDirectoryClassPath = "/ctx"; final String applicationContextPath = rootContextDirectoryClassPath + "/application-context.xml"; final ApplicationContext ac = new ClassPathXmlApplicationContext(applicationContextPath); final Resource resource = ac.getResource("classpath:conf/log4j/log4jconfig.xml"); try { DOMConfigurator.configure(resource.getURL()); } catch (final FactoryConfigurationError e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (final IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } applicationContext = ac; }
From source file:de.alpharogroup.mystic.crypt.actions.ShowLicenseFrameAction.java
/** * Load license.//from w w w.ja v a2 s . com * * @return the string */ private String loadLicense() { final ApplicationContext ctx = SpringApplicationContext.getInstance().getApplicationContext(); final Resource resource = ctx.getResource("classpath:LICENSE.txt"); InputStream is = null; final StringBuffer license = new StringBuffer(); try { String thisLine; is = resource.getInputStream(); final BufferedReader br = new BufferedReader(new InputStreamReader(is)); while ((thisLine = br.readLine()) != null) { license.append(thisLine + "\n"); } } catch (final IOException ex) { ex.printStackTrace(); } finally { try { StreamExtensions.close(is); } catch (final IOException e) { e.printStackTrace(); } } return license.toString(); }
From source file:com.toyota.carservice.config.config2.java
public Object newStage3(Stage stage, Label lb, String load, String judul, boolean resize, StageStyle style, boolean maximized) { try {/*from w w w . j a va2s .c om*/ Stage st = new Stage(); stage = (Stage) lb.getScene().getWindow(); FXMLLoader root = new FXMLLoader(getClass().getResource(load)); Scene scene = new Scene(root.load()); st.initStyle(style); st.setResizable(resize); st.setMaximized(maximized); st.setTitle(judul); st.setScene(scene); ApplicationContext appContex = config.getInstance().getApplicationContext(); Resource resource = appContex.getResource("classpath:com/toyota/carservice/img/kallatoyota.png"); st.getIcons().add(new Image(resource.getURI().toString())); st.show(); return root.getController(); } catch (Exception e) { e.printStackTrace(); } return null; }
From source file:com.toyota.carservice.config.config2.java
public Object newStage(Stage stage, Label lb, String load, String judul, boolean resize, StageStyle style, boolean maximized) { try {//from w w w . j a v a2s .co m Stage st = new Stage(); stage = (Stage) lb.getScene().getWindow(); FXMLLoader root = new FXMLLoader(getClass().getResource(load)); Scene scene = new Scene(root.load()); st.initStyle(style); st.setResizable(resize); st.setMaximized(maximized); st.setTitle(judul); st.setScene(scene); ApplicationContext appContex = config.getInstance().getApplicationContext(); Resource resource = appContex.getResource("classpath:com/toyota/carservice/img/kallatoyota.png"); st.getIcons().add(new Image(resource.getURI().toString())); st.show(); stage.close(); return root.getController(); } catch (Exception e) { e.printStackTrace(); } return null; }
From source file:com.toyota.carservice.config.config2.java
public Object newStage2(Stage stage, Button lb, String load, String judul, boolean resize, StageStyle style, boolean maximized) { try {/* w ww . ja va 2 s . co m*/ Stage st = new Stage(); stage = (Stage) lb.getScene().getWindow(); FXMLLoader root = new FXMLLoader(getClass().getResource(load)); Scene scene = new Scene(root.load()); st.initStyle(style); st.setResizable(resize); st.setMaximized(maximized); st.setTitle(judul); st.setScene(scene); ApplicationContext appContex = config.getInstance().getApplicationContext(); Resource resource = appContex.getResource("classpath:com/toyota/carservice/img/kallatoyota.png"); st.getIcons().add(new Image(resource.getURI().toString())); st.show(); stage.close(); return root.getController(); } catch (Exception e) { e.printStackTrace(); } return null; }
From source file:it.geosolutions.geobatch.catalog.dao.file.xstream.FakeDataDirHandler.java
@Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { try {//w w w. java2 s. c om super.setApplicationContext(applicationContext); Resource resource = applicationContext.getResource("data"); dataDirectory = resource.getFile(); LOGGER.info("DATA DIR: " + dataDirectory); } catch (IOException ex) { throw new BeanInitializationException("Can't set data dir", ex); } }
From source file:br.com.edo.atmlist.controller.ATMController.java
@Secured("authenticated") @RequestMapping(value = "/atmList", method = RequestMethod.GET, produces = "application/json") public @ResponseBody Object getATMListFromServer(ModelMap map) { map.put("greeting", "ING ATM List"); try {//w w w .j a va 2s .c o m ApplicationContext appContext = new ClassPathXmlApplicationContext(); System.out.println("----"); Resource resource = appContext.getResource("url:https://www.ing.nl/api/locator/atms/"); BufferedReader streamReader = new BufferedReader( new InputStreamReader(resource.getInputStream(), "UTF-8")); StringBuilder responseStrBuilder = new StringBuilder(); String inputStr; // Skip first line inputStr = streamReader.readLine(); while ((inputStr = streamReader.readLine()) != null) { responseStrBuilder.append(inputStr); } ObjectMapper mapper = new ObjectMapper(); atmServerList = mapper.readValue(responseStrBuilder.toString(), List.class); } catch (Exception e) { e.printStackTrace(); } return atmServerList; }
From source file:de.alpharogroup.duplicate.files.panels.progressbar.ProgressbarPanel.java
/** * Inits the components.//from ww w .j ava2s . c om */ private void initComponents() { prgrBrTask = new javax.swing.JProgressBar(); btnCancel = new javax.swing.JButton(); lblInfo = new javax.swing.JLabel(); ApplicationContext ctx = SpringApplicationContext.getInstance().getApplicationContext(); Resource resource = ctx.getResource("classpath:images/nico.gif"); File imageFile = null; try { imageFile = resource.getFile(); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } BufferedImage image = null; try { image = javax.imageio.ImageIO.read(imageFile); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } pnlIconPanel = new ImagePanel(image); btnCancel.setText("Cancel"); lblInfo.setText("Info"); }