Home » Source Code » » groovy_1/ExprSupport.java

groovy_1/ExprSupport.java ( File view )

  • By ophelia_fupx 2016-12-09
  • View(s):0
  • Download(s):0
  • Point(s): 1
			package com.yusys.approvalflow.afutil;

import groovy.lang.Binding;
import groovy.lang.GroovyShell;
import groovy.lang.Script;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Map;
import org.codehaus.groovy.control.CompilerConfiguration;
public class ExprSupport {

    private static final Object lock = new Object();
    private static final GroovyShell shell;
    private static Hashtable<String, Script> cache = new Hashtable<String, Script>();
    static {

        CompilerConfiguration cfg = new CompilerConfiguration();
        shell = new GroovyShell(cfg);
    public static Object parseExpr(String expr) {

        Script s = getScriptFromCache(expr);
        return s.run();
    public static Object parseExpr(String expr, Map<?, ?> map) {

        Binding binding = new Binding(map);
        Script script = getScriptFromCache(expr);
        return script.run();
    private static Script getScriptFromCache(String expr) {

        if (cache.contains(expr)) {

            return cache.get(expr);
        synchronized (lock) {

            if (cache.contains(expr)) {

                return cache.get(expr);
            Script script = shell.parse(expr);
(Please download the complete source code to view)
Expand> <Close

Want complete source code? Download it here

Point(s): 1

0 lines left, continue to read
Sponsored links

File list

Tips: You can preview the content of files by clicking file names^_^
Name Size Date
ExprSupport.java2.07 kB2016-11-28 21:27
MyBasicScript.java608.00 B2016-11-28 10:12
groovy_10.00 B2016-12-09 17:53
Sponsored links

groovy_1/ExprSupport.java (1.31 kB)

Need 1 point
Your Point(s)

Your Point isn't enough.

Get point immediately by PayPal

More(Debit card / Credit card / PayPal Credit / Online Banking)

Submit your source codes. Get more point


Don't have an account? Register now
Need any help?
Mail to: support@codeforge.com


CodeForge Chinese Version
CodeForge English Version

Where are you going?

^_^"Oops ...

Sorry!This guy is mysterious, its blog hasn't been opened, try another, please!

Warm tip!

CodeForge to FavoriteFavorite by Ctrl+D