SolarMetric Kodo JDO 3.2.4 generated on January 7 2005

kodo.runtime
Interface LockManager

All Superinterfaces:
com.solarmetric.util.Closeable
All Known Subinterfaces:
JDBCLockManager
All Known Implementing Classes:
AbstractLockManager

public interface LockManager
extends com.solarmetric.util.Closeable

Handles obtaining and releasing locks on objects. The lock manager generally does not have to worry about synchronization, as the persistence manager is responsible for synchronizing the calls it makes to the lock manager.


Method Summary
 void beginTransaction()
          Notification that a transaction is beginning.
 void close()
          Free any resources.
 void endTransaction()
          Notification that the current transaction has ended.
 int getLockLevel(KodoStateManager sm)
          Return the lock level of the specified instance, or KodoPersistenceManager.LOCK_NONE if not locked.
 void lock(KodoStateManager sm, int level, int timeout, Object context)
          Obtain a lock on the specified object.
 void lockAll(Collection sms, int level, int timeout, Object context)
          Obtain locks on the specified objects.
 void release(KodoStateManager sm)
          Release the lock on the given object.
 void setPersistenceManager(KodoPersistenceManager kpm)
          Set the persistence manager this lock manager is associated with.
 

Method Detail

setPersistenceManager

public void setPersistenceManager(KodoPersistenceManager kpm)
Set the persistence manager this lock manager is associated with. This will be invoked in the lock manager before any other methods are called.

getLockLevel

public int getLockLevel(KodoStateManager sm)
Return the lock level of the specified instance, or KodoPersistenceManager.LOCK_NONE if not locked.

lock

public void lock(KodoStateManager sm,
                 int level,
                 int timeout,
                 Object context)
Obtain a lock on the specified object. This method may be called when a user explicitly locks an object, and is also called automatically for every object accessed during a transaction. The implementation must track already-locked objects, and must be optimized to return quickly when the given object does not need additional locking. The lock manager might use the state manager's lock object for bookkeeping information.
Parameters:
sm - the object to lock
level - one of the lock constants defined in KodoPersistenceManager, or a custom level
timeout - the timeout in milliseconds, or a negative number for no timeout
context - the context information passed from the back end store manager to the persistence manager, if any; lock managers specific to a certain back end may be able to take advantage of this; others should ignore it
Throws:
LockTimedOutException - if a lock cannot be obtained in the given number of milliseconds
See Also:
KodoStateManager.setLock(java.lang.Object)

lockAll

public void lockAll(Collection sms,
                    int level,
                    int timeout,
                    Object context)
Obtain locks on the specified objects.
See Also:
lock(kodo.runtime.KodoStateManager, int, int, java.lang.Object)

release

public void release(KodoStateManager sm)
Release the lock on the given object. This method will be called automatically for each state manager with a lock object set on transaction completion, just before the call to endTransaction(). The lock manager should null the state manager's lock object. Note that some state manager may be garbage collected during a transaction; thus lock managers cannot rely on this method being called for every state manager.
See Also:
KodoStateManager.setLock(java.lang.Object)

beginTransaction

public void beginTransaction()
Notification that a transaction is beginning. Locks are only obtained within transactions, so an implementation might use this method to initialize bookkeeping datastructures, etc.

endTransaction

public void endTransaction()
Notification that the current transaction has ended. Clear all datastructures, release any left over locks, etc.

close

public void close()
Free any resources.
Specified by:
close in interface com.solarmetric.util.Closeable

SolarMetric Kodo JDO 3.2.4 generated on January 7 2005

Copyright 2001,2002 SolarMetric, Inc. All Rights Reserved.