List of usage examples for org.springframework.core.io ClassPathResource ClassPathResource
public ClassPathResource(String path)
From source file:net.javacrumbs.springws.test.common.DefaultMessageComparatorTest.java
public void compareDocuments(String control, String test) throws IOException { Document controlDocument = getXmlUtil().loadDocument(new ClassPathResource(control)); comparator.compareDocuments(controlDocument, getXmlUtil().loadDocument(createMessage(test))); }
From source file:org.cloudfoundry.tools.timeout.TimeoutResourceHttpRequestHandler.java
public TimeoutResourceHttpRequestHandler() { Resource location = new ClassPathResource("/cloudfoundry/"); setLocations(Collections.singletonList(location)); }
From source file:com.github.persapiens.jsfboot.jetty.JsfJettyServerCustomizer.java
@Override public void customize(Server server) { Handler[] childHandlersByClass = server.getChildHandlersByClass(WebAppContext.class); final WebAppContext webAppContext = (WebAppContext) childHandlersByClass[0]; try {// w ww. j ava 2s .co m ClassPathResource classPathResource = new ClassPathResource( this.jettyProperties.getClassPathResource()); webAppContext.setBaseResource(new ResourceCollection(classPathResource.getURI().toString())); AccessController.doPrivileged(new PrivilegedAction<Void>() { @Override public Void run() { webAppContext.setClassLoader(new URLClassLoader(new URL[0], this.getClass().getClassLoader())); return null; } }); LOGGER.info( "Setting Jetty classLoader to " + this.jettyProperties.getClassPathResource() + " directory"); } catch (IOException exception) { LOGGER.error("Unable to configure Jetty classLoader to " + this.jettyProperties.getClassPathResource() + " directory " + exception.getMessage()); throw new RuntimeException(exception); } }
From source file:com.googlecode.flyway.commandline.MainMediumTest.java
/** * Tests dynamically adding a directory to the classpath. */// w ww. jav a2 s . c om @Test public void addDirectoryToClasspath() throws Exception { assertFalse(new ClassPathResource("runtime.properties").exists()); String folder = new ClassPathResource("dynamic").getFile().getPath(); Main.addJarOrDirectoryToClasspath(folder); assertTrue(new ClassPathResource("runtime.properties").exists()); }
From source file:org.deeplearning4j.spark.models.embeddings.word2vec.Word2VecTest.java
@Test public void testConcepts() throws Exception { JavaRDD<String> corpus = sc.textFile(new ClassPathResource("raw_sentences.txt").getFile().getAbsolutePath()) .map(new Function<String, String>() { @Override//from www .j a v a 2 s . c o m public String call(String s) throws Exception { return s.toLowerCase(); } }).cache(); Word2Vec word2Vec = new Word2Vec(); sc.getConf().set(Word2VecPerformer.NEGATIVE, String.valueOf(0)); Pair<VocabCache, WeightLookupTable> table = word2Vec.train(corpus); WordVectors vectors = WordVectorSerializer.fromPair(new Pair<>(table.getSecond(), table.getFirst())); Collection<String> words = vectors.wordsNearest("day", 20); assertTrue(words.contains("week")); }
From source file:wsconfig.WebServiceConfigPays.java
@Bean(name = "pays") public DefaultWsdl11Definition defaultWsdl11Definition(XsdSchema paysSchema) { ClassPathResource cpr = new ClassPathResource("applicationContext.xml"); ListableBeanFactory bf = new XmlBeanFactory(cpr); WsConfig conf = (WsConfig) bf.getBean("config"); DefaultWsdl11Definition wsdl11Definition = new DefaultWsdl11Definition(); /*wsdl11Definition.setPortTypeName("PaysPort"); wsdl11Definition.setLocationUri("/ws"); wsdl11Definition.setTargetNamespace("http://spring.io/guides/gs-producing-web-service");*/ wsdl11Definition.setPortTypeName(conf.getPortTypeName()); wsdl11Definition.setLocationUri(conf.getLocationUri()); wsdl11Definition.setTargetNamespace(conf.getTargetNamespace()); wsdl11Definition.setSchema(paysSchema); return wsdl11Definition; }
From source file:org.pdfsam.configuration.PdfsamEnterpriseConfig.java
@Bean(name = "logo16") public Image logo16() throws IOException { return new Image(new ClassPathResource("/images/enterprise/16x16.png").getInputStream()); }
From source file:org.web4thejob.orm.test.AbstractHibernateDependentTest.java
@Before public void initializeData() { if (initialized) { return;/*w w w . ja v a 2s . co m*/ } Properties datasource = new Properties(); try { datasource.load(new ClassPathResource(DatasourceProperties.PATH).getInputStream()); } catch (IOException e) { e.printStackTrace(); throw new RuntimeException(e); } JobletInstaller jobletInstaller; jobletInstaller = ContextUtil.getBean(JobletInstaller.class); jobletInstaller.setConnectionInfo(datasource); List<Exception> errors = jobletInstaller.installAll(); if (errors.isEmpty()) { ContextUtil.addActiveProfile("installed"); ContextUtil.refresh(); } else { throw new RuntimeException("Test Context initialization failed."); } initialized = true; final DataWriterService dataWriterService = ContextUtil.getDWS(); for (int i = 1; i <= iterations; i++) { Reference2 reference2 = new Reference2(UUID.randomUUID().toString()); dataWriterService.save(reference2); Reference1 reference1 = new Reference1(reference2, UUID.randomUUID().toString()); dataWriterService.save(reference1); final Master1 master1 = new Master1(); master1.setName(master1.getEntityType().getName()); master1.setReference1(reference1); dataWriterService.save(master1); final Master2 master2 = new Master2(); master2.setKey(UUID.randomUUID().toString()); master2.setName(master2.getEntityType().getName()); dataWriterService.save(master2); final Detail detail = new Detail(); detail.setId(new DetailId(master1, master2, UUID.randomUUID().toString(), new Random(master1.getId()).nextLong())); detail.setFclass(detail.getEntityType()); detail.setFdate(new Date()); detail.setFdouble(java.lang.Math.PI); detail.setFint(new LocalDate().getMonthOfYear()); detail.setFstring(new LocalDate().toString()); detail.setFtimestamp(new Timestamp(System.currentTimeMillis())); dataWriterService.save(detail); } }
From source file:org.ngrinder.agent.service.MockDynamicCacheConfig.java
@SuppressWarnings("rawtypes") @Override//from w ww . ja v a 2s. com public EhCacheCacheManager dynamicCacheManager() { EhCacheCacheManager cacheManager = new EhCacheCacheManager(); Configuration cacheManagerConfig; InputStream inputStream = null; try { CoreLogger.LOGGER.info("In cluster mode."); inputStream = new ClassPathResource("ehcache-dist.xml").getInputStream(); cacheManagerConfig = ConfigurationFactory.parseConfiguration(inputStream); FactoryConfiguration peerProviderConfig = new FactoryConfiguration(); peerProviderConfig.setClass(RMICacheManagerPeerProviderFactory.class.getName()); List<String> replicatedCacheNames = getReplicatedCacheNames(cacheManagerConfig); Pair<NetworkUtils.IPPortPair, String> properties = createManualDiscoveryCacheProperties( replicatedCacheNames); NetworkUtils.IPPortPair currentListener = properties.getFirst(); String peerProperty = properties.getSecond(); peerProviderConfig.setProperties(peerProperty); cacheManagerConfig.addCacheManagerPeerProviderFactory(peerProviderConfig); System.setProperty("java.rmi.server.hostname", currentListener.getFormattedIP()); FactoryConfiguration peerListenerConfig = new FactoryConfiguration(); peerListenerConfig.setClass(RMICacheManagerPeerListenerFactory.class.getName()); String peerListenerProperty = String.format("hostName=%s, port=%d, socketTimeoutMillis=1000", currentListener.getFormattedIP(), currentListener.getPort()); peerListenerConfig.setProperties(peerListenerProperty); cacheManagerConfig.addCacheManagerPeerListenerFactory(peerListenerConfig); CoreLogger.LOGGER.info("clusterURLs:{}", peerListenerProperty); cacheManagerConfig.setName("TestCluster"); CacheManager mgr = CacheManager.create(cacheManagerConfig); cacheManager.setCacheManager(mgr); } catch (IOException e) { CoreLogger.LOGGER.error("Error while setting up cache", e); } finally { IOUtils.closeQuietly(inputStream); } return cacheManager; }