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; } }