Example usage for org.springframework.integration.scripting ScriptingException ScriptingException

List of usage examples for org.springframework.integration.scripting ScriptingException ScriptingException

Introduction

In this page you can find the example usage for org.springframework.integration.scripting ScriptingException ScriptingException.

Prototype

public ScriptingException(String description, Throwable cause) 

Source Link

Usage

From source file:org.springframework.integration.scripting.jsr223.AbstractScriptExecutor.java

public Object executeScript(ScriptSource scriptSource, Map<String, Object> variables) {
    Object result = null;/*from   w w  w .j a  v  a  2 s .  c o m*/

    try {
        if (variables != null) {
            for (Entry<String, Object> entry : variables.entrySet()) {
                scriptEngine.put(entry.getKey(), entry.getValue());
            }
        }
        String script = scriptSource.getScriptAsString();
        Date start = new Date();
        if (logger.isDebugEnabled()) {
            logger.debug("executing script: " + script);
        }

        result = scriptEngine.eval(script);

        result = postProcess(result, scriptEngine, script);

        if (logger.isDebugEnabled()) {
            logger.debug("script executed in " + (new Date().getTime() - start.getTime()) + " ms");
        }
    }

    catch (Exception e) {
        throw new ScriptingException(e.getMessage(), e);
    }

    return result;
}