Interface ICommandInterceptor


public interface ICommandInterceptor
An interface for stackable command interceptors, which can extend and modify the command call chain.

This mechanism can be used for authentication, logging, and other functions.

See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    execute(org.pipservices4.components.context.IContext context, ICommand command, org.pipservices4.components.exec.Parameters args)
    Executes the wrapped command with specified arguments.
    getName(ICommand command)
    Gets the name of the wrapped command.
    List<org.pipservices4.data.validate.ValidationResult>
    validate(ICommand command, org.pipservices4.components.exec.Parameters args)
    Validates arguments of the wrapped command before its execution.
  • Method Details

    • getName

      String getName(ICommand command)
      Gets the name of the wrapped command.

      The interceptor can use this method to override the command name. Otherwise it shall just delegate the call to the wrapped command.

      Parameters:
      command - the next command in the call chain.
      Returns:
      the name of the wrapped command.
    • execute

      Object execute(org.pipservices4.components.context.IContext context, ICommand command, org.pipservices4.components.exec.Parameters args) throws org.pipservices4.commons.errors.ApplicationException
      Executes the wrapped command with specified arguments.

      The interceptor can use this method to intercept and alter the command execution. Otherwise it shall just delete the call to the wrapped command.

      Parameters:
      context - (optional) a context to trace execution through call chain.
      command - the next command in the call chain that is to be executed.
      args - the parameters (arguments) to pass to the command for execution.
      Returns:
      execution result.
      Throws:
      org.pipservices4.commons.errors.ApplicationException - when execution fails for whatever reason.
      See Also:
      • Parameters
    • validate

      List<org.pipservices4.data.validate.ValidationResult> validate(ICommand command, org.pipservices4.components.exec.Parameters args)
      Validates arguments of the wrapped command before its execution.

      The interceptor can use this method to intercept and alter validation of the command arguments. Otherwise it shall just delegate the call to the wrapped command.

      Parameters:
      command - the next command in the call chain to be validated against.
      args - the parameters (arguments) to validate.
      Returns:
      an list of ValidationResults.
      See Also:
      • Parameters
      • ValidationResult