Project Wonder 5.0

er.extensions.migration
Class ERXJDBCMigrationLock

java.lang.Object
  extended by er.extensions.migration.ERXJDBCMigrationLock
All Implemented Interfaces:
IERXMigrationLock

public class ERXJDBCMigrationLock
extends java.lang.Object
implements IERXMigrationLock

JDBC implementation of the migration lock.

Author:
mschrag
Properties
er.migration.JDBC.dbUpdaterTableName the name of the db update version table (defaults to _DBUpdater)
           
er.migration.createTablesIfNecessary if true, the tables and model rows will be created automatically. *ONLY SET THIS IF YOU ARE RUNNING IN DEVELOPMENT MODE OR WITH A SINGLE INSTANCE*. If you are running multiple instances, the instances will not be able to acquire locks properly and you may end up with multiple instances attempting to create lock tables and/or failing to startup properly.
           
.InitialMigrationVersion the starting version number (in case you are retrofitting a project with migrations)
           

Field Summary
static org.apache.log4j.Logger log
           
 
Constructor Summary
ERXJDBCMigrationLock()
           
 
Method Summary
 boolean _tryLock(com.webobjects.eoaccess.EOAdaptorChannel channel, com.webobjects.eoaccess.EOModel model, java.lang.String lockOwnerName, boolean createTableIfMissing)
           
protected  boolean createIfMissing()
           
protected  java.lang.String dbUpdaterCreateStatement(com.webobjects.eoaccess.EOModel model, com.webobjects.jdbcadaptor.JDBCAdaptor adaptor)
           
protected  com.webobjects.eoaccess.EOModel dbUpdaterModelWithModel(com.webobjects.eoaccess.EOModel model, com.webobjects.jdbcadaptor.JDBCAdaptor adaptor)
           
protected  int initialVersionForModel(com.webobjects.eoaccess.EOModel model)
           
protected  java.lang.String migrationTableName(com.webobjects.jdbcadaptor.JDBCAdaptor adaptor)
          Adds support for overriding the name of the db updater table on a per-database product level.
 void setVersionNumber(com.webobjects.eoaccess.EOAdaptorChannel channel, com.webobjects.eoaccess.EOModel model, int versionNumber)
          Sets the current version number of the named model.
 boolean tryLock(com.webobjects.eoaccess.EOAdaptorChannel channel, com.webobjects.eoaccess.EOModel model, java.lang.String lockOwnerName)
          Attempts to retrieve a lock on the migration process for the named model.
 void unlock(com.webobjects.eoaccess.EOAdaptorChannel channel, com.webobjects.eoaccess.EOModel model)
          Unlocks the given model.
 int versionNumber(com.webobjects.eoaccess.EOAdaptorChannel channel, com.webobjects.eoaccess.EOModel model)
          Returns the current version number of the named model.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

public static final org.apache.log4j.Logger log
Constructor Detail

ERXJDBCMigrationLock

public ERXJDBCMigrationLock()
Method Detail

migrationTableName

protected java.lang.String migrationTableName(com.webobjects.jdbcadaptor.JDBCAdaptor adaptor)
Adds support for overriding the name of the db updater table on a per-database product level.

Parameters:
adaptor - the current jdbc adaptor
Returns:
the name of the dbupdater table

createIfMissing

protected boolean createIfMissing()

tryLock

public boolean tryLock(com.webobjects.eoaccess.EOAdaptorChannel channel,
                       com.webobjects.eoaccess.EOModel model,
                       java.lang.String lockOwnerName)
Description copied from interface: IERXMigrationLock
Attempts to retrieve a lock on the migration process for the named model. A lockOwnerName is provided that provides a simple mechanism to recover from a stale lock. If the lock owner name passed in matches the current lock owner name, then the lock is acquired.

Specified by:
tryLock in interface IERXMigrationLock
Parameters:
channel - the adaptor channel associated with this process
model - the model to try to lock
lockOwnerName - the name of the lock owner
Returns:
true if the lock was acquired, false if it was not

_tryLock

public boolean _tryLock(com.webobjects.eoaccess.EOAdaptorChannel channel,
                        com.webobjects.eoaccess.EOModel model,
                        java.lang.String lockOwnerName,
                        boolean createTableIfMissing)

unlock

public void unlock(com.webobjects.eoaccess.EOAdaptorChannel channel,
                   com.webobjects.eoaccess.EOModel model)
Description copied from interface: IERXMigrationLock
Unlocks the given model. This should only be called if you acquired a lock with tryLock(..).

Specified by:
unlock in interface IERXMigrationLock
Parameters:
channel - the adaptor channel associated with this process
model - the model to unlock

versionNumber

public int versionNumber(com.webobjects.eoaccess.EOAdaptorChannel channel,
                         com.webobjects.eoaccess.EOModel model)
Description copied from interface: IERXMigrationLock
Returns the current version number of the named model.

Specified by:
versionNumber in interface IERXMigrationLock
Parameters:
channel - the adaptor channel associated with this process
model - the model to lookup version information on
Returns:
the current version number of the named model

setVersionNumber

public void setVersionNumber(com.webobjects.eoaccess.EOAdaptorChannel channel,
                             com.webobjects.eoaccess.EOModel model,
                             int versionNumber)
Description copied from interface: IERXMigrationLock
Sets the current version number of the named model.

Specified by:
setVersionNumber in interface IERXMigrationLock
Parameters:
channel - the adaptor channel associated with this process
model - the model to set version information on
versionNumber - the new version number

initialVersionForModel

protected int initialVersionForModel(com.webobjects.eoaccess.EOModel model)

dbUpdaterModelWithModel

protected com.webobjects.eoaccess.EOModel dbUpdaterModelWithModel(com.webobjects.eoaccess.EOModel model,
                                                                  com.webobjects.jdbcadaptor.JDBCAdaptor adaptor)

dbUpdaterCreateStatement

protected java.lang.String dbUpdaterCreateStatement(com.webobjects.eoaccess.EOModel model,
                                                    com.webobjects.jdbcadaptor.JDBCAdaptor adaptor)

Last updated: Tue, Feb 21, 2017 • 05:45 PM CET

Copyright © 2002 – 2007 Project Wonder.