Package alpine.server.upgrade
Class UpgradeMetaProcessor
java.lang.Object
alpine.server.upgrade.UpgradeMetaProcessor
- All Implemented Interfaces:
Closeable,AutoCloseable
This class determines what upgrades (if any) have already been executed against the current database and
documents upgrades that are being installed so that an audit trail of the execution history is maintained.
- Since:
- 1.2.0
- Author:
- Steve Springett
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new UpgradeMetaProcessor object along with a new SQL Connection object.UpgradeMetaProcessor(Connection connection) Constructs a new UpgradeMetaProcessor object -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closing a Connection object should only be done when this class creates the Connection and not when a Connection is passed to this objects constructor.Retrieves the current schema version documented in the database.booleanhasUpgradeRan(Class<? extends UpgradeItem> upgradeClass) Determines if the specified upgrade already has a record of being executed previously or not.voidinstallUpgrade(Class<? extends UpgradeItem> upgradeClass, long startTime, long endTime) Documents a record in the database for the specified class indicating it has been executed.voidupdateSchemaVersion(VersionComparator version) Updates the schema version in the database.
-
Constructor Details
-
UpgradeMetaProcessor
Constructs a new UpgradeMetaProcessor object- Parameters:
connection- a SQL Connection object- Since:
- 1.2.0
-
UpgradeMetaProcessor
Constructs a new UpgradeMetaProcessor object along with a new SQL Connection object.- Throws:
UpgradeException- when an error occurs creating a Connection object- Since:
- 1.8.0
-
-
Method Details
-
hasUpgradeRan
Determines if the specified upgrade already has a record of being executed previously or not.- Parameters:
upgradeClass- the class to check fi an upgrade has previously executed- Returns:
- true if already executed, false if not
- Throws:
SQLException- a SQLException- Since:
- 1.2.0
-
installUpgrade
public void installUpgrade(Class<? extends UpgradeItem> upgradeClass, long startTime, long endTime) throws SQLException Documents a record in the database for the specified class indicating it has been executed.- Parameters:
upgradeClass- the name of the upgrade classstartTime- the time (in millis) of the executionendTime- the time (in millis) the execution completed- Throws:
SQLException- a SQLException- Since:
- 1.2.0
-
getSchemaVersion
Retrieves the current schema version documented in the database.- Returns:
- A VersionComparator of the schema version
- Since:
- 1.2.0
-
updateSchemaVersion
Updates the schema version in the database.- Parameters:
version- the version to set the schema to- Throws:
SQLException- a SQLException- Since:
- 1.2.0
-
close
public void close()Closing a Connection object should only be done when this class creates the Connection and not when a Connection is passed to this objects constructor.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-