org.jasig.portal.concurrency.locking
Class EntityLockImpl

java.lang.Object
  extended by org.jasig.portal.concurrency.locking.EntityLockImpl
All Implemented Interfaces:
IEntityLock

public class EntityLockImpl
extends java.lang.Object
implements IEntityLock

An implementation of IEntityLock. A lock is granted to a lockOwner for an entityType and entityKey. It guarantees some degree of exclusive access to the entity, depending on lockType and expirationTime.

Version:
$Revision: 1.7 $
Author:
Dan Ellentuck
See Also:
IEntityLock

Field Summary
private  java.lang.String entityKey
           
private  java.lang.Class entityType
           
private  java.util.Date expirationTime
           
private  java.lang.String lockOwner
           
private  int lockType
           
private  IEntityLockService service
           
 
Constructor Summary
protected EntityLockImpl(java.lang.Class newEntityType, java.lang.String newEntityKey, int newLockType, java.util.Date newExpirationTime, java.lang.String newLockOwner)
           
protected EntityLockImpl(java.lang.Class newEntityType, java.lang.String newEntityKey, int newLockType, java.util.Date newExpirationTime, java.lang.String newLockOwner, IEntityLockService newService)
           
 
Method Summary
 void convert(int newType)
          Delegate to the service.
 void convert(int newType, int duration)
          Delegate to the service.
 boolean equals(java.lang.Object obj)
           
protected  void expire()
           
protected  void finalize()
           
 java.lang.String getEntityKey()
           
 java.lang.Class getEntityType()
           
 java.util.Date getExpirationTime()
           
 java.lang.String getLockOwner()
          Could be the portal user or the framework or ...?
 int getLockType()
          See IEntityLockingService for a description of lock types.
protected  IEntityLockService getService()
           
 int hashCode()
          This method is supported primarily for hash tables, such as those provided in java.util.
 boolean isLocked()
          Answer if the lock is unexpired.
 boolean isValid()
          Delegate to the service.
 void release()
          Delegate to the service.
 void renew()
          Delegate to the service.
 void renew(int duration)
          Delegate to the service.
private  void setEntityKey(java.lang.String newEntityKey)
           
private  void setEntityType(java.lang.Class newEntityType)
           
(package private)  void setExpirationTime(java.util.Date newExpirationTime)
           
private  void setLockOwner(java.lang.String newLockOwner)
           
(package private)  void setLockType(int newLockType)
           
private  void setService(IEntityLockService newService)
           
 java.lang.String toString()
          Returns a String that represents the value of this object.
 
Methods inherited from class java.lang.Object
clone, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

entityType

private java.lang.Class entityType

entityKey

private java.lang.String entityKey

lockOwner

private java.lang.String lockOwner

expirationTime

private java.util.Date expirationTime

lockType

private int lockType

service

private IEntityLockService service
Constructor Detail

EntityLockImpl

protected EntityLockImpl(java.lang.Class newEntityType,
                         java.lang.String newEntityKey,
                         int newLockType,
                         java.util.Date newExpirationTime,
                         java.lang.String newLockOwner)

EntityLockImpl

protected EntityLockImpl(java.lang.Class newEntityType,
                         java.lang.String newEntityKey,
                         int newLockType,
                         java.util.Date newExpirationTime,
                         java.lang.String newLockOwner,
                         IEntityLockService newService)
Method Detail

convert

public void convert(int newType)
             throws LockingException
Delegate to the service.

Specified by:
convert in interface IEntityLock
Parameters:
newType - int
Throws:
LockingException - - if the conversion fails.

convert

public void convert(int newType,
                    int duration)
             throws LockingException
Delegate to the service.

Specified by:
convert in interface IEntityLock
Parameters:
newType - int
duration - int
Throws:
LockingException - - if the conversion fails.

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object
Parameters:
obj - the Object to compare with
Returns:
true if these Objects are equal; false otherwise.
See Also:
Hashtable

expire

protected void expire()

finalize

protected void finalize()
                 throws java.lang.Throwable
Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable

getEntityKey

public java.lang.String getEntityKey()
Specified by:
getEntityKey in interface IEntityLock
Returns:
java.lang.String

getEntityType

public java.lang.Class getEntityType()
Specified by:
getEntityType in interface IEntityLock
Returns:
java.lang.Class
See Also:
for known types.

getExpirationTime

public java.util.Date getExpirationTime()
Specified by:
getExpirationTime in interface IEntityLock
Returns:
java.util.Date

getLockOwner

public java.lang.String getLockOwner()
Could be the portal user or the framework or ...?

Specified by:
getLockOwner in interface IEntityLock
Returns:
java.lang.String

getLockType

public int getLockType()
See IEntityLockingService for a description of lock types.

Specified by:
getLockType in interface IEntityLock
Returns:
int

getService

protected IEntityLockService getService()
Returns:
org.jasig.portal.concurrency.locking.IEntityLockService

hashCode

public int hashCode()
This method is supported primarily for hash tables, such as those provided in java.util.

Overrides:
hashCode in class java.lang.Object
Returns:
an integer hash code for the receiver
See Also:
Hashtable

isLocked

public boolean isLocked()
Answer if the lock is unexpired.

Returns:
boolean

isValid

public boolean isValid()
                throws LockingException
Delegate to the service.

Specified by:
isValid in interface IEntityLock
Returns:
boolean
Throws:
LockingException

release

public void release()
             throws LockingException
Delegate to the service.

Specified by:
release in interface IEntityLock
Throws:
LockingException

renew

public void renew()
           throws LockingException
Delegate to the service.

Specified by:
renew in interface IEntityLock
Throws:
LockingException

renew

public void renew(int duration)
           throws LockingException
Delegate to the service.

Specified by:
renew in interface IEntityLock
Throws:
LockingException

setEntityKey

private void setEntityKey(java.lang.String newEntityKey)
Parameters:
newEntityKey -

setEntityType

private void setEntityType(java.lang.Class newEntityType)
Parameters:
newEntityType -

setExpirationTime

void setExpirationTime(java.util.Date newExpirationTime)
Parameters:
newExpirationTime -

setLockOwner

private void setLockOwner(java.lang.String newLockOwner)
Parameters:
newLockOwner -

setLockType

void setLockType(int newLockType)
Parameters:
newLockType -

setService

private void setService(IEntityLockService newService)
Parameters:
newService - org.jasig.portal.concurrency.locking.IEntityLockService

toString

public java.lang.String toString()
Returns a String that represents the value of this object.

Overrides:
toString in class java.lang.Object
Returns:
a string representation of the receiver