Class ResourceLazyLoadingScript
java.lang.Object
org.openspaces.remoting.scripting.ResourceLazyLoadingScript
- All Implemented Interfaces:
SmartExternalizable,Externalizable,Serializable,BroadcastIndicator,LazyLoadingScript,Script
public class ResourceLazyLoadingScript
extends Object
implements LazyLoadingScript, SmartExternalizable
A resource lazy loading script is a lazy loading script that uses Spring abstraction on top of
resources on top of a resource. The script resource location uses Spring notation for location
(similar to URL, with the addition of
classpath: prefix support).
When the scipt is constructed, the actual script contents is not loaded. Only if needed the
script contents will be loaded. See LazyLoadingRemoteInvocationAspect.
- Author:
- kimchy
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionResourceLazyLoadingScript(String name, String type, String resoruceLocation) Constructs a new lazy loading sctipt. -
Method Summary
Modifier and TypeMethodDescription<T,Y> ResourceLazyLoadingScript broadcast(RemoteResultReducer<T, Y> reducer) Broadcast the execution of this script over all active partitions.cache(boolean shouldCache) Should this script be cached or not.Object[]Returns a set of meta arguments that are used for remote invocation.getName()Returns the name of the script.Returns the set of parameters that will be passes to the script execution.Returns the reducer that will be used in case broadcasting is enabled or not.Returns the routing index (which partition it will "hit").Returns the scirpt string only if it was already loaded usingloadScript().getType()Returns the type of a script.booleanReturnstrueif the script has been loaded.voidLoads the scirpt into memory from the resource location.metaArguments(Object... metaArguments) Adds another meta argument to the scriptSets the name of the script.Puts a parameter that can be used during script execution.voidSets the routing index (which partition this will "hit") for the script.Sets the actual script source.Returntrueif broadcast should be enabled or not.booleanReturns if this script should be cached or not.toString()Sets the type of the script.voidMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.gigaspaces.serialization.SmartExternalizable
enabledSmartExternalizableWithReference
-
Constructor Details
-
ResourceLazyLoadingScript
public ResourceLazyLoadingScript() -
ResourceLazyLoadingScript
Constructs a new lazy loading sctipt.- Parameters:
name- The script name (used as a unique identifier for cachable scripts).type- The type of the script executedresoruceLocation- The resource location (similar to URL syntax, with additional support forclasspath:prefix).
-
-
Method Details
-
getScriptAsString
Returns the scirpt string only if it was already loaded usingloadScript().- Specified by:
getScriptAsStringin interfaceScript
-
hasScript
public boolean hasScript()Returnstrueif the script has been loaded.- Specified by:
hasScriptin interfaceLazyLoadingScript
-
loadScript
public void loadScript()Loads the scirpt into memory from the resource location.- Specified by:
loadScriptin interfaceLazyLoadingScript
-
getName
Returns the name of the script. Must uniquely identify a script. -
getType
Returns the type of a script. For example:groovy. -
getParameters
Returns the set of parameters that will be passes to the script execution.- Specified by:
getParametersin interfaceScript
-
shouldCache
public boolean shouldCache()Returns if this script should be cached or not.- Specified by:
shouldCachein interfaceScript
-
getRouting
Returns the routing index (which partition it will "hit").- Specified by:
getRoutingin interfaceScript
-
getReducer
Description copied from interface:BroadcastIndicatorReturns the reducer that will be used in case broadcasting is enabled or not.- Specified by:
getReducerin interfaceBroadcastIndicator
-
shouldBroadcast
Description copied from interface:BroadcastIndicatorReturntrueif broadcast should be enabled or not. Returnnullif should not affect it in any manner.- Specified by:
shouldBroadcastin interfaceBroadcastIndicator
-
getMetaArguments
Description copied from interface:ScriptReturns a set of meta arguments that are used for remote invocation.- Specified by:
getMetaArgumentsin interfaceScript- See Also:
-
name
Sets the name of the script. -
script
Sets the actual script source. -
type
Sets the type of the script. For example:groovy. -
cache
Should this script be cached or not. Deaults totrue. -
parameter
Puts a parameter that can be used during script execution.- Parameters:
name- The name of the parameter.value- The value of the parameter.
-
routing
Sets the routing index (which partition this will "hit") for the script. Defaults to a random routing. Defaults to a random routing. -
broadcast
Broadcast the execution of this script over all active partitions. Optionally use a reducer to reduce the results. -
metaArguments
Adds another meta argument to the script -
writeExternal
- Specified by:
writeExternalin interfaceExternalizable- Throws:
IOException
-
readExternal
- Specified by:
readExternalin interfaceExternalizable- Throws:
IOExceptionClassNotFoundException
-
toString
-