Package liquibase.command
Class CommandScope
java.lang.Object
liquibase.command.CommandScope
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 Summary
-
Constructor Summary
ConstructorDescriptionCommandScope
(String... commandName) Creates a new scope for the given command. -
Method Summary
Modifier and TypeMethodDescriptionaddArgumentValue
(String argument, Object value) Adds the given key/value pair to the stored argument data.<T> CommandScope
addArgumentValue
(CommandArgumentDefinition<T> argument, T value) Adds the given key/value pair to the stored argument data.execute()
Executes the command in this scope, and returns the results.<T> T
getArgumentValue
(CommandArgumentDefinition<T> argument) Convenience method forgetConfiguredValue(CommandArgumentDefinition)
, returningConfiguredValue.getValue()
along with anyCommandArgumentDefinition#getValueConverter()
appliedReturns theCommandDefinition
for the command in this scope.Returns the complete configuration prefix (without a trailing period) for the command in this scope.<T> ConfiguredValue<T>
getConfiguredValue
(CommandArgumentDefinition<T> argument) Returns the detailed information about how an argument is set.<T> Object
getDependency
(Class<T> clazz) Retrieves the registered dependency object provided by this class identifierprovideDependency
(Class<?> clazz, Object value) Assign a value to a given provided dependency.setOutput
(OutputStream outputStream) Sets the output stream for this command.void
validate()
-
Field Details
-
DO_NOT_SEND_EXCEPTION_TO_UI
- See Also:
-
NO_PREFIX_PATTERN
-
-
Constructor Details
-
CommandScope
Creates a new scope for the given command.- Throws:
CommandExecutionException
-
-
Method Details
-
getCommand
Returns theCommandDefinition
for the command in this scope. -
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
Adds the given key/value pair to the stored argument data.- See Also:
-
addArgumentValue
Adds the given key/value pair to the stored argument data. -
getConfiguredValue
Returns the detailed information about how an argument is set.
Prefers values set withaddArgumentValue(String, Object)
, but will also checkLiquibaseConfiguration
for settings of liquibase.command.${commandName(s)}.${argumentName} or liquibase.command.${argumentName} -
getArgumentValue
Convenience method forgetConfiguredValue(CommandArgumentDefinition)
, returningConfiguredValue.getValue()
along with anyCommandArgumentDefinition#getValueConverter()
applied -
provideDependency
Assign a value to a given provided dependency. So if a CommandStep provides class X, atCommandStep.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
Retrieves the registered dependency object provided by this class identifier -
setOutput
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
- Throws:
CommandValidationException
-
execute
Executes the command in this scope, and returns the results.- Throws:
CommandExecutionException
-