GigaSpaces XAP 7.0 API

org.openspaces.remoting.scripting
Class StaticScript

java.lang.Object
  extended by org.openspaces.remoting.scripting.StaticScript
All Implemented Interfaces:
Externalizable, Serializable, BroadcastIndicator, Script
Direct Known Subclasses:
StaticResourceScript

public class StaticScript
extends Object
implements Script, Externalizable

A script that holds the actual script as a String. The name, type, and script must be provided.

Author:
kimchy
See Also:
Serialized Form

Constructor Summary
StaticScript()
          Constructs a new static script.
StaticScript(String name, String type, String script)
          Constructs a new static script.
 
Method Summary
<T,Y> StaticScript
broadcast(RemoteResultReducer<T,Y> reducer)
          Broadcast the execution of this script over all active partitions.
 StaticScript cache(boolean shouldCache)
          Should this script be cached or not.
 Object[] getMetaArguments()
          Returns a set of meta arguments that are used for remote invocation.
 String getName()
          Returns the name of the script.
 Map<String,Object> getParameters()
          Returns the set of parameters that will be passes to the script execution.
 RemoteResultReducer getReducer()
          Returns the reducer that will be used in case broadcasting is enabled or not.
 Object getRouting()
          Returns the routing index.
 String getScriptAsString()
          Returns the script as a String.
 String getType()
          Returns the type of a script.
 StaticScript metaArguments(Object... metaArguments)
          Adds another meta argument to the script
 StaticScript name(String name)
          Sets the name of the script.
 StaticScript parameter(String name, Object value)
          Puts a parameter that can be used during script execution.
 void readExternal(ObjectInput in)
           
 StaticScript routing(Object routing)
          Sets the routing index (which partition it will "hit") for the scirpt.
 StaticScript script(String script)
          Sets the actual script source.
 Boolean shouldBroadcast()
          Return true if broadcast should be enabled or not.
 boolean shouldCache()
          Returns if this script should be cached or not.
 String toString()
           
 StaticScript type(String type)
          Sets the type of the script.
 void writeExternal(ObjectOutput out)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StaticScript

public StaticScript()
Constructs a new static script. Note, the name, type, and script must be provided.


StaticScript

public StaticScript(String name,
                    String type,
                    String script)
Constructs a new static script.

Parameters:
name - The name of the script.
type - The type of the script (for example, groovy).
script - The actual script as a String.
Method Detail

getScriptAsString

public String getScriptAsString()
Returns the script as a String.

Specified by:
getScriptAsString in interface Script

getName

public String getName()
Returns the name of the script. Must uniquely identify a script.

Specified by:
getName in interface Script

getType

public String getType()
Returns the type of a script. For example: groovy.

Specified by:
getType in interface Script

getParameters

public Map<String,Object> getParameters()
Returns the set of parameters that will be passes to the script execution.

Specified by:
getParameters in interface Script

shouldCache

public boolean shouldCache()
Returns if this script should be cached or not.

Specified by:
shouldCache in interface Script

getRouting

public Object getRouting()
Returns the routing index.

Specified by:
getRouting in interface Script

getReducer

public RemoteResultReducer getReducer()
Description copied from interface: BroadcastIndicator
Returns the reducer that will be used in case broadcasting is enabled or not.

Specified by:
getReducer in interface BroadcastIndicator

shouldBroadcast

public Boolean shouldBroadcast()
Description copied from interface: BroadcastIndicator
Return true if broadcast should be enabled or not. Return null if should not affect it in any manner.

Specified by:
shouldBroadcast in interface BroadcastIndicator

getMetaArguments

public Object[] getMetaArguments()
Description copied from interface: Script
Returns a set of meta arguments that are used for remote invocation.

Specified by:
getMetaArguments in interface Script
See Also:
SpaceRemotingInvocation.getMetaArguments()

name

public StaticScript name(String name)
Sets the name of the script.


script

public StaticScript script(String script)
Sets the actual script source.


type

public StaticScript type(String type)
Sets the type of the script. For example: groovy.


cache

public StaticScript cache(boolean shouldCache)
Should this script be cached or not. Deaults to true.


parameter

public StaticScript parameter(String name,
                              Object value)
Puts a parameter that can be used during script execution.

Parameters:
name - The name of the parameter.
value - The value of the parameter.

routing

public StaticScript routing(Object routing)
Sets the routing index (which partition it will "hit") for the scirpt.


metaArguments

public StaticScript metaArguments(Object... metaArguments)
Adds another meta argument to the script

See Also:
Script.getMetaArguments(), SpaceRemotingInvocation.getMetaArguments(), ScriptingMetaArgumentsHandler

broadcast

public <T,Y> StaticScript broadcast(RemoteResultReducer<T,Y> reducer)
Broadcast the execution of this script over all active partitions. Optionally use a reducer to reduce the results.


writeExternal

public void writeExternal(ObjectOutput out)
                   throws IOException
Specified by:
writeExternal in interface Externalizable
Throws:
IOException

readExternal

public void readExternal(ObjectInput in)
                  throws IOException,
                         ClassNotFoundException
Specified by:
readExternal in interface Externalizable
Throws:
IOException
ClassNotFoundException

toString

public String toString()
Overrides:
toString in class Object

GigaSpaces XAP 7.0 API

Copyright © GigaSpaces.