Class Interceptor

java.lang.Object
org.rapidcontext.core.proc.Interceptor
Direct Known Subclasses:
DefaultInterceptor, JsCompileInterceptor

public abstract class Interceptor extends Object
A procedure call interceptor. This is an abstract class that allows subclasses to override, monitor or extend any resource reservation or procedure call in the library. Interceptors are chained together, and by default each interceptor delegates calls to its parent interceptor. A default interceptor is available that provides a standard implementation for all methods (necessary since it is the last link in the interceptor chain).
Version:
1.0
See Also:
  • Constructor Details

    • Interceptor

      protected Interceptor(Interceptor parent)
      Creates a new interceptor and links it to the specified parent interceptor.
      Parameters:
      parent - the parent interceptor
  • Method Details

    • getParent

      public final Interceptor getParent()
      Returns the parent interceptor in the interceptor chain.
      Returns:
      the parent interceptor, or null if no parent is available
    • reserve

      public void reserve(CallContext cx, Procedure proc) throws ProcedureException
      Reserves all adapter connections needed for executing the specified procedure. All connections needed by imported procedures will also be reserved recursively.
      Parameters:
      cx - the procedure context
      proc - the procedure definition
      Throws:
      ProcedureException - if the connections couldn't be reserved
    • releaseAll

      public void releaseAll(CallContext cx, boolean commit)
      Releases all reserved adapter connections. The connections will either be committed or rolled back, depending on the commit flag.
      Parameters:
      cx - the procedure context
      commit - the commit (or rollback) flag
    • call

      public Object call(CallContext cx, Procedure proc, Bindings bindings) throws ProcedureException
      Calls a procedure with the specified bindings.
      Parameters:
      cx - the procedure context
      proc - the procedure definition
      bindings - the procedure bindings
      Returns:
      the result of the call, or null if the call produced no result
      Throws:
      ProcedureException - if the call execution caused an error