org.datanucleus.state.lock
Interface LockManager

All Known Implementing Classes:
LockManagerImpl

public interface LockManager

Interface defining a manager for locking of objects. There are currently two modes to a LockManager.

  1. Where the user has the object and wants it locking. In this case they provide the StateManager and we lock it (by a call to the datastore where appropriate).
  2. Where the user wants to do a find of an object with a particular id. In this case we register the identity as needing this lock level, and the datastore will be called to retrieve the object and will check back what lock level to use.


Field Summary
static short LOCK_MODE_NONE
          Lock mode representing no locking.
static short LOCK_MODE_OPTIMISTIC_READ
          Lock mode for optimistic reads.
static short LOCK_MODE_OPTIMISTIC_WRITE
          Lock mode for optimistic writes.
static short LOCK_MODE_PESSIMISTIC_READ
          Lock mode for pessimistic reads.
static short LOCK_MODE_PESSIMISTIC_WRITE
          Lock mode for pessimistic writes.
 
Method Summary
 void clear()
          Method to clear all settings of required lock level for object ids (mode 2).
 void close()
          Method to close the manager and release resources.
 short getLockMode(java.lang.Object id)
          Accessor for what locking should be applied to the object with the specified identity (mode 2).
 short getLockMode(StateManager sm)
          Accessor for the current lock mode for the object managed by the passed StateManager (mode 1).
 void lock(java.lang.Object id, short lockMode)
          Method to lock the object with the provided identity (mode 2).
 void lock(StateManager sm, short lockMode)
          Method to lock the object managed by the passed StateManager (mode 1).
 void unlock(StateManager sm)
          Method to unlock the object managed by the passed StateManager (mode 1).
 

Field Detail

LOCK_MODE_NONE

static final short LOCK_MODE_NONE
Lock mode representing no locking.

See Also:
Constant Field Values

LOCK_MODE_OPTIMISTIC_READ

static final short LOCK_MODE_OPTIMISTIC_READ
Lock mode for optimistic reads. Same as LOCK_MODE_OPTIMISTIC_WRITE for DataNucleus.

See Also:
Constant Field Values

LOCK_MODE_OPTIMISTIC_WRITE

static final short LOCK_MODE_OPTIMISTIC_WRITE
Lock mode for optimistic writes.

See Also:
Constant Field Values

LOCK_MODE_PESSIMISTIC_READ

static final short LOCK_MODE_PESSIMISTIC_READ
Lock mode for pessimistic reads. Same as LOCK_MODE_PESSIMISTIC_WRITE for DataNucleus.

See Also:
Constant Field Values

LOCK_MODE_PESSIMISTIC_WRITE

static final short LOCK_MODE_PESSIMISTIC_WRITE
Lock mode for pessimistic writes.

See Also:
Constant Field Values
Method Detail

lock

void lock(java.lang.Object id,
          short lockMode)
Method to lock the object with the provided identity (mode 2).

Parameters:
id - Identity of the object
lockMode - mode for locking

getLockMode

short getLockMode(java.lang.Object id)
Accessor for what locking should be applied to the object with the specified identity (mode 2).

Parameters:
id - The identity
Returns:
The lock mode to apply (NONE if nothing defined)

clear

void clear()
Method to clear all settings of required lock level for object ids (mode 2).


lock

void lock(StateManager sm,
          short lockMode)
Method to lock the object managed by the passed StateManager (mode 1).

Parameters:
sm - StateManager for the object
lockMode - mode for locking

unlock

void unlock(StateManager sm)
Method to unlock the object managed by the passed StateManager (mode 1).

Parameters:
sm - StateManager for the object

getLockMode

short getLockMode(StateManager sm)
Accessor for the current lock mode for the object managed by the passed StateManager (mode 1).

Parameters:
sm - StateManager for the object
Returns:
The lock mode

close

void close()
Method to close the manager and release resources.



Copyright © 2011. All Rights Reserved.