Package org.rapidcontext.core.proc
Class Library
java.lang.Object
org.rapidcontext.core.proc.Library
A procedure library. The library handles procedure aliases, call
interceptors and other functions for all procedures.
- Version:
- 1.0
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Deprecated, for removal: This API element is subject to removal in a future version.Storage cache is used instead.void
deleteProcedure
(String name) Deprecated, for removal: This API element is subject to removal in a future version.Remove directly from storage instead.Returns the procedure call interceptor.Returns the procedure usage metrics.getProcedure
(String name) Deprecated, for removal: This API element is subject to removal in a future version.Use load(String) instead.String[]
Deprecated, for removal: This API element is subject to removal in a future version.Query storage directly instead.boolean
Checks if all calls to a procedure should be traced.Locates a procedure using either its identifier or an alias.loadProcedure
(String name) Deprecated, for removal: This API element is subject to removal in a future version.Use load(String) instead.void
Loads built-in procedures via storage types.void
Reports procedure usage metrics for a single call.void
Sets the procedure call interceptor, overriding the default.void
setTracing
(String name, boolean enabled) Sets or clears the call tracing for a procedure.storeProcedure
(String id, String type, Dict data) Deprecated, for removal: This API element is subject to removal in a future version.Store directly to storage instead.
-
Field Details
-
PATH_PROC
Deprecated, for removal: This API element is subject to removal in a future version.Use org.rapidcontext.core.type.Procedure.PATH instead.The procedure object storage path.
-
-
Constructor Details
-
Library
Creates a new procedure library.- Parameters:
storage
- the data storage to use
-
-
Method Details
-
getProcedureNames
Deprecated, for removal: This API element is subject to removal in a future version.Query storage directly instead.Returns an array with the names of all loaded procedures.- Returns:
- an array with the names of all loaded procedures
- Throws:
ProcedureException
- if the procedures couldn't be listed
-
getProcedure
Deprecated, for removal: This API element is subject to removal in a future version.Use load(String) instead.Returns a loaded procedure.- Parameters:
name
- the procedure name- Returns:
- the procedure object
- Throws:
ProcedureException
- if the procedure couldn't be found, or failed to load correctly
-
refreshAliases
public void refreshAliases()Loads built-in procedures via storage types. This method is safe to call repeatedly (after each plug-in load). -
clearCache
Deprecated, for removal: This API element is subject to removal in a future version.Storage cache is used instead.Procedure instances are now cached in the storage layer. -
loadProcedure
Deprecated, for removal: This API element is subject to removal in a future version.Use load(String) instead.Loads (or reloads) a procedure from the data store to the cache.- Parameters:
name
- the procedure name- Returns:
- the procedure loaded
- Throws:
ProcedureException
- if the procedure couldn't be loaded
-
load
Locates a procedure using either its identifier or an alias.- Parameters:
id
- the procedure identifier- Returns:
- the procedure object
- Throws:
ProcedureException
- if the procedure couldn't be found, or failed to load correctly
-
storeProcedure
@Deprecated(forRemoval=true) public Procedure storeProcedure(String id, String type, Dict data) throws ProcedureException Deprecated, for removal: This API element is subject to removal in a future version.Store directly to storage instead.Stores a procedure to the data store. The procedure is created from the specified data object, stored to the data store and also placed in the library cache.- Parameters:
id
- the procedure name (object id)type
- the procedure typedata
- the procedure data object- Returns:
- the procedure stored
- Throws:
ProcedureException
- if the procedure couldn't be created or written to the data store
-
deleteProcedure
Deprecated, for removal: This API element is subject to removal in a future version.Remove directly from storage instead.Removes a procedure from the storage (if possible). Normally, only procedures in the local plug-in can be removed this way. Built-in procedures will remain unaffected by this.- Parameters:
name
- the name of the procedure- Throws:
ProcedureException
- if an error occurred while removing the procedure from storage
-
getInterceptor
Returns the procedure call interceptor.- Returns:
- the procedure call interceptor
-
setInterceptor
Sets the procedure call interceptor, overriding the default.- Parameters:
i
- the procedure call interceptor to use
-
isTracing
Checks if all calls to a procedure should be traced.- Parameters:
name
- the name of the procedure- Returns:
- true if all calls should be traced, or false otherwise
-
setTracing
Sets or clears the call tracing for a procedure.- Parameters:
name
- the name of the procedureenabled
- true to enabled tracing, false to disable
-
getMetrics
Returns the procedure usage metrics.- Returns:
- the procedure usage metrics
-
report
Reports procedure usage metrics for a single call.- Parameters:
proc
- the procedure executedstart
- the start time (in millis)success
- the success flagerror
- the optional error message
-