FileDocCategorySizeDatePackage
IsolatedClientSessionIdentityMapAccessor.javaAPI DocGlassfish v2 API22916Tue May 22 16:54:44 BST 2007oracle.toplink.essentials.internal.sessions

IsolatedClientSessionIdentityMapAccessor

public class IsolatedClientSessionIdentityMapAccessor extends IdentityMapAccessor
INTERNAL: Internal subclass that provides access to identity maps through the session. Implements the IdentityMapAccessor interface which provides all publicly available identity map functionality to users. This is the main class that should be used to access identity maps. In general, any function that accesses the identity map manager should go through this class Any session specific functionality appears in subclasses

Fields Summary
Constructors Summary
public IsolatedClientSessionIdentityMapAccessor(AbstractSession session, IdentityMapManager identityMapManager)
INTERNAL: An IdentityMapAccessor sits between the session and the identityMapManager It needs references in both directions

        super(session, identityMapManager);
    
Methods Summary
public oracle.toplink.essentials.internal.identitymaps.CacheKeyacquireDeferredLock(java.util.Vector primaryKey, java.lang.Class javaClass, oracle.toplink.essentials.descriptors.ClassDescriptor descriptor)
INTERNAL: Deferred lock the identity map for the object, this is used for avoiding deadlock The return cacheKey should be used to release the deferred lock

        if (descriptor.isIsolated()) {
            return getIdentityMapManager().acquireDeferredLock(primaryKey, javaClass, descriptor);
        } else {
            return ((IsolatedClientSession)session).getParent().getIdentityMapAccessorInstance().acquireDeferredLock(primaryKey, javaClass, descriptor);
        }
    
public oracle.toplink.essentials.internal.identitymaps.CacheKeyacquireLock(java.util.Vector primaryKey, java.lang.Class domainClass, boolean forMerge, oracle.toplink.essentials.descriptors.ClassDescriptor descriptor)
INTERNAL: Provides access for setting a concurrency lock on an object in the IdentityMap. called with true from the merge process, if true then the refresh will not refresh the object

see
IdentityMap#aquire

        if (descriptor.isIsolated()) {
            return getIdentityMapManager().acquireLock(primaryKey, domainClass, forMerge, descriptor);
        } else {
            return ((IsolatedClientSession)session).getParent().getIdentityMapAccessorInstance().acquireLock(primaryKey, domainClass, forMerge, descriptor);
        }
    
public oracle.toplink.essentials.internal.identitymaps.CacheKeyacquireLockNoWait(java.util.Vector primaryKey, java.lang.Class domainClass, boolean forMerge, oracle.toplink.essentials.descriptors.ClassDescriptor descriptor)
INTERNAL: Provides access for setting a concurrency lock on an object in the IdentityMap. called with true from the merge process, if true then the refresh will not refresh the object

see
IdentityMap#aquire

        if (descriptor.isIsolated()) {
            return getIdentityMapManager().acquireLockNoWait(primaryKey, domainClass, forMerge, descriptor);
        } else {
            return ((IsolatedClientSession)session).getParent().getIdentityMapAccessorInstance().acquireLockNoWait(primaryKey, domainClass, forMerge, descriptor);
        }
    
public oracle.toplink.essentials.internal.identitymaps.CacheKeyacquireReadLockOnCacheKey(java.util.Vector primaryKey, java.lang.Class domainClass, oracle.toplink.essentials.descriptors.ClassDescriptor descriptor)
INTERNAL: Find the cachekey for the provided primary key and place a readlock on it. This will allow multiple users to read the same object but prevent writes to the object while the read lock is held.

        if (descriptor.isIsolated()) {
            return getIdentityMapManager().acquireReadLockOnCacheKey(primaryKey, domainClass, descriptor);
        } else {
            return ((IsolatedClientSession)session).getParent().getIdentityMapAccessorInstance().acquireReadLockOnCacheKey(primaryKey, domainClass, descriptor);
        }
    
public oracle.toplink.essentials.internal.identitymaps.CacheKeyacquireReadLockOnCacheKeyNoWait(java.util.Vector primaryKey, java.lang.Class domainClass, oracle.toplink.essentials.descriptors.ClassDescriptor descriptor)
INTERNAL: Find the cachekey for the provided primary key and place a readlock on it. This will allow multiple users to read the same object but prevent writes to the object while the read lock is held. If no readlock can be acquired then do not wait but return null.

        if (descriptor.isIsolated()) {
            return getIdentityMapManager().acquireReadLockOnCacheKeyNoWait(primaryKey, domainClass, descriptor);
        } else {
            return ((IsolatedClientSession)session).getParent().getIdentityMapAccessorInstance().acquireReadLockOnCacheKeyNoWait(primaryKey, domainClass, descriptor);
        }
    
public booleanacquireWriteLock()
INTERNAL: Lock the entire cache if the cache isolation requires. By default concurrent reads and writes are allowed. By write, unit of work merge is meant.

        getIdentityMapManager().acquireWriteLock();
        // must lock the parents cache as well.
        return ((IsolatedClientSession)session).getParent().getIdentityMapAccessorInstance().acquireWriteLock();
    
public booleancontainsKey(java.util.Vector key, java.lang.Class theClass, oracle.toplink.essentials.descriptors.ClassDescriptor descriptor)
INTERNAL: Return whether the identity maps contain an item of the given class and key

        if (descriptor.isIsolated()) {
            return getIdentityMapManager().containsKey(key, theClass, descriptor);
        } else {
            return ((IsolatedClientSession)session).getParent().getIdentityMapAccessorInstance().containsKey(key, theClass, descriptor);
        }
    
public booleancontainsObjectInIdentityMap(java.util.Vector primaryKey, java.lang.Class theClass, oracle.toplink.essentials.descriptors.ClassDescriptor descriptor)
ADVANCED: Return if their is an object for the primary key.

        if (descriptor.isIsolated()) {
            return getIdentityMapManager().containsKey(primaryKey, theClass, descriptor);
        } else {
            return ((IsolatedClientSession)session).getParent().getIdentityMapAccessorInstance().containsObjectInIdentityMap(primaryKey, theClass, descriptor);
        }
    
public java.util.VectorgetAllFromIdentityMap(oracle.toplink.essentials.expressions.Expression selectionCriteria, java.lang.Class theClass, oracle.toplink.essentials.sessions.Record translationRow, oracle.toplink.essentials.queryframework.InMemoryQueryIndirectionPolicy valueHolderPolicy, boolean shouldReturnInvalidatedObjects)
ADVANCED: Query the cache in-memory. If the expression is too complex an exception will be thrown. Only return objects that are invalid in the cache if specified.

        if (session.getDescriptor(theClass).isIsolated()) {
            return getIdentityMapManager().getAllFromIdentityMap(selectionCriteria, theClass, translationRow, valueHolderPolicy, shouldReturnInvalidatedObjects);
        } else {
            return ((IsolatedClientSession)session).getParent().getIdentityMapAccessorInstance().getAllFromIdentityMap(selectionCriteria, theClass, translationRow, valueHolderPolicy, shouldReturnInvalidatedObjects);
        }
    
public oracle.toplink.essentials.internal.identitymaps.CacheKeygetCacheKeyForObject(java.util.Vector primaryKey, java.lang.Class myClass, oracle.toplink.essentials.descriptors.ClassDescriptor descriptor)
INTERNAL: Retrieve the cache key for the given identity information

param
Vector the primary key of the cache key to be retrieved
param
Class the class of the cache key to be retrieved
return
CacheKey

        if (descriptor.isIsolated()) {
            return getIdentityMapManager().getCacheKeyForObject(primaryKey, myClass, descriptor);
        } else {
            return ((IsolatedClientSession)session).getParent().getIdentityMapAccessorInstance().getCacheKeyForObject(primaryKey, myClass, descriptor);
        }
    
public java.util.VectorgetClassesRegistered()
INTERNAL: This method is used to get a list of those classes with IdentityMaps in the Session.

        Vector results = getIdentityMapManager().getClassesRegistered();
        results.addAll(((IsolatedClientSession)session).getParent().getIdentityMapAccessorInstance().getClassesRegistered());
        return results;
    
public java.lang.ObjectgetFromIdentityMap(java.util.Vector primaryKey, java.lang.Class theClass, oracle.toplink.essentials.descriptors.ClassDescriptor descriptor, oracle.toplink.essentials.internal.queryframework.JoinedAttributeManager joinedAttributeManager)
ADVANCED: Return the object from the identity with the primary and class.

        if (descriptor.isIsolated()) {
            return getIdentityMapManager().getFromIdentityMap(primaryKey, theClass, descriptor);
        } else {
            return ((IsolatedClientSession)session).getParent().getIdentityMapAccessorInstance().getFromIdentityMap(primaryKey, theClass, descriptor, joinedAttributeManager);
        }
    
public java.lang.ObjectgetFromIdentityMap(oracle.toplink.essentials.expressions.Expression selectionCriteria, java.lang.Class theClass, oracle.toplink.essentials.sessions.Record translationRow, oracle.toplink.essentials.queryframework.InMemoryQueryIndirectionPolicy valueHolderPolicy, boolean conforming, boolean shouldReturnInvalidatedObjects, oracle.toplink.essentials.descriptors.ClassDescriptor descriptor)
INTERNAL: Query the cache in-memory. If the object is not found null is returned. If the expression is too complex an exception will be thrown.

        if (descriptor.isIsolated()) {
            return getIdentityMapManager().getFromIdentityMap(selectionCriteria, theClass, translationRow, valueHolderPolicy, conforming, shouldReturnInvalidatedObjects, descriptor);
        } else {
            return ((IsolatedClientSession)session).getParent().getIdentityMapAccessorInstance().getFromIdentityMap(selectionCriteria, theClass, translationRow, valueHolderPolicy, conforming, shouldReturnInvalidatedObjects, descriptor);
        }
    
public java.lang.ObjectgetFromIdentityMapWithDeferredLock(java.util.Vector primaryKey, java.lang.Class theClass, boolean shouldReturnInvalidatedObjects, oracle.toplink.essentials.descriptors.ClassDescriptor descriptor)
INTERNAL: Return the object from the identity with the primary and class. Only return invalidated objects if requested

        if (descriptor.isIsolated()) {
            return getIdentityMapManager().getFromIdentityMapWithDeferredLock(primaryKey, theClass, shouldReturnInvalidatedObjects, descriptor);
        } else {
            return ((IsolatedClientSession)session).getParent().getIdentityMapAccessorInstance().getFromIdentityMapWithDeferredLock(primaryKey, theClass, shouldReturnInvalidatedObjects, descriptor);
        }
    
public oracle.toplink.essentials.internal.identitymaps.IdentityMapgetIdentityMap(oracle.toplink.essentials.descriptors.ClassDescriptor descriptor)
INTERNAL: Get the identity map for the given class from the IdentityMapManager

        if (descriptor.isIsolated()) {
            return getIdentityMapManager().getIdentityMap(descriptor);
        } else {
            return ((IsolatedClientSession)session).getParent().getIdentityMapAccessorInstance().getIdentityMap(descriptor);
        }
    
public oracle.toplink.essentials.internal.identitymaps.IdentityMapManagergetIdentityMapManager()
INTERNAL: Get the IdentityMapManager for this IdentityMapAccessor This method should be used for all IdentityMapManager access since it may be overridden in sub classes.

        return identityMapManager;
    
public longgetRemainingValidTime(java.lang.Object object)
ADVANCED: Return the remaining life of this object. This method is associated with use of TopLink's cache invalidation feature and returns the difference between the next expiry time of the object and its read time. The method will return 0 for invalidated objects.

        ClassDescriptor descriptor = getSession().getDescriptor(object);
        CacheKey key = this.getCacheKeyForObject(object, descriptor);
        if (key == null) {
            throw QueryException.objectDoesNotExistInCache(object);
        }
        return descriptor.getCacheInvalidationPolicy().getRemainingValidTime(key);
    
public oracle.toplink.essentials.internal.sessions.AbstractSessiongetSession()
INTERNAL: get the session associated with this IdentityMapAccessor

        return session;
    
public java.lang.ObjectgetWrapper(java.util.Vector primaryKey, java.lang.Class theClass)
INTERNAL: Get the wrapper object from the cache key associated with the given primary key, this is used for EJB.

        if (session.getDescriptor(theClass).isIsolated()) {
            return getIdentityMapManager().getWrapper(primaryKey, theClass);
        } else {
            return ((IsolatedClientSession)session).getParent().getIdentityMapAccessorInstance().getWrapper(primaryKey, theClass);
        }
    
public oracle.toplink.essentials.internal.helper.WriteLockManagergetWriteLockManager()
INTERNAL: Returns the single write Lock manager for this session

        // As there should only be one write lock manager per server session
        // get the one from the parent.
        return ((IsolatedClientSession)session).getParent().getIdentityMapAccessorInstance().getWriteLockManager();
    
public java.lang.ObjectgetWriteLockValue(java.util.Vector primaryKey, java.lang.Class theClass, oracle.toplink.essentials.descriptors.ClassDescriptor descriptor)
ADVANCED: Extract the write lock value from the identity map.

        if (descriptor.isIsolated()) {
            return getIdentityMapManager().getWriteLockValue(primaryKey, theClass, descriptor);
        } else {
            return ((IsolatedClientSession)session).getParent().getIdentityMapAccessorInstance().getWriteLockValue(primaryKey, theClass, descriptor);
        }
    
public voidinitializeAllIdentityMaps()
PUBLIC: Reset the entire object cache.

NOTE: be careful using this method. This method blows away both this session's and its parents caches, this includes the server cache or any other cache. This throws away any objects that have been read in. Extream caution should be used before doing this because object identity will no longer be maintained for any objects currently read in. This should only be called if the application knows that it no longer has references to object held in the cache.

        getSession().log(SessionLog.FINER, SessionLog.CACHE, "initialize_all_local_identitymaps");
        getIdentityMapManager().initializeIdentityMaps();
        ((IsolatedClientSession)session).getParent().getIdentityMapAccessorInstance().initializeIdentityMaps();
    
public voidinitializeIdentityMap(java.lang.Class theClass)
PUBLIC: Reset the identity map for only the instances of the class. For inheritance the user must make sure that they only use the root class. Caution must be used in doing this to ensure that the objects within the identity map are not referenced from other objects of other classes or from the application.

        getSession().log(SessionLog.FINER, SessionLog.CACHE, "initialize_identitymap", theClass);
        if (session.getDescriptor(theClass).isIsolated()) {
            getIdentityMapManager().initializeIdentityMap(theClass);
        } else {
            ((IsolatedClientSession)session).getParent().getIdentityMapAccessorInstance().initializeIdentityMap(theClass);
        }
    
public voidinitializeIdentityMaps()
PUBLIC: Reset the entire local object cache. This throws away any objects that have been read in. Extream caution should be used before doing this because object identity will no longer be maintained for any objects currently read in. This should only be called if the application knows that it no longer has references to object held in the cache.

        getSession().log(SessionLog.FINER, SessionLog.CACHE, "initialize_identitymaps");
        getIdentityMapManager().initializeIdentityMaps();
        getSession().getCommitManager().reinitialize();
    
public oracle.toplink.essentials.internal.identitymaps.CacheKeyinternalPutInIdentityMap(java.lang.Object domainObject, java.util.Vector key, java.lang.Object writeLockValue, long readTime, oracle.toplink.essentials.descriptors.ClassDescriptor descriptor)
ADVANCED: Register the object with the identity map. The object must always be registered with its version number if optimistic locking is used. The readTime may also be included in the cache key as it is constructed.

        //no need to unwrap as the put will unwrap later anyway
        if (descriptor.isIsolated()) {
            return getIdentityMapManager().putInIdentityMap(domainObject, key, writeLockValue, readTime, descriptor);
        } else {
            return ((IsolatedClientSession)session).getParent().getIdentityMapAccessorInstance().internalPutInIdentityMap(domainObject, key, writeLockValue, readTime, descriptor);
        }
    
public voidprintIdentityMap(java.lang.Class businessClass)
PUBLIC: Used to print all the objects in the identity map of the passed in class. The output of this method will be logged to this session's SessionLog at SEVERE level.

        if (getSession().shouldLog(SessionLog.SEVERE, SessionLog.CACHE)) {
            if (session.getDescriptor(businessClass).isIsolated()) {
                getIdentityMapManager().printIdentityMap(businessClass);
            } else {
                ((IsolatedClientSession)session).getParent().getIdentityMapAccessorInstance().printIdentityMap(businessClass);
            }
        }
    
public voidprintIdentityMapLocks()
PUBLIC: Used to print all the locks in every identity map in this session. The output of this method will be logged to this session's SessionLog at FINEST level.

        if (getSession().shouldLog(SessionLog.FINEST, SessionLog.CACHE)) {
            getIdentityMapManager().printLocks();
            ((IsolatedClientSession)session).getParent().getIdentityMapAccessorInstance().printIdentityMapLocks();
        }
    
public voidprintIdentityMaps()
PUBLIC: Used to print all the objects in every identity map in this session. The output of this method will be logged to this session's SessionLog at SEVERE level.

        if (getSession().shouldLog(SessionLog.SEVERE, SessionLog.CACHE)) {
            getIdentityMapManager().printIdentityMaps();
            ((IsolatedClientSession)session).getParent().getIdentityMapAccessorInstance().printIdentityMaps();
        }
    
public voidreleaseWriteLock()
INTERNAL: Lock the entire cache if the cache isolation requires. By default concurrent reads and writes are allowed. By write, unit of work merge is meant.

        //release in the oposite order of the acquire
        ((IsolatedClientSession)session).getParent().getIdentityMapAccessorInstance().releaseWriteLock();
        getIdentityMapManager().releaseWriteLock();
    
public java.lang.ObjectremoveFromIdentityMap(java.util.Vector key, java.lang.Class theClass, oracle.toplink.essentials.descriptors.ClassDescriptor descriptor)
ADVANCED: Remove the object from the object cache.

        if (descriptor.isIsolated()) {
            return getIdentityMapManager().removeFromIdentityMap(key, theClass, descriptor);
        } else {
            return ((IsolatedClientSession)session).getParent().getIdentityMapAccessorInstance().removeFromIdentityMap(key, theClass, descriptor);
        }
    
public voidsetIdentityMapManager(oracle.toplink.essentials.internal.identitymaps.IdentityMapManager identityMapManager)
INTERNAL: Set the IdentityMapManager for this IdentityMapAccessor

        this.identityMapManager = identityMapManager;
    
public voidsetWrapper(java.util.Vector primaryKey, java.lang.Class theClass, java.lang.Object wrapper)
INTERNAL: Update the wrapper object the cache key associated with the given primary key, this is used for EJB.

        if (getSession().getDescriptor(theClass).isIsolated()) {
            getIdentityMapManager().setWrapper(primaryKey, theClass, wrapper);
        } else {
            ((IsolatedClientSession)session).getParent().getIdentityMapAccessorInstance().setWrapper(primaryKey, theClass, wrapper);
        }
    
public voidupdateWriteLockValue(java.util.Vector primaryKey, java.lang.Class theClass, java.lang.Object writeLockValue)
ADVANCED: Update the write lock value in the identity map.

        if (getSession().getDescriptor(theClass).isIsolated()) {
            getIdentityMapManager().setWriteLockValue(primaryKey, theClass, writeLockValue);
        } else {
            ((IsolatedClientSession)session).getParent().getIdentityMapAccessorInstance().updateWriteLockValue(primaryKey, theClass, writeLockValue);
        }