@ConsumerType
public interface SlingScript
SlingScript
defines the API for objects which encapsulate
a script. To evaluate a script prepare a SlingBindings
instance of
variables used as global variables to the script and call the
eval(SlingBindings)
method.
You can obtain scripts by resolving a script resource through
ResourceResolver.resolve(String)
and then trying to adapt the resource to a script by
calling Adaptable.adaptTo(Class)
.
Modifier and Type | Method and Description |
---|---|
Object |
call(SlingBindings props,
String method,
Object... args)
Evaluates this script using the bound variables as global variables to
the script and then calls the given method with the arguments.
|
Object |
eval(SlingBindings props)
Evaluates this script using the bound variables as global variables to
the script.
|
Resource |
getScriptResource()
Returns the Resource providing the script source code.
|
@Nonnull Resource getScriptResource()
Object eval(@Nonnull SlingBindings props)
props
- The SlingBindings
providing the bound variables for
evaluating the script. Any bound variables must conform to the
requirements of the SlingBindings
predefined variables
set.ScriptEvaluationException
- If an error occurrs executing the
script or preparing the script execution. The cause of the
evaluation execption is available as the exception cause.Object call(@Nonnull SlingBindings props, @Nonnull String method, Object... args)
props
- The SlingBindings
providing the bound variables for
evaluating the script. Any bound variables must conform to the
requirements of the SlingBindings
predefined variables
set.method
- The name of the method to call.args
- The arguments for the method call.ScriptEvaluationException
- If an error occurrs executing the
script or preparing the script execution. The cause of the
evaluation execption is available as the exception cause.Copyright © 2015 The Apache Software Foundation. All rights reserved.