From: <one...@us...> - 2003-01-04 11:16:00
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/cache In directory sc8-pr-cvs1:/tmp/cvs-serv14211/src/net/sf/hibernate/cache Modified Files: Cache.java CacheConcurrencyStrategy.java CacheException.java CacheTest.java CachedItem.java HashBelt.java JCSCache.java ReadOnlyCache.java ReadWriteCache.java Timestamper.java Log Message: reformatted code with beautiful, shiny, happy TABS! improved an exception Index: Cache.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/cache/Cache.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** Cache.java 1 Jan 2003 13:53:52 -0000 1.1.1.1 --- Cache.java 4 Jan 2003 11:15:27 -0000 1.2 *************** *** 34,35 **** --- 34,38 ---- public void setClass(String clazz) throws CacheException; } + + + Index: CacheConcurrencyStrategy.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/cache/CacheConcurrencyStrategy.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** CacheConcurrencyStrategy.java 1 Jan 2003 13:53:52 -0000 1.1.1.1 --- CacheConcurrencyStrategy.java 4 Jan 2003 11:15:27 -0000 1.2 *************** *** 7,11 **** */ public interface CacheConcurrencyStrategy { ! /** * Attempt to retrieve an object from the cache --- 7,11 ---- */ public interface CacheConcurrencyStrategy { ! /** * Attempt to retrieve an object from the cache *************** *** 38,41 **** */ public void release(Object key) throws CacheException; ! } --- 38,44 ---- */ public void release(Object key) throws CacheException; ! } + + + Index: CacheException.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/cache/CacheException.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** CacheException.java 1 Jan 2003 13:53:52 -0000 1.1.1.1 --- CacheException.java 4 Jan 2003 11:15:27 -0000 1.2 *************** *** 8,19 **** */ public class CacheException extends HibernateException { ! public CacheException(String s) { super(s); } ! public CacheException(Exception e) { super(e); } ! } --- 8,22 ---- */ public class CacheException extends HibernateException { ! public CacheException(String s) { super(s); } ! public CacheException(Exception e) { super(e); } ! } + + + Index: CacheTest.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/cache/CacheTest.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** CacheTest.java 1 Jan 2003 13:53:53 -0000 1.1.1.1 --- CacheTest.java 4 Jan 2003 11:15:27 -0000 1.2 *************** *** 5,9 **** public class CacheTest extends TestCase { ! public CacheTest(String arg0) { super(arg0); --- 5,9 ---- public class CacheTest extends TestCase { ! public CacheTest(String arg0) { super(arg0); *************** *** 124,128 **** assertTrue( ccs.get("foo", longLongAfter).equals("baz") ); ! if ( cache instanceof HashBelt ) { --- 124,128 ---- assertTrue( ccs.get("foo", longLongAfter).equals("baz") ); ! if ( cache instanceof HashBelt ) { *************** *** 132,135 **** } ! } --- 132,138 ---- } ! } + + + Index: CachedItem.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/cache/CachedItem.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** CachedItem.java 1 Jan 2003 13:53:52 -0000 1.1.1.1 --- CachedItem.java 4 Jan 2003 11:15:27 -0000 1.2 *************** *** 16,20 **** private int lock; private Object value; ! public CachedItem(Object value) { this.value = value; --- 16,20 ---- private int lock; private Object value; ! public CachedItem(Object value) { this.value = value; *************** *** 31,35 **** return unlockTimestamp; } ! public Object getValue() { return value; --- 31,35 ---- return unlockTimestamp; } ! public Object getValue() { return value; *************** *** 54,57 **** return lock==0; } ! } --- 54,60 ---- return lock==0; } ! } + + + Index: HashBelt.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/cache/HashBelt.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** HashBelt.java 1 Jan 2003 13:53:53 -0000 1.1.1.1 --- HashBelt.java 4 Jan 2003 11:15:27 -0000 1.2 *************** *** 2,6 **** package net.sf.hibernate.cache; ! /** * Adaptation of design by William Grosso from onjava.com. * This implementation does not use a seperate thread to --- 2,6 ---- package net.sf.hibernate.cache; ! /** * Adaptation of design by William Grosso from onjava.com. * This implementation does not use a seperate thread to *************** *** 8,12 **** * the hashbelt design, but not all.<br> * <br> ! * This class is non-threadsafe so it <b>must</b> be wrapped * by a threadsafe version before you can use it. */ --- 8,12 ---- * the hashbelt design, but not all.<br> * <br> ! * This class is non-threadsafe so it <b>must</b> be wrapped * by a threadsafe version before you can use it. */ *************** *** 28,34 **** lastTime = System.currentTimeMillis(); } ! public Object get(Object key) { ! expire(); //TODO: expire should be outside synchronized block if // we need to explicitly expire data --- 28,34 ---- lastTime = System.currentTimeMillis(); } ! public Object get(Object key) { ! expire(); //TODO: expire should be outside synchronized block if // we need to explicitly expire data *************** *** 40,44 **** return null; } ! public Object invalidate(Object key) { expire(); --- 40,44 ---- return null; } ! public Object invalidate(Object key) { expire(); *************** *** 49,58 **** return null; } ! public void put(Object key, Object value) { invalidate(key); batches[0].put(key, value); } ! public void setTimeout(int timeout) { this.timeout=timeout; --- 49,58 ---- return null; } ! public void put(Object key, Object value) { invalidate(key); batches[0].put(key, value); } ! public void setTimeout(int timeout) { this.timeout=timeout; *************** *** 79,82 **** } } ! } --- 79,85 ---- } } ! } + + + Index: JCSCache.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/cache/JCSCache.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** JCSCache.java 1 Jan 2003 13:53:53 -0000 1.1.1.1 --- JCSCache.java 4 Jan 2003 11:15:27 -0000 1.2 *************** *** 10,22 **** */ public class JCSCache implements Cache { ! ! private static final Log log = LogFactory.getLog(JCSCache.class); ! ! private JCS region; ! ! public JCSCache() {} ! ! public void setClass(String clazz) throws CacheException { ! try { region = JCS.getInstance(clazz); --- 10,22 ---- */ public class JCSCache implements Cache { ! ! private static final Log log = LogFactory.getLog(JCSCache.class); ! ! private JCS region; ! ! public JCSCache() {} ! ! public void setClass(String clazz) throws CacheException { ! try { region = JCS.getInstance(clazz); *************** *** 27,35 **** } } ! ! public Object get(Object key) { ! return region.get(key); ! } ! public void put(Object key, Object value) throws CacheException { try { --- 27,35 ---- } } ! ! public Object get(Object key) { ! return region.get(key); ! } ! public void put(Object key, Object value) throws CacheException { try { *************** *** 40,45 **** throw new CacheException(e); } ! } ! ! public void setTimeout(int timeout) { } } --- 40,48 ---- throw new CacheException(e); } ! } ! ! public void setTimeout(int timeout) { } } + + + Index: ReadOnlyCache.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/cache/ReadOnlyCache.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** ReadOnlyCache.java 1 Jan 2003 13:53:53 -0000 1.1.1.1 --- ReadOnlyCache.java 4 Jan 2003 11:15:27 -0000 1.2 *************** *** 10,21 **** */ public class ReadOnlyCache implements CacheConcurrencyStrategy { ! private final Cache cache; private static final Log log = LogFactory.getLog(ReadOnlyCache.class); ! public ReadOnlyCache(Cache cache) { this.cache=cache; } ! public synchronized Object get(Object key, long timestamp) throws CacheException { Object result = cache.get(key); --- 10,21 ---- */ public class ReadOnlyCache implements CacheConcurrencyStrategy { ! private final Cache cache; private static final Log log = LogFactory.getLog(ReadOnlyCache.class); ! public ReadOnlyCache(Cache cache) { this.cache=cache; } ! public synchronized Object get(Object key, long timestamp) throws CacheException { Object result = cache.get(key); *************** *** 23,32 **** return result; } ! public void lock(Object key) { log.error("Application attempted to edit read only item: " + key); throw new UnsupportedOperationException("Can't write to a readonly object"); } ! public synchronized boolean put(Object key, Object value, long timestamp) throws CacheException { log.debug("Caching: " + key); --- 23,32 ---- return result; } ! public void lock(Object key) { log.error("Application attempted to edit read only item: " + key); throw new UnsupportedOperationException("Can't write to a readonly object"); } ! public synchronized boolean put(Object key, Object value, long timestamp) throws CacheException { log.debug("Caching: " + key); *************** *** 34,42 **** return true; } ! public void release(Object key) { log.error("Application attempted to edit read only item: " + key); throw new UnsupportedOperationException("Can't write to a readonly object"); } ! } --- 34,45 ---- return true; } ! public void release(Object key) { log.error("Application attempted to edit read only item: " + key); throw new UnsupportedOperationException("Can't write to a readonly object"); } ! } + + + Index: ReadWriteCache.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/cache/ReadWriteCache.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** ReadWriteCache.java 1 Jan 2003 13:53:53 -0000 1.1.1.1 --- ReadWriteCache.java 4 Jan 2003 11:15:27 -0000 1.2 *************** *** 19,23 **** this.cache=cache; } ! public synchronized Object get(Object key, long txTimestamp) throws CacheException { --- 19,23 ---- this.cache=cache; } ! public synchronized Object get(Object key, long txTimestamp) throws CacheException { *************** *** 26,39 **** CachedItem item = (CachedItem) cache.get(key); ! if ( ! item!=null && ! item.getFreshTimestamp() < txTimestamp && item.isFresh() // || txTimestamp < item.getLockTimestamp() ) { ! if ( log.isTraceEnabled() ) log.trace("Cache hit: " + key); return item.getValue(); } else { ! if ( log.isTraceEnabled() ) log.trace("Cache miss: " + key); return null; } --- 26,39 ---- CachedItem item = (CachedItem) cache.get(key); ! if ( ! item!=null && ! item.getFreshTimestamp() < txTimestamp && item.isFresh() // || txTimestamp < item.getLockTimestamp() ) { ! if ( log.isTraceEnabled() ) log.trace("Cache hit: " + key); return item.getValue(); } else { ! if ( log.isTraceEnabled() ) log.trace("Cache miss: " + key); return null; } *************** *** 42,46 **** //TODO: Actually keep locked CachedItems in a different HashMap //in this class until they are unlocked ! public synchronized void lock(Object key) throws CacheException { if ( log.isTraceEnabled() ) log.trace("Invalidating: " + key); --- 42,46 ---- //TODO: Actually keep locked CachedItems in a different HashMap //in this class until they are unlocked ! public synchronized void lock(Object key) throws CacheException { if ( log.isTraceEnabled() ) log.trace("Invalidating: " + key); *************** *** 52,56 **** } ! public synchronized boolean put(Object key, Object value, long txTimestamp) throws CacheException { if ( log.isTraceEnabled() ) log.trace("Caching: " + key); --- 52,56 ---- } ! public synchronized boolean put(Object key, Object value, long txTimestamp) throws CacheException { if ( log.isTraceEnabled() ) log.trace("Caching: " + key); *************** *** 58,64 **** CachedItem item = (CachedItem) cache.get(key); ! if ( item==null || ! ( item.isUnlocked() && !item.isFresh() && item.getUnlockTimestamp() < txTimestamp ) ) { cache.put( key, new CachedItem(value) ); --- 58,64 ---- CachedItem item = (CachedItem) cache.get(key); ! if ( item==null || ! ( item.isUnlocked() && !item.isFresh() && item.getUnlockTimestamp() < txTimestamp ) ) { cache.put( key, new CachedItem(value) ); *************** *** 86,89 **** } ! } --- 86,92 ---- } ! } + + + Index: Timestamper.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/cache/Timestamper.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** Timestamper.java 1 Jan 2003 13:53:54 -0000 1.1.1.1 --- Timestamper.java 4 Jan 2003 11:15:27 -0000 1.2 *************** *** 25,26 **** --- 25,29 ---- } } + + + |