Package org.openiam.script
Class AbstractGroovyScriptEngineIntegration
- java.lang.Object
-
- org.openiam.script.AbstractGroovyScriptEngineIntegration
-
- All Implemented Interfaces:
ScriptIntegration
,org.springframework.beans.factory.Aware
,org.springframework.context.ApplicationContextAware
- Direct Known Subclasses:
GroovyScriptEngineIntegration
public abstract class AbstractGroovyScriptEngineIntegration extends Object implements ScriptIntegration, org.springframework.context.ApplicationContextAware
- Author:
- Zdenko Imrek
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
AbstractGroovyScriptEngineIntegration.GroovyCache
Used to cache groovy body. we can't cache groovy class instances because they are not stateless, for example org.openiam.workflow.activiti.groovy.AbstractApproverAssociationIdentifierprotected static class
AbstractGroovyScriptEngineIntegration.GroovyClassCache
-
Field Summary
Fields Modifier and Type Field Description protected org.springframework.context.ApplicationContext
ac
protected static String
APP_CONTEXT
static String
BLACKLIST_PATTERNS
static ThreadLocal<Map<String,Object>>
COMPILE_OPTIONS
protected groovy.text.GStringTemplateEngine
engine
protected groovy.lang.GroovyClassLoader
gle
protected AbstractGroovyScriptEngineIntegration.GroovyCache
groovyCache
protected AbstractGroovyScriptEngineIntegration.GroovyClassCache
groovyClassCache
protected groovy.util.GroovyScriptEngine
gse
protected static org.apache.commons.logging.Log
LOG
static String
WHITELIST_PATTERNS
-
Constructor Summary
Constructors Constructor Description AbstractGroovyScriptEngineIntegration()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
cleanupClassInfoReferences()
This method is responsible for removing the ClassInfo junk that Groovy creates when instantiating a class We need to remove it, becuase after 8-9 hours of heavy load, Old Gen becomes globbed with WeakReferences and CachedMethod objects, which add up over a long period of time.Class
compile(String script)
String
evaluate(Map<String,Object> bindingMap, String gstring)
Object
execute(Map<String,Object> bindingMap, String scriptName)
Execute groovy script.void
init()
Object
instantiateClass(Map<String,Object> bindingMap, String scriptName)
Object
instantiateClass(Map<String,Object> bindingMap, String storageDirectory, String scriptName)
Deprecated.protected abstract String
loadScript(String script)
static void
main(String[] args)
boolean
scriptExists(String scriptName)
void
setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
-
-
-
Field Detail
-
COMPILE_OPTIONS
public static final ThreadLocal<Map<String,Object>> COMPILE_OPTIONS
-
WHITELIST_PATTERNS
public static final String WHITELIST_PATTERNS
- See Also:
- Constant Field Values
-
BLACKLIST_PATTERNS
public static final String BLACKLIST_PATTERNS
- See Also:
- Constant Field Values
-
APP_CONTEXT
protected static final String APP_CONTEXT
- See Also:
- Constant Field Values
-
ac
protected org.springframework.context.ApplicationContext ac
-
LOG
protected static final org.apache.commons.logging.Log LOG
-
gle
protected groovy.lang.GroovyClassLoader gle
-
gse
protected groovy.util.GroovyScriptEngine gse
-
engine
protected groovy.text.GStringTemplateEngine engine
-
groovyCache
protected AbstractGroovyScriptEngineIntegration.GroovyCache groovyCache
-
groovyClassCache
protected AbstractGroovyScriptEngineIntegration.GroovyClassCache groovyClassCache
-
-
Method Detail
-
init
@PostConstruct public void init() throws IOException, NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException, NoSuchMethodException, ClassNotFoundException
-
evaluate
public String evaluate(Map<String,Object> bindingMap, String gstring) throws IOException
- Specified by:
evaluate
in interfaceScriptIntegration
- Throws:
IOException
-
scriptExists
public boolean scriptExists(String scriptName)
- Specified by:
scriptExists
in interfaceScriptIntegration
-
execute
public Object execute(Map<String,Object> bindingMap, String scriptName) throws ScriptEngineException
Description copied from interface:ScriptIntegration
Execute groovy script.- Specified by:
execute
in interfaceScriptIntegration
- Parameters:
bindingMap
- map of input datascriptName
- groovy script name to load- Returns:
- any data, need for custom parsing
- Throws:
ScriptEngineException
-
compile
public Class compile(String script) throws CheckGroovyException, org.codehaus.groovy.control.MultipleCompilationErrorsException
- Specified by:
compile
in interfaceScriptIntegration
- Throws:
CheckGroovyException
org.codehaus.groovy.control.MultipleCompilationErrorsException
-
instantiateClass
public Object instantiateClass(Map<String,Object> bindingMap, String scriptName) throws IOException
- Specified by:
instantiateClass
in interfaceScriptIntegration
- Throws:
IOException
-
setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException
- Specified by:
setApplicationContext
in interfaceorg.springframework.context.ApplicationContextAware
- Throws:
org.springframework.beans.BeansException
-
instantiateClass
@Deprecated public Object instantiateClass(Map<String,Object> bindingMap, String storageDirectory, String scriptName) throws IOException
Deprecated.- Specified by:
instantiateClass
in interfaceScriptIntegration
- Throws:
IOException
-
cleanupClassInfoReferences
@Scheduled(fixedRateString="${org.openiam.groovy.cleanup.sweeptime}") public void cleanupClassInfoReferences() throws IllegalAccessException, IllegalArgumentException, InvocationTargetException
This method is responsible for removing the ClassInfo junk that Groovy creates when instantiating a class We need to remove it, becuase after 8-9 hours of heavy load, Old Gen becomes globbed with WeakReferences and CachedMethod objects, which add up over a long period of time.The Garbage Collector is very slow in removing these, and under persistnet high load, you will run out of memory.
-
main
public static void main(String[] args)
-
-