List of usage examples for org.springframework.core.io DefaultResourceLoader DefaultResourceLoader
public DefaultResourceLoader()
From source file:fi.solita.phantomrunner.browserserver.PhantomJsServer.java
public PhantomJsServer(JavascriptTestInterpreter interpreter, PhantomServerConfiguration serverConfig) { // TODO: how can we send the server port for PhantomJS from here? try {//www .ja v a 2 s . co m this.serverScriptFile = FileUtils.extractResourceToTempDirectory( new DefaultResourceLoader().getResource("classpath:phantomjs-server/phantomjs-server.js"), "phantomjs-server", true); } catch (IOException ioe) { throw new RuntimeException("phantomjs-server.js couldn't be loaded", ioe); } }
From source file:com.github.mjeanroy.springmvc.view.mustache.handlebars.HandlebarsCompilerTest.java
@Before public void setUp() { this.model = new HashMap<String, Object>(); this.model.put("name", "foo"); this.model.put("zero", 0); this.model.put("emptyString", ""); writer = new StringWriter(); ResourceLoader resourceLoader = new DefaultResourceLoader(); templateLoader = new DefaultTemplateLoader(resourceLoader); Handlebars hb = new Handlebars(); hbCompiler = new HandlebarsCompiler(hb, templateLoader); }
From source file:com.github.mjeanroy.springmvc.view.mustache.handlebar.HandlebarCompilerTest.java
@Before public void setUp() { this.model = new HashMap<String, Object>(); this.model.put("name", "foo"); this.model.put("zero", 0); this.model.put("emptyString", ""); writer = new StringWriter(); ResourceLoader resourceLoader = new DefaultResourceLoader(); templateLoader = new DefaultMustacheTemplateLoader(resourceLoader); Handlebars hb = new Handlebars(); hbCompiler = new HandlebarCompiler(hb, templateLoader); }
From source file:com.netflix.genie.web.configs.GenieApiAutoConfiguration.java
/** * Get a resource loader.// w ww . j a v a2 s.co m * * @return a DefaultResourceLoader */ @Bean @ConditionalOnMissingBean(ResourceLoader.class) public ResourceLoader resourceLoader() { return new DefaultResourceLoader(); }
From source file:com.netflix.genie.agent.cli.UserConsole.java
/** * Load and print the Spring banner (if one is configured) to UserConsole. * * @param environment the Spring environment *//*from ww w. java2 s. c o m*/ static void printBanner(final Environment environment) { try { final String bannerLocation = environment.getProperty(BANNER_LOCATION_SPRING_PROPERTY_KEY); if (StringUtils.isNotBlank(bannerLocation)) { final ResourceLoader resourceLoader = new DefaultResourceLoader(); final Resource resource = resourceLoader.getResource(bannerLocation); if (resource.exists()) { final String banner = StreamUtils.copyToString(resource.getInputStream(), environment.getProperty(BANNER_CHARSET_SPRING_PROPERTY_KEY, Charset.class, StandardCharsets.UTF_8)); UserConsole.getLogger().info(banner); } } } catch (final Throwable t) { System.err.println("Failed to print banner: " + t.getMessage()); t.printStackTrace(System.err); } }
From source file:com.github.mjeanroy.springmvc.view.mustache.MustacheView_MustacheJava_Test.java
@Before public void setUp() throws Exception { this.model = new HashMap<String, Object>(); this.model.put("name", "foo"); this.model.put("zero", 0); this.model.put("emptyString", ""); writer = new StringWriter(); when(response.getWriter()).thenReturn(new PrintWriter(writer)); ResourceLoader resourceLoader = new DefaultResourceLoader(); templateLoader = new DefaultTemplateLoader(resourceLoader); MustacheCompiler mustacheCompiler = new MustacheJavaCompiler(templateLoader); mustacheView = new MustacheView(); mustacheView.setCompiler(mustacheCompiler); }
From source file:com.netflix.genie.GenieCoreTestApplication.java
/** * Get the jobs dir as a Spring Resource. Will create if it doesn't exist. * * @return The job dir as a resource//from w w w .j a v a2s. c om * @throws IOException on error reading or creating the directory */ @Bean @ConditionalOnMissingBean public Resource jobsDir() throws IOException { return new DefaultResourceLoader().getResource("/tmp"); }
From source file:com.processpuzzle.application.configuration.domain.PropertyContext.java
public PropertyContext(Application application, ResourceLoader loader, String descriptorUrl) { super(application); log.debug("Application: " + application.getApplicationName() + " is creating configuration: " + descriptorUrl);/*from ww w . j a v a 2 s . co m*/ this.loader = loader; this.configurationDescriptorUrl = descriptorUrl; if (loader == null) this.loader = new DefaultResourceLoader(); }
From source file:com.cloudseal.spring.client.namespace.SAMLBeanDefinitionParserInstanceTest.java
@Before @SuppressWarnings({ "unchecked" }) public void prepareParserContext() throws IOException, SAXException, ParserConfigurationException { final XmlReaderContext readerContext = mock(XmlReaderContext.class); when(readerContext.generateBeanName(any(BeanDefinition.class))) .thenAnswer(GeneratedBeanNameAnswer.generatedBeanName()); when(readerContext.getResourceLoader()).thenReturn(new DefaultResourceLoader()); registry = new SimpleBeanDefinitionRegistry(); final BeanDefinitionBuilder filterChain = BeanDefinitionBuilder.rootBeanDefinition(FilterChainProxy.class); final Map map = new ManagedMap(); map.put("/**", new ManagedList()); filterChain.addPropertyValue("filterChainMap", map); registry.registerBeanDefinition("org.springframework.security.filterChainProxy", filterChain.getBeanDefinition()); parserContext = mock(ParserContext.class); when(parserContext.getReaderContext()).thenReturn(readerContext); when(parserContext.getRegistry()).thenReturn(registry); rootElement = domFromFile("full-config.xml", "sso"); }
From source file:com.yeahmobi.yunit.dataset.AbstractDataSetLoader.java
/** * Gets the {@link ResourceLoader} that will be used to load the dataset {@link Resource}s. * @param testClass The class under test * @return resource loader list//from w ww . ja v a 2 s.c o m */ protected ResourceLoader[] getResourceLoader(Class<?> testClass) { return new ResourceLoader[] { new ClassRelativeResourceLoader(testClass), new DefaultResourceLoader() }; }