Package com.sishuok.spring4.script

Source Code of com.sishuok.spring4.script.ScriptTest

package com.sishuok.spring4.script;

import org.junit.Test;
import org.springframework.scripting.ScriptEvaluator;
import org.springframework.scripting.ScriptSource;
import org.springframework.scripting.groovy.GroovyScriptEvaluator;
import org.springframework.scripting.support.StaticScriptSource;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ExecutionException;

/**
* <p>User: Zhang Kaitao
* <p>Date: 13-12-19
* <p>Version: 1.0
*/
public class ScriptTest {

    @Test
    public void test() throws ExecutionException, InterruptedException {
        ScriptEvaluator scriptEvaluator = new GroovyScriptEvaluator();

        //ResourceScriptSource 外部的
        ScriptSource source = new StaticScriptSource("i+j");
        Map<String, Object> args = new HashMap<>();
        args.put("i", 1);
        args.put("j", 2);
        System.out.println(scriptEvaluator.evaluate(source, args));
    }
}
TOP

Related Classes of com.sishuok.spring4.script.ScriptTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.