Class Library

java.lang.Object
org.rapidcontext.core.proc.Library

public class Library extends Object
A procedure library. The library handles procedure aliases, call interceptors and other functions for all procedures.
Version:
1.0
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Path
    Deprecated, for removal: This API element is subject to removal in a future version.
    Use org.rapidcontext.core.type.Procedure.PATH instead.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Library(Storage storage)
    Creates a new procedure library.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Deprecated, for removal: This API element is subject to removal in a future version.
    Storage cache is used instead.
    void
    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.
    Deprecated, for removal: This API element is subject to removal in a future version.
    Use load(String) instead.
    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.
    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
    report(Procedure proc, long start, boolean success, String error)
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • PATH_PROC

      @Deprecated(forRemoval=true) public static final Path 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

      public Library(Storage storage)
      Creates a new procedure library.
      Parameters:
      storage - the data storage to use
  • Method Details

    • getProcedureNames

      @Deprecated(forRemoval=true) public String[] getProcedureNames() throws ProcedureException
      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(forRemoval=true) public Procedure getProcedure(String name) throws ProcedureException
      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(forRemoval=true) public void 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(forRemoval=true) public Procedure loadProcedure(String name) throws ProcedureException
      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

      public Procedure load(String id) throws ProcedureException
      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 type
      data - 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(forRemoval=true) public void deleteProcedure(String name) throws ProcedureException
      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

      public Interceptor getInterceptor()
      Returns the procedure call interceptor.
      Returns:
      the procedure call interceptor
    • setInterceptor

      public void setInterceptor(Interceptor i)
      Sets the procedure call interceptor, overriding the default.
      Parameters:
      i - the procedure call interceptor to use
    • isTracing

      public boolean isTracing(String name)
      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

      public void setTracing(String name, boolean enabled)
      Sets or clears the call tracing for a procedure.
      Parameters:
      name - the name of the procedure
      enabled - true to enabled tracing, false to disable
    • getMetrics

      public Metrics getMetrics()
      Returns the procedure usage metrics.
      Returns:
      the procedure usage metrics
    • report

      public void report(Procedure proc, long start, boolean success, String error)
      Reports procedure usage metrics for a single call.
      Parameters:
      proc - the procedure executed
      start - the start time (in millis)
      success - the success flag
      error - the optional error message