From: <hib...@li...> - 2006-05-30 18:01:05
|
Author: ste...@jb... Date: 2006-05-30 14:00:28 -0400 (Tue, 30 May 2006) New Revision: 9965 Modified: trunk/Hibernate3/src/org/hibernate/cache/OptimisticTreeCache.java trunk/Hibernate3/src/org/hibernate/cache/TreeCache.java Log: HHH-1796 : TreeCache based providers and Fqn Modified: trunk/Hibernate3/src/org/hibernate/cache/OptimisticTreeCache.java =================================================================== --- trunk/Hibernate3/src/org/hibernate/cache/OptimisticTreeCache.java 2006-05-30 15:40:54 UTC (rev 9964) +++ trunk/Hibernate3/src/org/hibernate/cache/OptimisticTreeCache.java 2006-05-30 18:00:28 UTC (rev 9965) @@ -33,14 +33,14 @@ private org.jboss.cache.TreeCache cache; private final String regionName; - private final String userRegionName; + private final Fqn regionFqn; private OptimisticCacheSource source; public OptimisticTreeCache(org.jboss.cache.TreeCache cache, String regionName) throws CacheException { this.cache = cache; - userRegionName = regionName; - this.regionName = regionName.replace('.', '/'); + this.regionName = regionName; + this.regionFqn = Fqn.fromString( regionName.replace( '.', '/' ) ); } @@ -69,7 +69,7 @@ ); } } - cache.put( new Fqn( new Object[] { regionName, key } ), ITEM, value, option ); + cache.put( new Fqn( regionFqn, key ), ITEM, value, option ); } catch (Exception e) { throw new CacheException(e); @@ -80,7 +80,7 @@ try { Option option = new Option(); option.setFailSilently( true ); - cache.remove( new Fqn( new Object[] { regionName, key } ), "ITEM", option ); + cache.remove( new Fqn( regionFqn, key ), "ITEM", option ); if ( source != null ) { if ( source.isVersioned() ) { option.setDataVersion( @@ -92,7 +92,7 @@ ); } } - cache.put( new Fqn( new Object[] { regionName, key } ), ITEM, value, option ); + cache.put( new Fqn( regionFqn, key ), ITEM, value, option ); } catch (Exception e) { throw new CacheException(e); @@ -106,7 +106,7 @@ try { Option option = new Option(); option.setFailSilently( true ); - return cache.get( new Fqn( new Object[] { regionName, key } ), ITEM, option ); + return cache.get( new Fqn( regionFqn, key ), ITEM, option ); } catch (Exception e) { throw new CacheException(e); @@ -115,7 +115,7 @@ public Object read(Object key) throws CacheException { try { - return cache.get( new Fqn( new Object[] { regionName, key } ), ITEM ); + return cache.get( new Fqn( regionFqn, key ), ITEM ); } catch (Exception e) { throw new CacheException(e); @@ -124,7 +124,7 @@ public void update(Object key, Object value) throws CacheException { try { - cache.put( new Fqn( new Object[] { regionName, key } ), ITEM, value ); + cache.put( new Fqn( regionFqn, key ), ITEM, value ); } catch (Exception e) { throw new CacheException(e); @@ -136,7 +136,7 @@ // do the put outside the scope of the JTA txn Option option = new Option(); option.setFailSilently( true ); - cache.put( new Fqn( new Object[] { regionName, key } ), ITEM, value, option ); + cache.put( new Fqn( regionFqn, key ), ITEM, value, option ); } catch (TimeoutException te) { //ignore! @@ -149,7 +149,7 @@ public void remove(Object key) throws CacheException { try { - cache.remove( new Fqn( new Object[] { regionName, key } ) ); + cache.remove( new Fqn( regionFqn, key ) ); } catch (Exception e) { throw new CacheException(e); @@ -158,7 +158,7 @@ public void clear() throws CacheException { try { - cache.remove( new Fqn(regionName) ); + cache.remove( regionFqn ); } catch (Exception e) { throw new CacheException(e); @@ -169,7 +169,7 @@ try { Option option = new Option(); option.setCacheModeLocal( true ); - cache.remove( new Fqn( regionName ), option ); + cache.remove( regionFqn, option ); } catch( Exception e ) { throw new CacheException( e ); @@ -177,11 +177,11 @@ } public void lock(Object key) throws CacheException { - throw new UnsupportedOperationException("TreeCache is a fully transactional cache" + regionName); + throw new UnsupportedOperationException( "TreeCache is a fully transactional cache" + regionName ); } public void unlock(Object key) throws CacheException { - throw new UnsupportedOperationException("TreeCache is a fully transactional cache: " + regionName); + throw new UnsupportedOperationException( "TreeCache is a fully transactional cache: " + regionName ); } public long nextTimestamp() { @@ -193,7 +193,7 @@ } public String getRegionName() { - return userRegionName; + return regionName; } public long getSizeInMemory() { @@ -202,7 +202,7 @@ public long getElementCountInMemory() { try { - Set children = cache.getChildrenNames( new Fqn(regionName) ); + Set children = cache.getChildrenNames( regionFqn ); return children == null ? 0 : children.size(); } catch (Exception e) { @@ -217,14 +217,14 @@ public Map toMap() { try { Map result = new HashMap(); - Set childrenNames = cache.getChildrenNames( new Fqn(regionName) ); + Set childrenNames = cache.getChildrenNames( regionFqn ); if (childrenNames != null) { Iterator iter = childrenNames.iterator(); while ( iter.hasNext() ) { Object key = iter.next(); result.put( key, - cache.get( new Fqn( new Object[] { regionName, key } ), ITEM ) + cache.get( new Fqn( regionFqn, key ), ITEM ) ); } } @@ -236,7 +236,7 @@ } public String toString() { - return "OptimisticTreeCache(" + userRegionName + ')'; + return "OptimisticTreeCache(" + regionName + ')'; } public static class DataVersionAdapter implements DataVersion { Modified: trunk/Hibernate3/src/org/hibernate/cache/TreeCache.java =================================================================== --- trunk/Hibernate3/src/org/hibernate/cache/TreeCache.java 2006-05-30 15:40:54 UTC (rev 9964) +++ trunk/Hibernate3/src/org/hibernate/cache/TreeCache.java 2006-05-30 18:00:28 UTC (rev 9965) @@ -28,14 +28,14 @@ private org.jboss.cache.TreeCache cache; private final String regionName; - private final String userRegionName; + private final Fqn regionFqn; private final TransactionManager transactionManager; public TreeCache(org.jboss.cache.TreeCache cache, String regionName, TransactionManager transactionManager) throws CacheException { this.cache = cache; - userRegionName = regionName; - this.regionName = regionName.replace('.', '/'); + this.regionName = regionName; + this.regionFqn = Fqn.fromString( regionName.replace( '.', '/' ) ); this.transactionManager = transactionManager; } @@ -51,7 +51,7 @@ public Object read(Object key) throws CacheException { try { - return cache.get( new Fqn( new Object[] { regionName, key } ), ITEM ); + return cache.get( new Fqn( regionFqn, key ), ITEM ); } catch (Exception e) { throw new CacheException(e); @@ -60,7 +60,7 @@ public void update(Object key, Object value) throws CacheException { try { - cache.put( new Fqn( new Object[] { regionName, key } ), ITEM, value ); + cache.put( new Fqn( regionFqn, key ), ITEM, value ); } catch (Exception e) { throw new CacheException(e); @@ -71,7 +71,7 @@ Transaction tx = suspend(); try { //do the failfast put outside the scope of the JTA txn - cache.putFailFast( new Fqn( new Object[] { regionName, key } ), ITEM, value, 0 ); + cache.putFailFast( new Fqn( regionFqn, key ), ITEM, value, 0 ); } catch (TimeoutException te) { //ignore! @@ -109,7 +109,7 @@ public void remove(Object key) throws CacheException { try { - cache.remove( new Fqn( new Object[] { regionName, key } ) ); + cache.remove( new Fqn( regionFqn, key ) ); } catch (Exception e) { throw new CacheException(e); @@ -118,7 +118,7 @@ public void clear() throws CacheException { try { - cache.remove( new Fqn(regionName) ); + cache.remove( regionFqn ); } catch (Exception e) { throw new CacheException(e); @@ -132,7 +132,7 @@ // exactly what is needed when we destroy() here; destroy() is used // as part of the process of shutting down a SessionFactory; thus // these removals should not be propogated - cache.evict( new Fqn( regionName ) ); + cache.evict( regionFqn ); } catch( Exception e ) { throw new CacheException( e ); @@ -140,11 +140,11 @@ } public void lock(Object key) throws CacheException { - throw new UnsupportedOperationException("TreeCache is a fully transactional cache" + regionName); + throw new UnsupportedOperationException( "TreeCache is a fully transactional cache" + regionName ); } public void unlock(Object key) throws CacheException { - throw new UnsupportedOperationException("TreeCache is a fully transactional cache: " + regionName); + throw new UnsupportedOperationException( "TreeCache is a fully transactional cache: " + regionName ); } public long nextTimestamp() { @@ -156,7 +156,7 @@ } public String getRegionName() { - return userRegionName; + return regionName; } public long getSizeInMemory() { @@ -165,7 +165,7 @@ public long getElementCountInMemory() { try { - Set children = cache.getChildrenNames( new Fqn(regionName) ); + Set children = cache.getChildrenNames( regionFqn ); return children == null ? 0 : children.size(); } catch (Exception e) { @@ -180,14 +180,14 @@ public Map toMap() { try { Map result = new HashMap(); - Set childrenNames = cache.getChildrenNames( new Fqn(regionName) ); + Set childrenNames = cache.getChildrenNames( regionFqn ); if (childrenNames != null) { Iterator iter = childrenNames.iterator(); while ( iter.hasNext() ) { Object key = iter.next(); result.put( key, - cache.get( new Fqn( new Object[] { regionName, key } ), ITEM ) + cache.get( new Fqn( regionFqn, key ), ITEM ) ); } } @@ -199,7 +199,7 @@ } public String toString() { - return "TreeCache(" + userRegionName + ')'; + return "TreeCache(" + regionName + ')'; } } |