|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.ca.jcs.processor.script.ScriptPool
public class ScriptPool
This class allows a pool of primed ScriptEngines to be maintained for maximum runtime efficiency, where a separate
pool is maintained for each unique script's key. Usage counts are maintained both for this class
(eg matching number of live connectors) and for the scripts managed by it (eg matching
number of opbindings executing a function with a script). To calculate the minIdle, maxIdle, maxActive counts for each script's
pool both usage counts are multiplied by each other and then multiplied by the values set in the provided configuration. This class makes
use of any ScriptPoolFactory.ExceptionUnwrapper instance registered against the ScriptPoolFactory.EXCEPTION_UNWRAPPER_KEY key
in an engine's ENGINE_SCOPE bindings.
| Constructor Summary | |
|---|---|
ScriptPool(GenericObjectPool.Config config)
Initialize pool using provided base config (which will be multiplied by usages), or using default settings if it is null. |
|
| Method Summary | |
|---|---|
void |
close()
|
void |
createPools()
Should be called after the pool has been fully set-up, and will create all required underlying pools for each script, provided there is at least one active usage of the pool. |
Object |
invokeFunction(String key,
javax.script.Bindings bindings,
String name,
Object... args)
|
Object |
invokeScript(String key,
javax.script.Bindings bindings)
|
void |
registerScript(String key,
String scriptLang,
String script,
boolean invokeFunc,
int srcLine,
int srcCol)
Register a script (which causes a pool to be created for it), or if it is already registered (eg there are multiple opbindings calling functions in the same script) then bump up the script's usage count. |
void |
setUsages(int usages)
Set usages of this pool (for instance when a connector is activated), causing thresholds for all contained per-script pools to be multiplied by N+1). |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ScriptPool(GenericObjectPool.Config config)
| Method Detail |
|---|
public void createPools()
public void setUsages(int usages)
public void close()
public void registerScript(String key,
String scriptLang,
String script,
boolean invokeFunc,
int srcLine,
int srcCol)
key - Unique key for the script.scriptLang - Language which the script is written in (eg "JavaScript").script - The script to be executed (or a function within it should be).invokeFunc - True if a function within the script is to be executed rather then the whole script.
public Object invokeScript(String key,
javax.script.Bindings bindings)
throws Exception
Exception
public Object invokeFunction(String key,
javax.script.Bindings bindings,
String name,
Object... args)
throws Exception
Exception
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||