Package liquibase.snapshot.jvm
Class JdbcSnapshotGenerator
- java.lang.Object
-
- liquibase.snapshot.jvm.JdbcSnapshotGenerator
-
- All Implemented Interfaces:
SnapshotGenerator
- Direct Known Subclasses:
CatalogSnapshotGenerator
,ColumnSnapshotGenerator
,DataSnapshotGenerator
,ForeignKeySnapshotGenerator
,IndexSnapshotGenerator
,PrimaryKeySnapshotGenerator
,SchemaSnapshotGenerator
,SequenceSnapshotGenerator
,TableSnapshotGenerator
,UniqueConstraintSnapshotGenerator
,ViewSnapshotGenerator
public abstract class JdbcSnapshotGenerator extends Object implements SnapshotGenerator
-
-
Field Summary
-
Fields inherited from interface liquibase.snapshot.SnapshotGenerator
PRIORITY_ADDITIONAL, PRIORITY_DATABASE, PRIORITY_DEFAULT, PRIORITY_NONE
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
JdbcSnapshotGenerator(Class<? extends DatabaseObject> defaultFor)
protected
JdbcSnapshotGenerator(Class<? extends DatabaseObject> defaultFor, Class<? extends DatabaseObject>[] addsTo)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
addStatusListener(DiffStatusListener listener)
Class<? extends DatabaseObject>[]
addsTo()
When snapshotting a certain object type (e.g.protected abstract void
addTo(DatabaseObject foundObject, DatabaseSnapshot snapshot)
protected String
cleanNameFromDatabase(String objectName, Database database)
protected String[]
getDatabaseCatalogNames(Database database)
Fetches an array of Strings with the catalog names in the database.int
getPriority(Class<? extends DatabaseObject> objectType, Database database)
Inquire if this SnapshotGenerator is capable of snapshotting objects of type objectType (e.g.Class<? extends SnapshotGenerator>[]
replaces()
Returns classes (and superclasses) that this SnapshotGenerator replaces.protected boolean
shouldAddTo(Class<? extends DatabaseObject> databaseObjectType, DatabaseSnapshot snapshot)
DatabaseObject
snapshot(DatabaseObject example, DatabaseSnapshot snapshot, SnapshotGeneratorChain chain)
Commands the SnapshotGenerator to create a snapshot (a representation of a database object in Java object form) of a specific database object.protected abstract DatabaseObject
snapshotObject(DatabaseObject example, DatabaseSnapshot snapshot)
protected void
updateListeners(String message)
-
-
-
Constructor Detail
-
JdbcSnapshotGenerator
protected JdbcSnapshotGenerator(Class<? extends DatabaseObject> defaultFor)
-
JdbcSnapshotGenerator
protected JdbcSnapshotGenerator(Class<? extends DatabaseObject> defaultFor, Class<? extends DatabaseObject>[] addsTo)
-
-
Method Detail
-
getPriority
public int getPriority(Class<? extends DatabaseObject> objectType, Database database)
Description copied from interface:SnapshotGenerator
Inquire if this SnapshotGenerator is capable of snapshotting objects of type objectType (e.g. Table, Index, View etc.) in the DBMS database (e.g. Oracle, Postgres, HyperSQL etc.) A return priority of > 0 will be interpreted as capable. The highest priority for an objectType-database combination wins.- Specified by:
getPriority
in interfaceSnapshotGenerator
- Parameters:
objectType
- The object type we are asked to snapshotdatabase
- The DBMS for which the snapshotting should be done- Returns:
- An integer of PRIORITY_... constants indicating our capability and willingness to snapshot
-
addsTo
public Class<? extends DatabaseObject>[] addsTo()
Description copied from interface:SnapshotGenerator
When snapshotting a certain object type (e.g. a table), different types of objects might be discovered in the process. (TODO: Which ones? Needs a more precise description.)- Specified by:
addsTo
in interfaceSnapshotGenerator
- Returns:
- an array of classes that this SnapshotGenerator might return upon snapshotting a given DatabaseObject type.
-
snapshot
public DatabaseObject snapshot(DatabaseObject example, DatabaseSnapshot snapshot, SnapshotGeneratorChain chain) throws DatabaseException, InvalidExampleException
Description copied from interface:SnapshotGenerator
Commands the SnapshotGenerator to create a snapshot (a representation of a database object in Java object form) of a specific database object.- Specified by:
snapshot
in interfaceSnapshotGenerator
- Parameters:
example
- The object we should try to snapshotsnapshot
- The Snapshot object representing the result of the snapshot operations so farchain
- A list of other SnapshotGenerators that might be asked to try the same- Returns:
- An object of type T if our snapshot attempt is successful
- Throws:
DatabaseException
- If an operation on the database failsInvalidExampleException
- If, for some reason, we cannot work on the example object (ambiguous naming etc.)
-
shouldAddTo
protected boolean shouldAddTo(Class<? extends DatabaseObject> databaseObjectType, DatabaseSnapshot snapshot)
-
replaces
public Class<? extends SnapshotGenerator>[] replaces()
Description copied from interface:SnapshotGenerator
Returns classes (and superclasses) that this SnapshotGenerator replaces. Return null or empty array to not affect the SnapshotGeneratorChain.- Specified by:
replaces
in interfaceSnapshotGenerator
-
snapshotObject
protected abstract DatabaseObject snapshotObject(DatabaseObject example, DatabaseSnapshot snapshot) throws DatabaseException, InvalidExampleException
-
addTo
protected abstract void addTo(DatabaseObject foundObject, DatabaseSnapshot snapshot) throws DatabaseException, InvalidExampleException
-
addStatusListener
public void addStatusListener(DiffStatusListener listener)
-
updateListeners
protected void updateListeners(String message)
-
getDatabaseCatalogNames
protected String[] getDatabaseCatalogNames(Database database) throws SQLException, DatabaseException
Fetches an array of Strings with the catalog names in the database.- Parameters:
database
- The database from which to get the schema names- Returns:
- An array of catalog name Strings (May be an empty array)
- Throws:
SQLException
- propagated java.sql.SQLExceptionDatabaseException
- if a different problem occurs during the DBMS-specific code
-
-