Class CommandScope

java.lang.Object
liquibase.command.CommandScope

public class CommandScope extends Object
The primary facade used for executing commands. This object gets configured with the command to run and the input arguments associated with it, then is populated with the result output after execute() is called.

Named similarly to Scope because they both define a self-contained unit of values, but this scope is specific to a command rather than being a global scope.

  • Field Details

    • DO_NOT_SEND_EXCEPTION_TO_UI

      public static final String DO_NOT_SEND_EXCEPTION_TO_UI
      See Also:
    • SUPPRESS_SHOWING_EXCEPTION_IN_LOG

      public static final String SUPPRESS_SHOWING_EXCEPTION_IN_LOG
      See Also:
    • NO_PREFIX_PATTERN

      public static final Pattern NO_PREFIX_PATTERN
  • Constructor Details

  • Method Details

    • suppressExceptionLogging

      public static void suppressExceptionLogging(boolean suppressLoggingFlag)
      Set flag to turn on/off exception logging, to prevent stack traces from being shown multiple times
    • isSuppressExceptionLogging

      public static boolean isSuppressExceptionLogging()
    • getCommand

      public CommandDefinition getCommand()
      Returns the CommandDefinition for the command in this scope.
    • getCompleteConfigPrefix

      public String getCompleteConfigPrefix()
      Returns the complete configuration prefix (without a trailing period) for the command in this scope.
      Returns:
      the complete configuration prefix for the command in this scope
    • addArgumentValue

      public CommandScope addArgumentValue(String argument, Object value)
      Adds the given key/value pair to the stored argument data.
      See Also:
    • addArgumentValue

      public <T> CommandScope addArgumentValue(CommandArgumentDefinition<T> argument, T value)
      Adds the given key/value pair to the stored argument data.
    • getConfiguredValue

      public <T> ConfiguredValue<T> getConfiguredValue(CommandArgumentDefinition<T> argument)
      Returns the detailed information about how an argument is set.

      Prefers values set with addArgumentValue(String, Object), but will also check LiquibaseConfiguration for settings of liquibase.command.${commandName(s)}.${argumentName} or liquibase.command.${argumentName}
    • getArgumentValue

      public <T> T getArgumentValue(CommandArgumentDefinition<T> argument)
      Convenience method for getConfiguredValue(CommandArgumentDefinition), returning ConfiguredValue.getValue() along with any CommandArgumentDefinition#getValueConverter() applied
    • provideDependency

      public CommandScope provideDependency(Class<?> clazz, Object value)
      Assign a value to a given provided dependency. So if a CommandStep provides class X, at CommandStep.run(CommandResultsBuilder) method it needs to provide the value for X using this method. commandScope.provideDependency(LockService.class, lockService);

      Means that this class will LockService.class using object lock

    • getDependency

      public <T> Object getDependency(Class<T> clazz)
      Retrieves the registered dependency object provided by this class identifier
    • setOutput

      public CommandScope setOutput(OutputStream outputStream)
      Sets the output stream for this command. The command output sent to this stream should not include status/progress type output, only the actual output itself. Think "what would be piped out", not "what the user is told about what is happening".
    • validate

      public void validate() throws CommandValidationException
      Throws:
      CommandValidationException
    • execute

      public CommandResults execute() throws CommandExecutionException
      Executes the command in this scope, and returns the results.
      Throws:
      CommandExecutionException