Package com.arjuna.ats.txoj
Class Lock
java.lang.Object
com.arjuna.ats.arjuna.StateManager
com.arjuna.ats.txoj.Lock
Instances of this class (or derived user classes) are used when trying to set
a lock. The default implementation provides a single-write/multiple-reader
policy. However, by overridding the appropriate methods, other, type-specific
concurrency control locks can be implemented.
- Since:
- JTS 1.0.
- Version:
- $Id: Lock.java 2342 2006-03-30 13:06:17Z $
- Author:
- Mark Little (mark@arjuna.com)
-
Field Summary
Fields inherited from class com.arjuna.ats.arjuna.StateManager
modifyingActions, objectModel, objectUid, synchronizationLock, usingActions -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal voidchangeHierarchy(ActionHierarchy newOwner) Change the transaction hierarchy associated with the lock to that provided.booleanconflictsWith(Lock otherLock) Implementation of Lock conflict check.booleanAre the two locks equal?booleanOverrides Object.equals()voidfinalize()General clean up as Lock is deleted.final ActionHierarchyfinal Uidfinal intprotected LockgetLink()Get the next lock in the chain.final intbooleanDoes this lock imply a modification of the object it is applied to? For example, a READ lock would return false, but a WRITE lock would return true.voidprint(PrintWriter strm) functions inherited from StateManagerfinal voidPropagate the lock.booleanrestore_state(InputObjectState os, int ot) Carefully restore the state of a Lock.booleansave_state(OutputObjectState os, int ot) Save the state of a lock object.protected voidSet the next lock in the chain.toString()Overrides Object.toString()type()Overrides StateManager.type()Methods inherited from class com.arjuna.ats.arjuna.StateManager
activate, activate, cleanup, createLists, deactivate, deactivate, deactivate, destroy, disable, forgetAction, get_uid, getCreationTimeMillis, getMutex, getObjectModel, getStore, getStoreRoot, loadObjectState, lockMutex, modified, objectType, packHeader, persist, rememberAction, setStatus, setupStore, setupStore, setupStore, status, terminate, tryLockMutex, unlockMutex, unpackHeader
-
Constructor Details
-
Lock
public Lock()Create a new lock. -
Lock
public Lock(int lm) Create a new Lock object and initialise it. Mode is based upon argument. The value of BasicAction.Current determines the values of the remainder of the fields. If there is no action running the owner field is set to be the application uid created when the application starts. -
Lock
This is used when re-initialising a Lock after retrieval from the object store.
-
-
Method Details
-
finalize
General clean up as Lock is deleted. -
getLockMode
public final int getLockMode()- Returns:
- the mode this lock is currently in, e.g.,
LockMode.READ.
-
getCurrentOwner
- Returns:
- the identity of the lock's current owner (the transaction id).
-
getAllOwners
- Returns:
- the transaction hierarchy associated with this lock.
-
getCurrentStatus
public final int getCurrentStatus()- Returns:
- the lock's current status.
-
changeHierarchy
Change the transaction hierarchy associated with the lock to that provided. -
propagate
public final void propagate()Propagate the lock. -
modifiesObject
public boolean modifiesObject()Does this lock imply a modification of the object it is applied to? For example, a READ lock would return false, but a WRITE lock would return true.- Returns:
trueif this lock implies the object's state will be modified,falseotherwise.
-
conflictsWith
Implementation of Lock conflict check. Returns TRUE if there is conflict FALSE otherwise. Does not take account of relationship in the atomic action hierarchy since this is a function of LockManager.- Returns:
trueif this lock conflicts with the parameter,falseotherwise.
-
equals
Overrides Object.equals() -
equals
Are the two locks equal?- Returns:
trueif the locks are equal,falseotherwise.
-
toString
Overrides Object.toString() -
print
functions inherited from StateManager- Overrides:
printin classStateManager
-
restore_state
Carefully restore the state of a Lock.- Overrides:
restore_statein classStateManager- Returns:
trueif successful,falseotherwise.
-
save_state
Save the state of a lock object.- Overrides:
save_statein classStateManager- Returns:
trueif successful,falseotherwise.
-
type
Overrides StateManager.type()- Overrides:
typein classStateManager
-
getLink
Get the next lock in the chain. -
setLink
Set the next lock in the chain.
-