Package org.rapidcontext.core.type
Class Procedure
java.lang.Object
org.rapidcontext.core.storage.StorableObject
org.rapidcontext.core.type.Procedure
- Direct Known Subclasses:
AppListProcedure
,ConnectionListProcedure
,ConnectionMetricsProcedure
,ConnectionValidateProcedure
,JsProcedure
,PluginInstallProcedure
,PluginListProcedure
,PluginLoadProcedure
,PluginUninstallProcedure
,PluginUnloadProcedure
,ProcedureCallProcedure
,ProcedureDeleteProcedure
,ProcedureListProcedure
,ProcedureMetricsProcedure
,ProcedureReadProcedure
,ProcedureTraceProcedure
,ProcedureTypesProcedure
,ProcedureWriteProcedure
,ResetProcedure
,SessionAuthenticateProcedure
,SessionAuthenticateTokenProcedure
,SessionCurrentProcedure
,SessionTerminateProcedure
,StatusProcedure
,StorageCopyProcedure
,StorageDeleteProcedure
,StorageListProcedure
,StorageQueryProcedure
,StorageReadProcedure
,StorageWriteProcedure
,ThreadContextProcedure
,ThreadCreateProcedure
,ThreadInterruptProcedure
,ThreadListProcedure
,TypeListProcedure
,UserAccessProcedure
,UserAuthenticationTokenProcedure
,UserChangeProcedure
,UserListProcedure
,UserMetricsProcedure
,UserPasswordChangeProcedure
,UserSearchProcedure
,UserSettingsProcedure
A server-side function or operation. Procedures may take arguments, modify
data and/or return values. They can be invoked either server-side or
client-side (via API) if permissions allow.
This generic type is used only for direct Java implementations. A number
of subtypes allows creating procedures from configurable parameters (e.g.
SQL text, HTTP requests, etc) instead, sharing a common reusable Java
implementation. When implementing procedures in Java, care must be taken so
that all operations are properly checked for security.
- Version:
- 1.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final long
The default active procedure time (5 minutes).static final String
The dictionary key for the optional alias.static final String
The dictionary key for the binding array.static final String
The dictionary key for the optional deprecation message.static final String
The dictionary key for the description.static final Path
The procedure object storage 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionalias()
Returns the optional procedure alias.Returns a stream of all procedures found in the storage.abstract Object
call
(CallContext cx, Bindings bindings) Executes a call of this procedure in the specified context and with the specified call bindings.Returns the optional deprecation message.Returns the procedure description.static Procedure
Searches for a specific procedure in the storage.Returns the bindings for this procedure.protected boolean
isActive()
Checks if this object is in active use.static Metrics
Returns the procedure call metrics.static Dict
Normalizes a procedure data object if needed.static void
refreshAliases
(Storage storage) Updates the cached procedure aliases by loading all procedures from storage and inspecting them.void
Reports procedure call metrics for a single call.Methods inherited from class org.rapidcontext.core.storage.StorableObject
activate, activatedTime, destroy, dictKey, id, init, isModified, passivate, path, serialize, sterilize, toString, type
-
Field Details
-
KEY_DESCRIPTION
The dictionary key for the description.- See Also:
-
KEY_ALIAS
The dictionary key for the optional alias.- See Also:
-
KEY_DEPRECATED
The dictionary key for the optional deprecation message.- See Also:
-
KEY_BINDING
The dictionary key for the binding array.- See Also:
-
PATH
The procedure object storage path. -
ACTIVE_MILLIS
public static final long ACTIVE_MILLISThe default active procedure time (5 minutes).- See Also:
-
-
Constructor Details
-
Procedure
Creates a new procedure from a serialized representation.- Parameters:
id
- the object identifiertype
- the object type namedict
- the serialized representation- See Also:
-
-
Method Details
-
all
Returns a stream of all procedures found in the storage.- Parameters:
storage
- the storage to search- Returns:
- a stream of procedure instances found
-
find
Searches for a specific procedure in the storage.- Parameters:
storage
- the storage to search inid
- the procedure identifier- Returns:
- the procedure found, or null if not found
-
refreshAliases
Updates the cached procedure aliases by loading all procedures from storage and inspecting them. This method is safe to call repeatedly (after each plug-in load), but is potentially slow.- Parameters:
storage
- the storage to load from
-
metrics
Returns the procedure call metrics. The metrics will be loaded from storage if not already in memory.- Parameters:
storage
- the storage to load from- Returns:
- the procedure call metrics
-
normalize
Normalizes a procedure data object if needed. This method will modify legacy data into the proper keys and values.- Parameters:
id
- the object identifierdict
- the storage data- Returns:
- the storage data (possibly modified)
-
isActive
protected boolean isActive()Checks if this object is in active use. This method will return true if the object was activated during the last 5 minutes.- Overrides:
isActive
in classStorableObject
- Returns:
- true if the object is considered active, or false otherwise
-
description
Returns the procedure description.- Returns:
- the procedure description
-
alias
Returns the optional procedure alias.- Returns:
- the procedure alias, or null for none
-
deprecated
Returns the optional deprecation message.- Returns:
- the deprecation message, or null for none
-
getBindings
Returns the bindings for this procedure. If this procedure requires any special data, adapter connection or input argument binding, those bindings should be set (but possibly to null or blank values).- Returns:
- the bindings for this procedure
-
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.- 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
-
report
Reports procedure call metrics for a single call.- Parameters:
start
- the start time (in millis)success
- the success flagerror
- the optional error message
-