Class 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

public abstract class Procedure extends StorableObject
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 Details

    • KEY_DESCRIPTION

      public static final String KEY_DESCRIPTION
      The dictionary key for the description.
      See Also:
    • KEY_ALIAS

      public static final String KEY_ALIAS
      The dictionary key for the optional alias.
      See Also:
    • KEY_DEPRECATED

      public static final String KEY_DEPRECATED
      The dictionary key for the optional deprecation message.
      See Also:
    • KEY_BINDING

      public static final String KEY_BINDING
      The dictionary key for the binding array.
      See Also:
    • PATH

      public static final Path PATH
      The procedure object storage path.
    • ACTIVE_MILLIS

      public static final long ACTIVE_MILLIS
      The default active procedure time (5 minutes).
      See Also:
  • Constructor Details

    • Procedure

      protected Procedure(String id, String type, Dict dict)
      Creates a new procedure from a serialized representation.
      Parameters:
      id - the object identifier
      type - the object type name
      dict - the serialized representation
      See Also:
  • Method Details

    • all

      public static Stream<Procedure> all(Storage storage)
      Returns a stream of all procedures found in the storage.
      Parameters:
      storage - the storage to search
      Returns:
      a stream of procedure instances found
    • find

      public static Procedure find(Storage storage, String id)
      Searches for a specific procedure in the storage.
      Parameters:
      storage - the storage to search in
      id - the procedure identifier
      Returns:
      the procedure found, or null if not found
    • refreshAliases

      public static void refreshAliases(Storage storage)
      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

      public static Metrics metrics(Storage storage)
      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

      public static Dict normalize(String id, Dict dict)
      Normalizes a procedure data object if needed. This method will modify legacy data into the proper keys and values.
      Parameters:
      id - the object identifier
      dict - 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 class StorableObject
      Returns:
      true if the object is considered active, or false otherwise
    • description

      public String description()
      Returns the procedure description.
      Returns:
      the procedure description
    • alias

      public String alias()
      Returns the optional procedure alias.
      Returns:
      the procedure alias, or null for none
    • deprecated

      public String deprecated()
      Returns the optional deprecation message.
      Returns:
      the deprecation message, or null for none
    • getBindings

      public Bindings 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

      public abstract Object call(CallContext cx, Bindings bindings) throws ProcedureException
      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 context
      bindings - 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

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