Spring Framework ResourceScriptSource - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Spring Framework ResourceScriptSource class.

This code example shows how to use the following methods:getScriptAsString
	private volatile String script;
 
 
	public RefreshableResourceScriptSource(Resource resource, long refreshDelay) {
		this.refreshDelay = refreshDelay;
		this.source = new ResourceScriptSource(resource);
		try { 
			this.script = this.source.getScriptAsString();
		} 
		catch (IOException e) {
			this.lastModifiedChecked.set(0);
		} 
	} 
 
	public String getScriptAsString() throws IOException {
		if (this.script == null || this.isModified()) {
			this.lastModifiedChecked.set(System.currentTimeMillis());
			this.script = source.getScriptAsString();
		} 
		return this.script;
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
	} 
 
	@Test
	public void test3() { 
		ScriptSource source =
			new ResourceScriptSource(new ClassPathResource("/org/springframework/integration/scripting/jsr223/test3.py"));
		Object obj =  executor.executeScript(source);
		PyTuple tuple = (PyTuple) obj;
		assertEquals(1, tuple.get(0));
	} 
 
	@Test
	public void testEmbeddedVariable() { 
		Map<String,Object> variables = new HashMap<String,Object>();
		variables.put("scope", "world");
		Object obj = executor.executeScript(new StaticScriptSource("\"hello, %s\"% scope"),variables);
		assertEquals("hello, world",obj);
	} 
} 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
		Map<String,Object> vars = new HashMap<String,Object>();
		vars.put("one",1);
		vars.put("two","two");
		vars.put("three", 3);
 
		ScriptSource scriptSource = new ResourceScriptSource(new ClassPathResource("/org/springframework/integration/scripting/jsr223/print_message.rb"));
 
		ScriptExecutingMessageProcessor messageProcessor = new ScriptExecutingMessageProcessor(scriptSource, executor, vars);
		messageProcessor.setBeanFactory(Mockito.mock(BeanFactory.class));
 
		Message<?> message = new GenericMessage<String>("hello");
 
		Object obj = messageProcessor.processMessage(message);
 
		assertEquals("hello modified",obj.toString().substring(0,"hello modified".length()));
	} 
 
	@Test
	public void testWithNoVars(){ 
		ScriptSource scriptSource = new ResourceScriptSource(new ClassPathResource("/org/springframework/integration/scripting/jsr223/print_message.rb"));
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getResource
	@Override 
	public Object evaluate(ScriptSource script, Map<String, Object> arguments) {
		GroovyShell groovyShell = new GroovyShell(this.classLoader, new Binding(arguments));
		try { 
			String filename = (script instanceof ResourceScriptSource ?
					((ResourceScriptSource) script).getResource().getFilename() : null);
			if (filename != null) {
				return groovyShell.evaluate(script.getScriptAsString(), filename);
			} 
			else { 
				return groovyShell.evaluate(script.getScriptAsString());
			} 
		} 
		catch (IOException ex) {
			throw new ScriptCompilationException(script, "Cannot access script", ex);
		} 
		catch (CompilationFailedException ex) {
			throw new ScriptCompilationException(script, "Evaluation failure", ex);
		} 
	} 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
 
	/** 
	 * @param scriptLocation The location of the script 
	 */ 
	public void setLocation(Resource scriptLocation) {
		this.scriptSource = new ResourceScriptSource(scriptLocation);
	} 
 
	/** 
	 * @param scriptSource A @{link {@link ScriptSource} pointing to the script 
	 */ 
	public void setScriptSource(ScriptSource scriptSource) {
		this.scriptSource = scriptSource;
	} 
} 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
	} 
 
	@Test
	public void testRhinoHadoopScript() throws Exception {
		UrlResource urlResource = new UrlResource(getClass().getResource("basic-script.js"));
		ScriptSource script = new ResourceScriptSource(urlResource);
 
		Jsr223ScriptEvaluator eval = new Jsr223ScriptEvaluator();
		eval.setLanguage("javascript");
 
		Map<String, Object> args = new LinkedHashMap<String, Object>();
		FileSystem fs = FileSystem.get(config);
		SimplerFileSystem sfs = new SimplerFileSystem(fs);
		 
		args.put("fs", sfs);
		args.put("fsh", new FsShell(config, sfs));
 
		eval.evaluate(script, args);
	} 
 

4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
See Code Examples for Spring Framework ResourceScriptSource Methods: