Code example for ResourceScriptSource

Methods: getResource

0
	@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);
		} 
	}