|
GigaSpaces XAP 7.0 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.openspaces.remoting.scripting.DefaultScriptingExecutor
public class DefaultScriptingExecutor
A Default "server" side script executor. Can execute Script
s
based on a set of registered LocalScriptExecutor
s.
Will automatically register groovy
(GroovyLocalScriptExecutor
)
if it exists within the classpath. Will also automatically register ruby
(JRubyLocalScriptExecutor
) if the jruby jars exists within the classpath.
If working under Java 6, or adding JSR 223 jars into the classpath, will use its scripting support as a fallback if no local script executors are found for a given type. The JSR allows for a unified API on top of different scripting libraries with pluggable types.
The executor will automatically add the Spring application context as a parameter to the script under the
name applicationContext
allowing to get any beans defined on the "server side". Since GigaSpace
instances are often used within the script, it will automatically add all the different GigaSpace
instances defined within the application context under their respective bean names.
Another parameter that will be passed to the script is the ClusterInfo
allowing
the script to be "aware" of which cluster instance it is executed on, and the cluster size.
This executor also supports caching of compiled scipts using the CompiledScriptCache
abstraction. There are two special caches, one for compiled scripts that are thread safe (the same compiled script
can be executed by several threads) and one for compiled scripts that are not thread safe (the same compiled scripts
can only be executed by a single thread). Note, caching is done based on the script name (Script.getName()
,
this means that changed scripts should change their name in order to recompile them and insert them into the cache.
Field Summary | |
---|---|
static String |
APPLICATION_CONTEXT_KEY
|
static String |
CLUSTER_INFO_KEY
|
static String |
GROOVY_LOCAL_EXECUTOR_TYPE
|
static String |
JRUBY_LOCAL_EXECUTOR_TYPE
|
Constructor Summary | |
---|---|
DefaultScriptingExecutor()
|
Method Summary | |
---|---|
void |
afterPropertiesSet()
|
Future |
asyncExecute(Script script)
Executes the given script and return a future that can be used to read the response at a later stage. |
Object |
execute(Script script)
Executes the given script and returns a response. |
void |
onApplicationEvent(ApplicationEvent applicationEvent)
On applicaiton context refresh event get all the GigaSpace beans and put them in a map that will later be appeneded to any script parameters. |
void |
setApplicationContext(ApplicationContext applicationContext)
|
void |
setClusterInfo(ClusterInfo clusterInfo)
Sets the cluster information. |
void |
setExecutors(Map<String,LocalScriptExecutor> executors)
|
void |
setNonThreadSafeCopmiledScriptCache(CompiledScriptCache nonThreadSafeCopmiledScriptCache)
Sets a compiled script cache for compiled scripts taht are not thread safe (the same script can not be executed by different threads). |
void |
setParameters(Map<String,Object> parameters)
Sets parameters that will be added to each script. |
void |
setThreadSafeCompiledScriptCache(CompiledScriptCache threadSafeCompiledScriptCache)
Sets a compiled script cache for compiled scripts taht are thread safe (the same script can be executed by different threads). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String APPLICATION_CONTEXT_KEY
public static final String CLUSTER_INFO_KEY
public static final String GROOVY_LOCAL_EXECUTOR_TYPE
public static final String JRUBY_LOCAL_EXECUTOR_TYPE
Constructor Detail |
---|
public DefaultScriptingExecutor()
Method Detail |
---|
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException
setApplicationContext
in interface ApplicationContextAware
BeansException
public void setClusterInfo(ClusterInfo clusterInfo)
ClusterInfoAware
Note, the cluster information is obtained externally from the application context which means
that this feature need to be supported by specific containers (and is not supported by plain
Spring application context). This means that beans that implement ClusterInfoAware
should take into account the fact that the cluster info provided might be null.
setClusterInfo
in interface ClusterInfoAware
clusterInfo
- The cluster information to be injectedpublic void setParameters(Map<String,Object> parameters)
public void setExecutors(Map<String,LocalScriptExecutor> executors)
public void setThreadSafeCompiledScriptCache(CompiledScriptCache threadSafeCompiledScriptCache)
LRUThreadSafeCompiledScriptCache
.
LocalScriptExecutor.isThreadSafe()
public void setNonThreadSafeCopmiledScriptCache(CompiledScriptCache nonThreadSafeCopmiledScriptCache)
LRUNonThreadSafeCompiledScriptCache
.
LocalScriptExecutor.isThreadSafe()
public void afterPropertiesSet() throws Exception
afterPropertiesSet
in interface InitializingBean
Exception
public void onApplicationEvent(ApplicationEvent applicationEvent)
onApplicationEvent
in interface ApplicationListener
public Object execute(Script script) throws ScriptingException
ScriptingExecutor
execute
in interface ScriptingExecutor
ScriptingException
public Future asyncExecute(Script script) throws ScriptingException
ScriptingExecutor
Note, this only works with "async" remoting.
asyncExecute
in interface ScriptingExecutor
ScriptingException
|
GigaSpaces XAP 7.0 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |