This page describes an older version of the product. The latest stable version is 16.4.

Scripting Executor

Dynamic Language Tasks has been extended and now supports Scala based script execution.


Here is how you would configure a processing unit to run a scripting executor with scala support and use it from a client proxy. For detailed information on the Scripting Executor framework, see Dynamic Language Tasks.

Processing Unit Configuration

<os-core:embedded-space id="space" name="mySpace"/>

<os-core:giga-space id="gigaSpace" space="space"/>

<bean id="scriptingExecutorImpl" class="org.openspaces.remoting.scripting.DefaultScriptingExecutor">
  <property name="executors">
      <entry key="scala">
    <bean class="org.openspaces.remoting.scripting.ScalaLocalScriptExecutor">

<os-remoting:service-exporter id="serviceExporter">
  <os-remoting:service ref="scriptingExecutorImpl"/>

<os-events:polling-container id="remotingContainer" giga-space="gigaSpace">
  <os-events:listener ref="serviceExporter"/>

Client Side Configuration

<os-core:space-proxy  id="space" name="mySpace"/>

<os-core:giga-space id="gigaSpace" space="space"/>

<os-remoting:executor-proxy id="executorScriptingExecutor" giga-space="gigaSpace"
    <bean class="org.openspaces.remoting.scripting.LazyLoadingRemoteInvocationAspect" />
    <bean class="org.openspaces.remoting.scripting.ScriptingRemoteRoutingHandler" />
    <bean class="org.openspaces.remoting.scripting.ScriptingMetaArgumentsHandler" />


3 new Script implementations have been added to support compilation and caching of compiled scala scripts. These provide the ability to explicitly set the static type for script parameters which is required when the runtime type is not public. In most cases, there is no need to define these as they can be deduced to use the parameter runtime type.

  • org.openspaces.remoting.scripting.ScalaTypedStaticScript which extends StaticScript.
  • org.openspaces.remoting.scripting.ScalaTypedStaticResourceScript which extends StaticResourceScript.
  • org.openspaces.remoting.scripting.ScalaTypedResourceLazyLoadingScript which extends ResourceLazyLoadingScript.


Import org.openspaces.remoting.scripting.ScalaTypedStaticScript into scope to use the methods demonstrated below.

val code = """
val readData: Any =
val numberAsString = someNumber.toString
val setAsString = someSet.toString
numberAsString + " " + someString + " " + setAsString + " " + readData

val script = new ScalaTypedStaticScript("myScript", "scala", code)
  .parameter("someNumber", 1)
  .parameter("someString", "str")
  // explicit type is requierd because the runtime type of the generated
  // set is not public
  .parameter("someSet", Set(1,2,3), classOf[Set[_]])

val result = executor.execute(script)

println("Script execution result: " + result)