fix
Helius
2022-07-12 e30573034a467475c7f62f137efcd278ec1b5735
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package com.xcong.farmer.cms.utils;
 
import groovy.lang.Binding;
import groovy.lang.GroovyShell;
 
/**
 * @author wzy
 * @date 2022-07-08
 **/
public class GroovySingleton {
    private volatile static GroovyShell groovyShell;
 
    private GroovySingleton (){}
 
    public static GroovyShell getSingleton() {
        if (groovyShell == null) {
            synchronized (GroovySingleton.class) {
                if (groovyShell == null) {
                    Binding binding = new Binding();
                    groovyShell = new GroovyShell(binding);
                }
            }
        }
        return groovyShell;
    }
 
}