org.jboss.util
Class FastKey

java.lang.Object
  |
  +--org.jboss.ejb.CacheKey
        |
        +--org.jboss.util.FastKey
All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable

public class FastKey
extends CacheKey
implements java.io.Externalizable

FastKey FastKey is a hack to enable fool proof and fast operation of caches for Entity In the case of complex PK if a developer misses hash and equals the maps won't properly work in jboss. Here we provide an wrapper to the DB Key and the hash is over-written so that we never miss a hit in cache and have constant speed.

Version:
$Revision: 1.8 $
Author:
Marc Fleury
See Also:
org.jboss.ejb.plugins.NoPassivationInstanceCache.java, Serialized Form

Field Summary
protected  java.lang.Long fastKey
           
 
Fields inherited from class org.jboss.ejb.CacheKey
hashCode, id, mo
 
Constructor Summary
FastKey()
           
FastKey(java.lang.Object id)
           
 
Method Summary
 boolean equals(java.lang.Object object)
          equals() We base the equals on the equality of the underlying key in this fashion we make sure that we cannot have duplicate hashes in the maps.
 java.lang.Object getPrimaryKey()
           
 int hashCode()
          these should be overwritten by extending Cache key since they define what the cache does in the first place
protected  java.lang.Long nextFastKey()
           
 void readExternal(java.io.ObjectInput in)
           
 void writeExternal(java.io.ObjectOutput out)
           
 
Methods inherited from class org.jboss.ejb.CacheKey
getId, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

fastKey

protected java.lang.Long fastKey
Constructor Detail

FastKey

public FastKey()

FastKey

public FastKey(java.lang.Object id)
Method Detail

getPrimaryKey

public java.lang.Object getPrimaryKey()

nextFastKey

protected java.lang.Long nextFastKey()

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Specified by:
writeExternal in interface java.io.Externalizable
Overrides:
writeExternal in class CacheKey

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Specified by:
readExternal in interface java.io.Externalizable
Overrides:
readExternal in class CacheKey

hashCode

public int hashCode()
Description copied from class: CacheKey
these should be overwritten by extending Cache key since they define what the cache does in the first place
Overrides:
hashCode in class CacheKey

equals

public boolean equals(java.lang.Object object)
Description copied from class: CacheKey
equals() We base the equals on the equality of the underlying key in this fashion we make sure that we cannot have duplicate hashes in the maps. The fast way (and right way) to do this implementation is with a incremented cachekey. It is more complex but worth the effort this is a FIXME (MF) The following implementation is fool-proof
Overrides:
equals in class CacheKey


Copyright © 2000 The JBoss Organization. All Rights Reserved.