List of usage examples for org.springframework.core.io ClassPathResource ClassPathResource
public ClassPathResource(String path)
From source file:eu.falcon.semantic.client.DenaClient.java
public static String publishOntology(String fileClassPath, String format, String dataset) { RestTemplate restTemplate = new RestTemplate(); LinkedMultiValueMap<String, Object> map = new LinkedMultiValueMap<>(); final String uri = "http://localhost:8090/api/v1/ontology/publish"; //final String uri = "http://falconsemanticmanager.euprojects.net/api/v1/ontology/publish"; map.add("file", new ClassPathResource(fileClassPath)); map.add("format", format); map.add("dataset", dataset); HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.MULTIPART_FORM_DATA); HttpEntity<LinkedMultiValueMap<String, Object>> entity = new HttpEntity<LinkedMultiValueMap<String, Object>>( map, headers);/* w w w . j a va 2 s . c om*/ String result = restTemplate.postForObject(uri, entity, String.class); return result; }
From source file:au.id.hazelwood.xmltvguidebuilder.utils.ClassPathResourceUtils.java
public static InputStream toInputStream(String path) throws IOException { return new ClassPathResource(path).getInputStream(); }
From source file:cz.muni.fi.pv168.project.hotelmanager.Main.java
public static DataSource createMemoryDatabase() { log.info("starts creation of tables"); BasicDataSource bds = new BasicDataSource(); //set JDBC driver and URL bds.setDriverClassName(EmbeddedDriver.class.getName()); log.info("try create Datasource"); bds.setUrl("jdbc:derby:memory:HotelManagerDB;create=true"); //populate db with tables and data log.info("try create tables"); new ResourceDatabasePopulator(new ClassPathResource("schema-javadb.sql")).execute(bds); log.info("return datasource"); return bds;//from w w w .j a va 2 s . co m }
From source file:com.eventattend.portal.Factory.LoginFactory.java
public static LoginController checkLayer() throws Exception { ClassPathResource resource = new ClassPathResource("BusinessObjectFactory.xml"); BeanFactory factory = new XmlBeanFactory(resource); return (LoginController) factory.getBean("checkdetails"); }
From source file:org.cagrid.gaards.websso.utils.ObjectFactory.java
/** * Initializes the object factory from the <code>fileName</code> parameter * //from ww w . jav a2 s. c om * @param fileName Name of the file which contains the configuration for the WebSSO */ public static void initialize(String fileName) { synchronized (lock) { if (!initialized) { initialized = true; factory = new XmlBeanFactory(new ClassPathResource(fileName)); } } }
From source file:stormy.pythian.service.spring.PyhtianProperties.java
@Bean public static PropertyPlaceholderConfigurer propertyPlaceholderConfigurer() { PropertyPlaceholderConfigurer propertyPlaceholderConfigurer = new PropertyPlaceholderConfigurer(); propertyPlaceholderConfigurer.setLocations(new Resource[] { // new ClassPathResource("redis-config.properties"), // new ClassPathResource("pythian-config.properties") // });/* w w w .j a v a2s . c o m*/ propertyPlaceholderConfigurer.setIgnoreUnresolvablePlaceholders(false); return propertyPlaceholderConfigurer; }
From source file:com.fengduo.bee.commons.filter.xss.XssClean.java
public static Policy getPolicy() throws PolicyException, ServiceException { if (policy == null) { ClassPathResource classPathResource = new ClassPathResource("/antisamy/spark-antisamy.xml"); if (classPathResource == null || !classPathResource.exists()) { throw new ServiceException("spark-antisamy.xml is not exists!"); }/*from w w w . jav a 2s . com*/ InputStream policyFile = XssClean.class.getResourceAsStream("/antisamy/spark-antisamy.xml"); if (policyFile == null) { throw new ServiceException("spark-antisamy.xml is not exists!"); } policy = Policy.getInstance(policyFile); } return policy; }
From source file:com.eventattend.portal.Factory.UserFactory.java
public static UserController userProfilePopulate() throws Exception { ClassPathResource resource = new ClassPathResource("BusinessObjectFactory.xml"); BeanFactory factory = new XmlBeanFactory(resource); return (UserController) factory.getBean("User"); }
From source file:cz.muni.pv168.dragonrental.backend.DragonRental.java
public static DataSource createMemoryDatabase() { BasicDataSource bds = new BasicDataSource(); //set JDBC driver and URL bds.setDriverClassName(EmbeddedDriver.class.getName()); bds.setUrl("jdbc:derby:memory:peopleDB;create=true"); //populate db with tables and data new ResourceDatabasePopulator(new ClassPathResource("schema-javadb.sql"), new ClassPathResource("test-data.sql")).execute(bds); return bds;//from w w w .j a v a 2 s . co m }
From source file:org.ngrinder.common.util.FileUtils.java
/** * Copy the given resource to the given file. * * @param resourcePath resource path/*from ww w . jav a 2s . c o m*/ * @param file file to write * @since 3.2 */ public static void copyResourceToFile(String resourcePath, File file) { InputStream io = null; FileOutputStream fos = null; try { io = new ClassPathResource(resourcePath).getInputStream(); fos = new FileOutputStream(file); IOUtils.copy(io, fos); } catch (IOException e) { LOGGER.error("error while writing {}", resourcePath, e); } finally { IOUtils.closeQuietly(io); IOUtils.closeQuietly(fos); } }