List of usage examples for org.springframework.core.io ClassPathResource ClassPathResource
public ClassPathResource(String path)
From source file:com.graphaware.module.es.mapping.JsonFileMapping.java
@Override public void configure(Map<String, String> config) { if (!config.containsKey(FILE_PATH_KEY)) { throw new RuntimeException("Configuration is missing the " + FILE_PATH_KEY + "key"); }/*from w ww .j a v a 2 s. c o m*/ try { String file = new ClassPathResource(config.get("file")).getFile().getAbsolutePath(); mappingRepresentation = new ObjectMapper().readValue(new File(file), DocumentMappingRepresentation.class); } catch (IOException e) { throw new RuntimeException("Unable to read json mapping file", e); } }
From source file:org.jolokia.jvmagent.spring.config.SpringConfigTest.java
@Test public void simpleServer() throws ParserConfigurationException, IOException, SAXException { reader.loadBeanDefinitions(new ClassPathResource("/simple-server.xml")); BeanDefinition bd = beanFactory.getBeanDefinition("jolokiaServer"); assertEquals(bd.getBeanClassName(), SpringJolokiaAgent.class.getName()); MutablePropertyValues props = bd.getPropertyValues(); assertEquals(props.size(), 2);//from ww w . j av a 2 s .c om assertEquals(props.getPropertyValue("lookupConfig").getValue(), false); BeanDefinition cBd = (BeanDefinition) props.getPropertyValue("config").getValue(); ; assertEquals(cBd.getBeanClassName(), SpringJolokiaConfigHolder.class.getName()); MutablePropertyValues cProps = cBd.getPropertyValues(); assertEquals(cProps.size(), 1); verifyConfig(cProps); }
From source file:org.jtheque.ui.impl.UIUtilsImpl.java
/** * Create a new UIUtilsImpl.//from w ww . j a v a 2s .com * * @param stateService The state service. * @param imageService The resource service. * @param core The core */ public UIUtilsImpl(StateService stateService, ImageService imageService, Core core) { super(); configuration = stateService.getState(new WindowsConfiguration(core)); imageService.registerResource(LIGHT_IMAGE, new ClassPathResource("org/jtheque/ui/light.png")); }