jconch.lock
Class SyncLogEqLock<OBJ_T>

java.lang.Object
  extended by jconch.lock.AbstractLogEqLock<OBJ_T,Object>
      extended by jconch.lock.SyncLogEqLock<OBJ_T>
Type Parameters:
OBJ_T - The type of object being processed by the lock.

public class SyncLogEqLock<OBJ_T>
extends AbstractLogEqLock<OBJ_T,Object>

This class should be used to implement logically equivalent locks.

Currently, Java has a major failing in its synchronization mechanism. The synchronize keyword operates at the reference level, which means that two different but logically equivalent objects can enter the same synchronized block concurrently. Since POJOs are often generated such that they are logically equivalent, but referentially different, this is a problem.

A single instance of this class will provide the same Object instance for each logically equivalent object passed in.

Author:
Robert Fischer

Constructor Summary
SyncLogEqLock()
          Default constructor.
 
Method Summary
protected  Object createNewLock()
          Implementation of the "lock" that is created.
static SyncLogEqLock<Object> getGlobalInstance()
          Provides the same instance of this class every time it is called.
 
Methods inherited from class jconch.lock.AbstractLogEqLock
getLock, hasLockFor
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SyncLogEqLock

public SyncLogEqLock()
Default constructor.

Method Detail

getGlobalInstance

public static SyncLogEqLock<Object> getGlobalInstance()
Provides the same instance of this class every time it is called. To be used when a universally-valid global instance is required.

Returns:
The global instance of this class.

createNewLock

protected Object createNewLock()
Description copied from class: AbstractLogEqLock
Implementation of the "lock" that is created.

Specified by:
createNewLock in class AbstractLogEqLock<OBJ_T,Object>
Returns:
A newly-instantiated Object.