org.exolab.castor.persist
Class TypeInfo

java.lang.Object
  extended by org.exolab.castor.persist.TypeInfo

public final class TypeInfo
extends Object

Provides lock and cache about all the objects of a specific type. This information includes lifecycle interceptor requesting notification about activities that affect an object.

Version:
$Revision: 9042 $ $Date: 2011-08-16 18:41:15 +0200 (Di, 16 Aug 2011) $
Author:
Assaf Arkin, Thomas Yip, Bruce Snyder

Constructor Summary
TypeInfo(Cache<OID,CacheEntry> cache)
          Constructor for creating class info.
 
Method Summary
 ObjectLock acquire(OID oid, TransactionContext tx, LockAction lockAction, int timeout)
          Acquire the object lock for transaction.
 ObjectLock assure(OID oid, TransactionContext tx, boolean write)
          Reassure the lock which have been successfully acquired by the transaction.
 void closeCache()
          Life-cycle method to allow shutdown of cache instances.
 ObjectLock delete(OID oid, TransactionContext tx)
          Delete the object lock.
 void dumpCache(String name)
          Dump all objects in cache and lock to output.
 void expireCache()
          Expire all objects of this class from the cache.
 boolean isCached(OID oid)
          Indicates whether an object with the specified identifier is currently cached.
 boolean isLocked(OID oid)
          Indicates whether an object with the specified OID is currently locked.
 ObjectLock release(OID oid, TransactionContext tx)
          Release the object lock.
 ObjectLock rename(OID orgoid, OID newoid, TransactionContext tx)
          Move the locked object from one OID to another OID for transaction.
 ObjectLock upgrade(OID oid, TransactionContext tx, int timeout)
          Upgrade the lock to write lock.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TypeInfo

public TypeInfo(Cache<OID,CacheEntry> cache)
Constructor for creating class info.

Parameters:
cache - The LRU which may be used to store and dispose freed ObjectLock.
Method Detail

closeCache

public void closeCache()
Life-cycle method to allow shutdown of cache instances.


dumpCache

public void dumpCache(String name)
Dump all objects in cache and lock to output.

Parameters:
name - the class's full name

expireCache

public void expireCache()
Expire all objects of this class from the cache.


acquire

public ObjectLock acquire(OID oid,
                          TransactionContext tx,
                          LockAction lockAction,
                          int timeout)
                   throws LockNotGrantedException
Acquire the object lock for transaction. After this method is called, user must call ObjectLock.confirm(TransactionContext, boolean) exactly once.

Parameters:
oid - The OID of the lock.
tx - The context of the transaction to acquire lock.
lockAction - The initial action to be performed on the lock.
timeout - The time limit to acquire the lock.
Returns:
The object lock for the OID within this transaction context.
Throws:
LockNotGrantedException - Timeout or deadlock or object deleted occurred attempting to acquire lock on object

upgrade

public ObjectLock upgrade(OID oid,
                          TransactionContext tx,
                          int timeout)
                   throws LockNotGrantedException
Upgrade the lock to write lock.

Parameters:
oid - The OID of the lock.
tx - The transaction in action.
timeout - Time limit.
Returns:
The upgraded ObjectLock instance.
Throws:
LockNotGrantedException - Timeout or deadlock or object deleted occured attempting to acquire lock on object.

assure

public ObjectLock assure(OID oid,
                         TransactionContext tx,
                         boolean write)
Reassure the lock which have been successfully acquired by the transaction.

Parameters:
oid - The OID of the lock.
tx - The transaction in action.
write - true if we want to upgrade or reassure a write lock, false for read lock.
Returns:
The reassured ObjectLock instance.

rename

public ObjectLock rename(OID orgoid,
                         OID newoid,
                         TransactionContext tx)
                  throws LockNotGrantedException
Move the locked object from one OID to another OID for transaction. It is to be called by after create.

Parameters:
orgoid - Orginal OID before the object is created.
newoid - New OID after the object is created.
tx - The TransactionContext of the transaction in action.
Returns:
An ObjectLock instance whose OID has been assigned to a new value.
Throws:
LockNotGrantedException - Timeout or deadlock occured attempting to acquire lock on object

delete

public ObjectLock delete(OID oid,
                         TransactionContext tx)
Delete the object lock. It's called after the object is deleted from the persistence and the transaction committed.

Parameters:
oid - The OID of the ObjectLock.
tx - The transactionContext of transaction in action.
Returns:
The just-deleted ObjectLock instance.

release

public ObjectLock release(OID oid,
                          TransactionContext tx)
Release the object lock. It's called after the object the transaction has been committed.

Parameters:
oid - The OID of the ObjectLock.
tx - The transactionContext of transaction in action.
Returns:
The just-released ObjectLock instance.

isCached

public boolean isCached(OID oid)
Indicates whether an object with the specified identifier is currently cached.

Parameters:
oid - The Object identifier.
Returns:
True if the object is cached.

isLocked

public boolean isLocked(OID oid)
Indicates whether an object with the specified OID is currently locked.

Parameters:
oid - Object identifier.
Returns:
True if the object is locked.


Copyright © 2012. All Rights Reserved.