V
- The expected result type of the Promise
. As a convenience, this class supports non-Promise type to
be returned from the script, and will wrap it into a Promise
.public class AbstractScriptableHeapObject<V> extends Object implements Closeable
This class is a base class for implementing any interface that we want to make pluggable through scripting support.
Scripts are provided with the following variables bindings:
logger
- The logger for this script
globals
- the Map of global variables which persist across
successive invocations of the script
context
- the associated request context
contexts
- the visible contexts, keyed by context's name
http
- an HTTP client which may be used for performing outbound HTTP requests
ldap
- an LDAP client which may be used for performing LDAP requests
such as LDAP authentication
The provided args
parameters supports config-time expressions evaluation with the
special addition of a heap
variable that allows the script to get references
to other objects available in the heap.
{
"args": {
"ref": "heap['object-name']"
}
}
NOTE : at the moment only Groovy is supported.
Modifier and Type | Class and Description |
---|---|
protected static class |
AbstractScriptableHeapObject.AbstractScriptableHeaplet
Creates and initializes a capture filter in a heap environment.
|
Modifier | Constructor and Description |
---|---|
protected |
AbstractScriptableHeapObject(Script compiledScript,
Heap heap,
String name)
Creates a new scriptable heap object using the provided compiled script.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
protected Promise<V,ScriptException> |
runScript(Bindings bindings,
Context context,
Class<V> clazz)
Runs the compiled script using the provided bindings.
|
void |
setArgs(Map<String,Object> args)
Sets the parameters which should be made available to scripts.
|
void |
setClientHandler(Handler clientHandler)
Sets the HTTP client handler which should be made available to scripts.
|
protected AbstractScriptableHeapObject(Script compiledScript, Heap heap, String name)
compiledScript
- The compiled script.heap
- The heap to look for bindingsname
- The name of this scriptable heap object.public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
public void setClientHandler(Handler clientHandler)
clientHandler
- The HTTP client handler which should be made available to scripts.public void setArgs(Map<String,Object> args)
args
- The parameters which should be made available to scripts.protected final Promise<V,ScriptException> runScript(Bindings bindings, Context context, Class<V> clazz)
bindings
- Base bindings available to the script (will be enriched).context
- request processing contextclazz
- the class representing the expected result type of the Promise
Copyright 2011-2017 ForgeRock AS.