Top Description Inners Fields Constructors Methods
liquibase

public Class Scope

extends Object
Class Inheritance
Imports
liquibase.configuration.LiquibaseConfiguration, liquibase.database.Database, .DatabaseConnection, .OfflineConnection, liquibase.database.jvm.JdbcConnection, liquibase.exception.UnexpectedLiquibaseException, liquibase.listener.LiquibaseListener, liquibase.logging.LogService, .Logger, liquibase.logging.core.JavaLogService, .LogServiceFactory, liquibase.logging.mdc.CustomMdcObject, .MdcManager, .MdcManagerFactory, .MdcObject, liquibase.osgi.ContainerChecker, liquibase.resource.ClassLoaderResourceAccessor, .ResourceAccessor, liquibase.servicelocator.ServiceLocator, .StandardServiceLocator, liquibase.ui.ConsoleUIService, .UIService, liquibase.util.CollectionUtil, .SmartMap, .StringUtil, lombok.Getter, java.lang.reflect.Constructor, java.nio.charset.Charset, java.util.*, java.util.concurrent.ConcurrentHashMap

This scope object is used to hold configuration and other parameters within a call without needing complex method signatures. It also allows new parameters to be added by extensions without affecting standard method signatures. Scope objects can be created in a hierarchical manner with the child(Map, ScopedRunner) or child(String, Object, ScopedRunner) methods. Values set in parent scopes are visible in child scopes, but values in child scopes are not visible to parent scopes. Values with the same key in different scopes "mask" each other with the value furthest down the scope chain being returned.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
Scope.Attr

Enumeration containing standard attributes.

public static interface
public static interface

Field Summary

Modifier and TypeField and Description
private static final Map<String, List<MdcObject>>
public static final String
private LiquibaseListener
private final Scope
private final String
private static ScopeManager
private final SmartMap

Constructor Summary

AccessConstructor and Description
private
Scope()

Creates a new "root" scope.

protected
Scope(Scope
The new Scopes parent in the hierarchy of Scopes, not null.
parent
,
Map<String, Object>
The values for the new Scope.
scopeValues
)

Method Summary

Modifier and TypeMethod and Description
public MdcObject
addMdcValue(String key, String value)

Add a key value pair to the MDC using the MDC manager.

public MdcObject
addMdcValue(String key, String value, boolean
if true, this key value pair will be automatically removed from the MDC when this scope exits. If there is not a demonstrable reason for setting this parameter to false then it should be set to true.
removeWhenScopeExits
)

Add a key value pair to the MDC using the MDC manager.

public MdcObject
addMdcValue(String key, Map<String, Object> value)

Add a key value pair to the MDC using the MDC manager.

public MdcObject
addMdcValue(String key, Map<String, Object> value, boolean
if true, this key value pair will be automatically removed from the MDC when this scope exits. If there is not a demonstrable reason for setting this parameter to false then it should be set to true.
removeWhenScopeExits
)

Add a key value pair to the MDC using the MDC manager.

public MdcObject
addMdcValue(String key, CustomMdcObject customMdcObject)

Add a key value pair to the MDC using the MDC manager.

public MdcObject
addMdcValue(String key, CustomMdcObject customMdcObject, boolean
if true, this key value pair will be automatically removed from the MDC when this scope exits. If there is not a demonstrable reason for setting this parameter to false then it should be set to true.
removeWhenScopeExits
)

Add a key value pair to the MDC using the MDC manager.

public static void
child(Map<String, Object> scopeValues, Scope.ScopedRunner<T> runner)

Creates a new scope that is a child of this scope.

public static <ReturnType> ReturnType
child(Map<String, Object> scopeValues, Scope.ScopedRunnerWithReturn<ReturnType> runner)

Creates a new scope that is a child of this scope.

public static void
child(LiquibaseListener listener, Scope.ScopedRunner<T> runner)

Creates a new child scope that includes the given LiquibaseListener.

public static void
child(LiquibaseListener listener, Map<String, Object> scopeValues, Scope.ScopedRunner<T> runner)

public static <T> T
child(LiquibaseListener listener, Map<String, Object> scopeValues, Scope.ScopedRunnerWithReturn<T> runner)

public static void
child(String newValueKey, Object newValue, Scope.ScopedRunner<T> runner)

Creates a new scope that is a child of this scope.

public static void
child(Enum<E extends Enum<E>> newValueKey, Object newValue, Scope.ScopedRunner<T> runner)

public String
public static String
enter(Map<String, Object> scopeValues)

Convenience version of enter(LiquibaseListener, Map) with no LiquibaseListener

public static String

Returns:

Returns the scopeId to pass to to exit(String)
enter
(LiquibaseListener listener, Map<String, Object> scopeValues)

Creates a new scope without passing a ScopedRunner.

public static void
exit(String
The id of the scope to exit. Throws an exception if the name does not match the current scope.
scopeId
)

Exits the scope started with enter(LiquibaseListener, Map)

private String
public synchronized <T> T
get(Enum<E extends Enum<E>> key, Class<T> type)

public <T> T
get(Enum<E extends Enum<E>> key, T defaultValue)

public <T> T
get(String key, Class<T> type)

Return the value associated with the given key in this scope or any parent scope.

public synchronized <T> T
get(String key, T defaultValue)

Return the value associated with the given key in this scope or any parent scope.

public ChecksumVersion
public ClassLoader
public ClassLoader
getClassLoader(boolean fallbackToContextClassLoader)

public static Scope
public Database
public Charset
public String
public <T extends LiquibaseListener> Collection<T>
getListeners(Class<T> type)

Returns LiquibaseListeners defined in this scope and/or all its parents that are of the given type.

public Logger
getLog(Class<T> clazz)

public MdcManager
getMdcManager()

Get the current MDC manager.

public Scope
getParent()

Returns the parent scope to this scope.

public ResourceAccessor
public ServiceLocator
public synchronized <T extends SingletonObject> T
getSingleton(Class<T> type)

Looks up the singleton object of the given type.

public UIService
public boolean
has(String key)

Return true if the given key is defined.

public boolean
has(Enum<E extends Enum<E>> key)

Return true if the given key is defined.

public boolean

Returns:

true if there is an existing key, false otherwise
isMdcKeyPresent
(String key)

Check if the provided mdc key is present

private void
removeMdcObjectWhenScopeExits(boolean removeWhenScopeExits, MdcObject mdcObject)

public static void
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

addedMdcEntriesback to summary
private static final Map<String, List<MdcObject>> addedMdcEntries
JAVA_PROPERTIESback to summary
public static final String JAVA_PROPERTIES
listenerback to summary
private LiquibaseListener listener
parentback to summary
private final Scope parent
scopeIdback to summary
private final String scopeId
Annotations
@lombok.Getter
scopeManagerback to summary
private static ScopeManager scopeManager
valuesback to summary
private final SmartMap values

Constructor Detail

Scopeback to summary
private Scope()

Creates a new "root" scope. Defaults resourceAccessor to ClassLoaderResourceAccessor. Defaults serviceLocator to StandardServiceLocator

Scopeback to summary
protected Scope(Scope parent, Map<String, Object> scopeValues)
Parameters
parent:Scope

The new Scopes parent in the hierarchy of Scopes, not null.

scopeValues:Map<String, Object>

The values for the new Scope.

Method Detail

addMdcValueback to summary
public MdcObject addMdcValue(String key, String value)

Add a key value pair to the MDC using the MDC manager. This key value pair will be automatically removed from the MDC when this scope exits.

addMdcValueback to summary
public MdcObject addMdcValue(String key, String value, boolean removeWhenScopeExits)

Add a key value pair to the MDC using the MDC manager.

Parameters
removeWhenScopeExits:boolean

if true, this key value pair will be automatically removed from the MDC when this scope exits. If there is not a demonstrable reason for setting this parameter to false then it should be set to true.

addMdcValueback to summary
public MdcObject addMdcValue(String key, Map<String, Object> value)

Add a key value pair to the MDC using the MDC manager. This key value pair will be automatically removed from the MDC when this scope exits.

addMdcValueback to summary
public MdcObject addMdcValue(String key, Map<String, Object> value, boolean removeWhenScopeExits)

Add a key value pair to the MDC using the MDC manager.

Parameters
removeWhenScopeExits:boolean

if true, this key value pair will be automatically removed from the MDC when this scope exits. If there is not a demonstrable reason for setting this parameter to false then it should be set to true.

addMdcValueback to summary
public MdcObject addMdcValue(String key, CustomMdcObject customMdcObject)

Add a key value pair to the MDC using the MDC manager. This key value pair will be automatically removed from the MDC when this scope exits.

addMdcValueback to summary
public MdcObject addMdcValue(String key, CustomMdcObject customMdcObject, boolean removeWhenScopeExits)

Add a key value pair to the MDC using the MDC manager.

Parameters
removeWhenScopeExits:boolean

if true, this key value pair will be automatically removed from the MDC when this scope exits. If there is not a demonstrable reason for setting this parameter to false then it should be set to true.

childback to summary
public static void child(Map<String, Object> scopeValues, Scope.ScopedRunner<T> runner) throws Exception

Creates a new scope that is a child of this scope.

childback to summary
public static <ReturnType> ReturnType child(Map<String, Object> scopeValues, Scope.ScopedRunnerWithReturn<ReturnType> runner) throws Exception

Creates a new scope that is a child of this scope.

childback to summary
public static void child(LiquibaseListener listener, Scope.ScopedRunner<T> runner) throws Exception

Creates a new child scope that includes the given LiquibaseListener. You cannot unassign a listener, they simply fall out of scope when the Scope does.

See Also
getListeners(Class)
childback to summary
public static void child(LiquibaseListener listener, Map<String, Object> scopeValues, Scope.ScopedRunner<T> runner) throws Exception
childback to summary
public static <T> T child(LiquibaseListener listener, Map<String, Object> scopeValues, Scope.ScopedRunnerWithReturn<T> runner) throws Exception
childback to summary
public static void child(String newValueKey, Object newValue, Scope.ScopedRunner<T> runner) throws Exception

Creates a new scope that is a child of this scope.

childback to summary
public static void child(Enum<E extends Enum<E>> newValueKey, Object newValue, Scope.ScopedRunner<T> runner) throws Exception
describeback to summary
public String describe()
enterback to summary
public static String enter(Map<String, Object> scopeValues) throws Exception

Convenience version of enter(LiquibaseListener, Map) with no LiquibaseListener

enterback to summary
public static String enter(LiquibaseListener listener, Map<String, Object> scopeValues) throws Exception

Creates a new scope without passing a ScopedRunner. This mainly exists for tests where you have a setup/cleanup method pattern. The recommended way to create Scopes is the "child" methods. When done with the scope, call exit(String)

Returns:String

Returns the scopeId to pass to to exit(String)

exitback to summary
public static void exit(String scopeId) throws Exception

Exits the scope started with enter(LiquibaseListener, Map)

Parameters
scopeId:String

The id of the scope to exit. Throws an exception if the name does not match the current scope.

generateScopeIdback to summary
private String generateScopeId()
getback to summary
public synchronized <T> T get(Enum<E extends Enum<E>> key, Class<T> type)
getback to summary
public <T> T get(Enum<E extends Enum<E>> key, T defaultValue)
getback to summary
public <T> T get(String key, Class<T> type)

Return the value associated with the given key in this scope or any parent scope. The value is converted to the given type if necessary using liquibase.util.ObjectUtil#convert(Object, Class). Returns null if key is not defined in this or any parent scopes.

getback to summary
public synchronized <T> T get(String key, T defaultValue)

Return the value associated with the given key in this scope or any parent scope. If the value is not defined, the passed defaultValue is returned. The value is converted to the given type if necessary using liquibase.util.ObjectUtil#convert(Object, Class).

getChecksumVersionback to summary
public ChecksumVersion getChecksumVersion()
getClassLoaderback to summary
public ClassLoader getClassLoader()
getClassLoaderback to summary
public ClassLoader getClassLoader(boolean fallbackToContextClassLoader)
getCurrentScopeback to summary
public static Scope getCurrentScope()
getDatabaseback to summary
public Database getDatabase()
getFileEncodingback to summary
public Charset getFileEncoding()
getLineSeparatorback to summary
public String getLineSeparator()
getListenersback to summary
public <T extends LiquibaseListener> Collection<T> getListeners(Class<T> type)

Returns LiquibaseListeners defined in this scope and/or all its parents that are of the given type.

getLogback to summary
public Logger getLog(Class<T> clazz)
getMdcManagerback to summary
public MdcManager getMdcManager()

Get the current MDC manager.

getParentback to summary
public Scope getParent()

Returns the parent scope to this scope. Returns null if this is a root scope.

getResourceAccessorback to summary
public ResourceAccessor getResourceAccessor()
getServiceLocatorback to summary
public ServiceLocator getServiceLocator()
getSingletonback to summary
public synchronized <T extends SingletonObject> T getSingleton(Class<T> type)

Looks up the singleton object of the given type. If the singleton has not been created yet, it will be instantiated. The singleton is a singleton based on the root scope and the same object will be returned for all child scopes of the root.

getUIback to summary
public UIService getUI()
hasback to summary
public boolean has(String key)

Return true if the given key is defined.

hasback to summary
public boolean has(Enum<E extends Enum<E>> key)

Return true if the given key is defined.

isMdcKeyPresentback to summary
public boolean isMdcKeyPresent(String key)

Check if the provided mdc key is present

Returns:boolean

true if there is an existing key, false otherwise

Annotations
@Beta
removeMdcObjectWhenScopeExitsback to summary
private void removeMdcObjectWhenScopeExits(boolean removeWhenScopeExits, MdcObject mdcObject)
setScopeManagerback to summary
public static void setScopeManager(ScopeManager scopeManager)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
liquibase back to summary

public final Enum Scope.Attr

extends Enum<Scope.Attr>
Class Inheritance

Enumeration containing standard attributes. Normally use methods like convenience getResourceAccessor() or getDatabase()

Field Summary

Modifier and TypeField and Description
public static final Scope.Attr
public static final Scope.Attr
public static final Scope.Attr
public static final Scope.Attr
public static final Scope.Attr
public static final Scope.Attr
public static final Scope.Attr
public static final Scope.Attr
public static final Scope.Attr
public static final Scope.Attr
public static final Scope.Attr
public static final Scope.Attr
public static final Scope.Attr
public static final Scope.Attr
public static final Scope.Attr
public static final Scope.Attr
public static final Scope.Attr

Constructor Summary

AccessConstructor and Description
private
Attr()

Method Summary

Modifier and TypeMethod and Description
public static Scope.Attr
public static Scope.Attr[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

changeLogHistoryServiceback to summary
public static final Scope.Attr changeLogHistoryService
changeSetback to summary
public static final Scope.Attr changeSet
checksumVersionback to summary
public static final Scope.Attr checksumVersion
classLoaderback to summary
public static final Scope.Attr classLoader
databaseback to summary
public static final Scope.Attr database
databaseChangeLogback to summary
public static final Scope.Attr databaseChangeLog
executeModeback to summary
public static final Scope.Attr executeMode
fileEncodingback to summary
public static final Scope.Attr fileEncoding
latestChecksumVersionback to summary
public static final Scope.Attr latestChecksumVersion
lineSeparatorback to summary
public static final Scope.Attr lineSeparator
lockServiceback to summary
public static final Scope.Attr lockService
logServiceback to summary
public static final Scope.Attr logService
osgiPlatformback to summary
public static final Scope.Attr osgiPlatform
quotingStrategyback to summary
public static final Scope.Attr quotingStrategy
resourceAccessorback to summary
public static final Scope.Attr resourceAccessor
serviceLocatorback to summary
public static final Scope.Attr serviceLocator
uiback to summary
public static final Scope.Attr ui

Constructor Detail

Attrback to summary
private Attr()

Method Detail

valueOfback to summary
public static Scope.Attr valueOf(String name)
valuesback to summary
public static Scope.Attr[] values()
liquibase back to summary

public Interface Scope.ScopedRunner<T>


Method Summary

Modifier and TypeMethod and Description
public void
run()

Method Detail

runback to summary
public void run() throws Exception
liquibase back to summary

public Interface Scope.ScopedRunnerWithReturn<T>


Method Summary

Modifier and TypeMethod and Description
public T
run()

Method Detail

runback to summary
public T run() throws Exception