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 classAbstractGroovyScriptEngineIntegration.GroovyCacheUsed 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 classAbstractGroovyScriptEngineIntegration.GroovyClassCache
-
Field Summary
Fields Modifier and Type Field Description protected org.springframework.context.ApplicationContextacprotected static StringAPP_CONTEXTstatic StringBLACKLIST_PATTERNSstatic ThreadLocal<Map<String,Object>>COMPILE_OPTIONSprotected groovy.text.GStringTemplateEngineengineprotected groovy.lang.GroovyClassLoadergleprotected AbstractGroovyScriptEngineIntegration.GroovyCachegroovyCacheprotected AbstractGroovyScriptEngineIntegration.GroovyClassCachegroovyClassCacheprotected groovy.util.GroovyScriptEnginegseprotected static org.apache.commons.logging.LogLOGstatic StringWHITELIST_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 voidcleanupClassInfoReferences()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.Classcompile(String script)Stringevaluate(Map<String,Object> bindingMap, String gstring)Objectexecute(Map<String,Object> bindingMap, String scriptName)Execute groovy script.voidinit()ObjectinstantiateClass(Map<String,Object> bindingMap, String scriptName)ObjectinstantiateClass(Map<String,Object> bindingMap, String storageDirectory, String scriptName)Deprecated.protected abstract StringloadScript(String script)static voidmain(String[] args)ClassparseClassMethod(String scriptName, groovy.lang.GroovyCodeSource codeSource)booleanscriptExists(String scriptName)voidsetApplicationContext(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:
evaluatein interfaceScriptIntegration- Throws:
IOException
-
scriptExists
public boolean scriptExists(String scriptName)
- Specified by:
scriptExistsin interfaceScriptIntegration
-
execute
public Object execute(Map<String,Object> bindingMap, String scriptName) throws ScriptEngineException
Description copied from interface:ScriptIntegrationExecute groovy script.- Specified by:
executein 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:
compilein interfaceScriptIntegration- Throws:
CheckGroovyExceptionorg.codehaus.groovy.control.MultipleCompilationErrorsException
-
parseClassMethod
public Class parseClassMethod(String scriptName, groovy.lang.GroovyCodeSource codeSource) throws IOException
- Throws:
IOException
-
instantiateClass
public Object instantiateClass(Map<String,Object> bindingMap, String scriptName) throws IOException
- Specified by:
instantiateClassin interfaceScriptIntegration- Throws:
IOException
-
setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException- Specified by:
setApplicationContextin 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:
instantiateClassin interfaceScriptIntegration- Throws:
IOException
-
cleanupClassInfoReferences
@Scheduled(fixedRateString="${org.openiam.groovy.cleanup.sweeptime}") public void cleanupClassInfoReferences() throws IllegalAccessException, IllegalArgumentException, InvocationTargetExceptionThis 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)
-
-