Permalink
Browse files

HHH-7350 read-only entities can not be deleted from 2LC

  • Loading branch information...
1 parent 27df736 commit a203ea65aa686510199d93102d48b5b6b7031151 @stliu stliu committed May 25, 2012
@@ -75,19 +75,13 @@ public boolean putFromLoad(Object key, Object value, long txTimestamp, Object ve
}
}
- /**
- * Throws UnsupportedOperationException since this cache is read-only
- *
- * @throws UnsupportedOperationException always
- */
public SoftLock lockItem(Object key, Object version) throws UnsupportedOperationException {
- throw new UnsupportedOperationException( "Can't write to a readonly object" );
+ return null;
}
/**
* A no-op since this cache is read-only
*/
public void unlockItem(Object key, SoftLock lock) throws CacheException {
- //throw new UnsupportedOperationException("Can't write to a readonly object");
}
}
@@ -78,20 +78,15 @@ public boolean putFromLoad(Object key, Object value, long txTimestamp, Object ve
}
}
- /**
- * Throws UnsupportedOperationException since this cache is read-only
- *
- * @throws UnsupportedOperationException always
- */
public SoftLock lockItem(Object key, Object version) throws UnsupportedOperationException {
- throw new UnsupportedOperationException( "Can't write to a readonly object" );
+ return null;
}
/**
* A no-op since this cache is read-only
*/
public void unlockItem(Object key, SoftLock lock) throws CacheException {
- //throw new UnsupportedOperationException("Can't write to a readonly object");
+ evict( key );
}
/**
@@ -75,20 +75,15 @@ public boolean putFromLoad(Object key, Object value, long txTimestamp, Object ve
}
}
- /**
- * Throws UnsupportedOperationException since this cache is read-only
- *
- * @throws UnsupportedOperationException always
- */
public SoftLock lockItem(Object key, Object version) throws UnsupportedOperationException {
- throw new UnsupportedOperationException( "Can't write to a readonly object" );
+ return null;
}
/**
* A no-op since this cache is read-only
*/
public void unlockItem(Object key, SoftLock lock) throws CacheException {
- //throw new UnsupportedOperationException("Can't write to a readonly object");
+ region.remove( key );
}
/**
@@ -16,25 +16,6 @@
super( naturalIdRegion );
}
- @Override
- public SoftLock lockItem(Object key, Object version) throws CacheException {
- throw new UnsupportedOperationException( "Illegal attempt to edit read only item" );
- }
-
- @Override
- public SoftLock lockRegion() throws CacheException {
- throw new UnsupportedOperationException( "Illegal attempt to edit read only item" );
- }
-
- @Override
- public void unlockItem(Object key, SoftLock lock) throws CacheException {
- log.error( "Illegal attempt to edit read only item" );
- }
-
- @Override
- public void unlockRegion(SoftLock lock) throws CacheException {
- log.error( "Illegal attempt to edit read only item" );
- }
@Override
public boolean update(Object key, Object value) throws CacheException {
@@ -31,7 +31,9 @@
*/
class BaseCollectionRegionAccessStrategy extends BaseRegionAccessStrategy implements CollectionRegionAccessStrategy {
private final CollectionRegionImpl region;
-
+ BaseCollectionRegionAccessStrategy(CollectionRegionImpl region) {
+ this.region = region;
+ }
@Override
protected BaseGeneralDataRegion getInternalRegion() {
return region;
@@ -46,8 +48,4 @@ protected boolean isDefaultMinimalPutOverride() {
public CollectionRegion getRegion() {
return region;
}
-
- BaseCollectionRegionAccessStrategy(CollectionRegionImpl region) {
- this.region = region;
- }
}
@@ -33,25 +33,7 @@
* @author Strong Liu
*/
class ReadOnlyCollectionRegionAccessStrategy extends BaseCollectionRegionAccessStrategy {
- private static final CoreMessageLogger LOG = Logger.getMessageLogger(
- CoreMessageLogger.class, ReadOnlyCollectionRegionAccessStrategy.class.getName()
- );
-
ReadOnlyCollectionRegionAccessStrategy(CollectionRegionImpl region) {
super( region );
}
-
- @Override
- public void unlockItem(Object key, SoftLock lock) throws CacheException {
- LOG.invalidEditOfReadOnlyItem( key );
- }
-
- @Override
- public SoftLock lockItem(Object key, Object version) throws CacheException {
- LOG.invalidEditOfReadOnlyItem( key );
- throw new UnsupportedOperationException( "Can't write to a readonly object" );
- }
-
-
-
}
@@ -54,18 +54,9 @@ public boolean afterInsert(Object key, Object value, Object version) throws Cach
return true;
}
- /**
- * This cache is asynchronous hence a no-op
- */
@Override
public void unlockItem(Object key, SoftLock lock) throws CacheException {
- LOG.invalidEditOfReadOnlyItem( key );
- }
-
- @Override
- public SoftLock lockItem(Object key, Object version) throws CacheException {
- LOG.invalidEditOfReadOnlyItem( key );
- throw new UnsupportedOperationException( "Can't write to a readonly object" );
+ evict( key );
}
/**
@@ -43,15 +43,6 @@
@Override
public void unlockItem(Object key, SoftLock lock) throws CacheException {
- LOG.invalidEditOfReadOnlyItem( key );
+ evict( key );
}
-
- @Override
- public SoftLock lockItem(Object key, Object version) throws CacheException {
- LOG.invalidEditOfReadOnlyItem( key );
- throw new UnsupportedOperationException( "Can't write to a readonly object" );
- }
-
-
-
}

0 comments on commit a203ea6

Please sign in to comment.