Package org.rapidcontext.core.js
Class JsProcedure
java.lang.Object
org.rapidcontext.core.storage.StorableObject
org.rapidcontext.core.type.Procedure
org.rapidcontext.core.js.JsProcedure
- All Implemented Interfaces:
Procedure
A JavaScript procedure. This procedure will execute generic
JavaScript code allowing other procedures to be called.
- Version:
- 1.0
-
Field Summary
FieldsFields inherited from class org.rapidcontext.core.type.Procedure
ACTIVE_MILLIS, KEY_ALIAS, KEY_BINDING, KEY_DEPRECATED, KEY_DESCRIPTION, PATH
Fields inherited from class org.rapidcontext.core.storage.StorableObject
dict, KEY_ACTIVATED_TIME, KEY_CLASSNAME, KEY_ID, KEY_TYPE, PREFIX_COMPUTED, PREFIX_HIDDEN
-
Constructor Summary
ConstructorsConstructorDescriptionJsProcedure
(String id, String type, Dict dict) Creates a new procedure from a serialized representation. -
Method Summary
Modifier and TypeMethodDescriptioncall
(CallContext cx, Bindings bindings) Executes a call of this procedure in the specified context and with the specified call bindings.void
compile()
Compiles the script code.boolean
Checks if this script has been compiled.Methods inherited from class org.rapidcontext.core.type.Procedure
alias, all, deprecated, description, find, getBindings, getDescription, getName, isActive
Methods inherited from class org.rapidcontext.core.storage.StorableObject
activate, activatedTime, destroy, id, init, isModified, passivate, path, serialize, sterilize, toString, type
-
Field Details
-
BINDING_CODE
The binding name for the JavaScript code.- See Also:
-
-
Constructor Details
-
JsProcedure
Creates a new procedure from a serialized representation.- Parameters:
id
- the object identifiertype
- the object type namedict
- the serialized representation
-
-
Method Details
-
isCompiled
public boolean isCompiled()Checks if this script has been compiled.- Returns:
- true if this script has been compiled, or false otherwise
-
call
Executes a call of this procedure in the specified context and with the specified call bindings. The semantics of what the procedure actually does, is up to each implementation. Note that the call bindings are normally inherited from the procedure bindings with arguments bound to their call values.- Specified by:
call
in interfaceProcedure
- Specified by:
call
in classProcedure
- Parameters:
cx
- the procedure call contextbindings
- the call bindings to use- Returns:
- the result of the call, or null if the call produced no result
- Throws:
ProcedureException
- if the call execution caused an error
-
compile
Compiles the script code. This will be done automatically the first time the procedure is run, but may be practical to do at other times as well in order to detect errors.- Throws:
ProcedureException
- if the script couldn't be compiled correctly
-