org.hibernate.cache.spi.access.SoftLock Java Examples
The following examples show how to use
org.hibernate.cache.spi.access.SoftLock.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ReadWriteJ2CacheNaturalIdRegionAccessStrategy.java From J2Cache with Apache License 2.0 | 6 votes |
@Override public boolean afterUpdate(Object key, Object value, SoftLock lock) throws CacheException { region().writeLock(key); try { final Lockable item = (Lockable) region().get(key); if (item != null && item.isUnlockable(lock)) { final Lock lockItem = (Lock) item; if (lockItem.wasLockedConcurrently()) { decrementLock(key, lockItem); return false; } else { region().put(key, new Item(value, null, region().nextTimestamp())); return true; } } else { handleLockExpiry(key, item); return false; } } finally { region().writeUnlock(key); } }
Example #2
Source File: ReadWriteJ2CacheNaturalIdRegionAccessStrategy.java From J2Cache with Apache License 2.0 | 6 votes |
@Override public boolean afterUpdate(SharedSessionContractImplementor session, Object key, Object value, SoftLock lock) throws CacheException { region().writeLock(key); try { final Lockable item = (Lockable) region().get(key); if (item != null && item.isUnlockable(lock)) { final Lock lockItem = (Lock) item; if (lockItem.wasLockedConcurrently()) { decrementLock(key, lockItem); return false; } else { region().put(key, new Item(value, null, region().nextTimestamp())); return true; } } else { handleLockExpiry(key, item); return false; } } finally { region().writeUnlock(key); } }
Example #3
Source File: NonstopAwareEntityRegionAccessStrategy.java From J2Cache with Apache License 2.0 | 5 votes |
@Override public boolean afterUpdate(Object key, Object value, Object currentVersion, Object previousVersion, SoftLock lock) throws CacheException { try { return actualStrategy.afterUpdate(key, value, currentVersion, previousVersion, lock); } catch (NonStopCacheException nonStopCacheException) { hibernateNonstopExceptionHandler.handleNonstopCacheException(nonStopCacheException); return false; } }
Example #4
Source File: ReadWriteJ2CacheEntityRegionAccessStrategy.java From J2Cache with Apache License 2.0 | 5 votes |
@Override public boolean afterUpdate(Object key, Object value, Object currentVersion, Object previousVersion, SoftLock lock) throws CacheException { //what should we do with previousVersion here? region().writeLock( key ); try { final AbstractReadWriteJ2CacheAccessStrategy.Lockable item = (AbstractReadWriteJ2CacheAccessStrategy.Lockable) region().get( key ); if ( item != null && item.isUnlockable( lock ) ) { final AbstractReadWriteJ2CacheAccessStrategy.Lock lockItem = (AbstractReadWriteJ2CacheAccessStrategy.Lock) item; if ( lockItem.wasLockedConcurrently() ) { decrementLock( key, lockItem ); return false; } else { region().put( key, new AbstractReadWriteJ2CacheAccessStrategy.Item( value, currentVersion, region().nextTimestamp() ) ); return true; } } else { handleLockExpiry( key, item ); return false; } } finally { region().writeUnlock( key ); } }
Example #5
Source File: NonstopAwareEntityRegionAccessStrategy.java From J2Cache with Apache License 2.0 | 5 votes |
@Override public void unlockItem(Object key, SoftLock lock) throws CacheException { try { actualStrategy.unlockItem(key, lock); } catch (NonStopCacheException nonStopCacheException) { hibernateNonstopExceptionHandler.handleNonstopCacheException(nonStopCacheException); } }
Example #6
Source File: NonstopAwareEntityRegionAccessStrategy.java From J2Cache with Apache License 2.0 | 5 votes |
@Override public void unlockRegion(SoftLock lock) throws CacheException { try { actualStrategy.unlockRegion(lock); } catch (NonStopCacheException nonStopCacheException) { hibernateNonstopExceptionHandler.handleNonstopCacheException(nonStopCacheException); } }
Example #7
Source File: ReadWriteJ2CacheEntityRegionAccessStrategy.java From J2Cache with Apache License 2.0 | 5 votes |
@Override public boolean afterUpdate(SharedSessionContractImplementor session, Object key, Object value, Object currentVersion, Object previousVersion, SoftLock lock) throws CacheException { //what should we do with previousVersion here? region().writeLock( key ); try { final AbstractReadWriteJ2CacheAccessStrategy.Lockable item = (AbstractReadWriteJ2CacheAccessStrategy.Lockable) region().get( key ); if ( item != null && item.isUnlockable( lock ) ) { final AbstractReadWriteJ2CacheAccessStrategy.Lock lockItem = (AbstractReadWriteJ2CacheAccessStrategy.Lock) item; if ( lockItem.wasLockedConcurrently() ) { decrementLock( key, lockItem ); return false; } else { region().put( key, new AbstractReadWriteJ2CacheAccessStrategy.Item( value, currentVersion, region().nextTimestamp() ) ); return true; } } else { handleLockExpiry( key, item ); return false; } } finally { region().writeUnlock( key ); } }
Example #8
Source File: NonstopAwareCollectionRegionAccessStrategy.java From J2Cache with Apache License 2.0 | 5 votes |
@Override public SoftLock lockRegion() throws CacheException { try { return actualStrategy.lockRegion(); } catch (NonStopCacheException nonStopCacheException) { hibernateNonstopExceptionHandler.handleNonstopCacheException(nonStopCacheException); return null; } }
Example #9
Source File: NonstopAwareCollectionRegionAccessStrategy.java From J2Cache with Apache License 2.0 | 5 votes |
@Override public SoftLock lockItem(Object key, Object version) throws CacheException { try { return actualStrategy.lockItem(key, version); } catch (NonStopCacheException nonStopCacheException) { hibernateNonstopExceptionHandler.handleNonstopCacheException(nonStopCacheException); return null; } }
Example #10
Source File: NonstopAwareNaturalIdRegionAccessStrategy.java From J2Cache with Apache License 2.0 | 5 votes |
@Override public void unlockRegion(SoftLock lock) throws CacheException { try { actualStrategy.unlockRegion(lock); } catch (NonStopCacheException nonStopCacheException) { hibernateNonstopExceptionHandler.handleNonstopCacheException(nonStopCacheException); } }
Example #11
Source File: NonstopAwareNaturalIdRegionAccessStrategy.java From J2Cache with Apache License 2.0 | 5 votes |
@Override public void unlockItem(Object key, SoftLock lock) throws CacheException { try { actualStrategy.unlockItem(key, lock); } catch (NonStopCacheException nonStopCacheException) { hibernateNonstopExceptionHandler.handleNonstopCacheException(nonStopCacheException); } }
Example #12
Source File: NonstopAwareNaturalIdRegionAccessStrategy.java From J2Cache with Apache License 2.0 | 5 votes |
@Override public SoftLock lockRegion() throws CacheException { try { return actualStrategy.lockRegion(); } catch (NonStopCacheException nonStopCacheException) { hibernateNonstopExceptionHandler.handleNonstopCacheException(nonStopCacheException); return null; } }
Example #13
Source File: NonstopAwareNaturalIdRegionAccessStrategy.java From J2Cache with Apache License 2.0 | 5 votes |
@Override public SoftLock lockItem(Object key, Object version) throws CacheException { try { return actualStrategy.lockItem(key, version); } catch (NonStopCacheException nonStopCacheException) { hibernateNonstopExceptionHandler.handleNonstopCacheException(nonStopCacheException); return null; } }
Example #14
Source File: NonstopAwareNaturalIdRegionAccessStrategy.java From J2Cache with Apache License 2.0 | 5 votes |
@Override public boolean afterUpdate(Object key, Object value, SoftLock lock) throws CacheException { try { return actualStrategy.afterUpdate(key, value, lock); } catch (NonStopCacheException nonStopCacheException) { hibernateNonstopExceptionHandler.handleNonstopCacheException(nonStopCacheException); return false; } }
Example #15
Source File: NonstopAwareNaturalIdRegionAccessStrategy.java From J2Cache with Apache License 2.0 | 5 votes |
@Override public boolean afterUpdate(SharedSessionContractImplementor session, Object key, Object value, SoftLock lock) throws CacheException { try { return this.actualStrategy.afterUpdate(session, key, value, lock); } catch (NonStopCacheException nonStopCacheException) { hibernateNonstopExceptionHandler.handleNonstopCacheException(nonStopCacheException); return false; } }
Example #16
Source File: NonstopAwareCollectionRegionAccessStrategy.java From J2Cache with Apache License 2.0 | 5 votes |
@Override public void unlockItem(Object key, SoftLock lock) throws CacheException { try { actualStrategy.unlockItem(key, lock); } catch (NonStopCacheException nonStopCacheException) { hibernateNonstopExceptionHandler.handleNonstopCacheException(nonStopCacheException); } }
Example #17
Source File: NonstopAwareNaturalIdRegionAccessStrategy.java From J2Cache with Apache License 2.0 | 5 votes |
@Override public SoftLock lockItem(SharedSessionContractImplementor session, Object key, Object version) throws CacheException { try { return this.actualStrategy.lockItem(session, key, version); } catch (NonStopCacheException nonStopCacheException) { hibernateNonstopExceptionHandler.handleNonstopCacheException(nonStopCacheException); return null; } }
Example #18
Source File: NonstopAwareNaturalIdRegionAccessStrategy.java From J2Cache with Apache License 2.0 | 5 votes |
@Override public void unlockItem(SharedSessionContractImplementor session, Object key, SoftLock lock) throws CacheException { try { this.actualStrategy.unlockItem(session, key, lock); } catch (NonStopCacheException nonStopCacheException) { hibernateNonstopExceptionHandler.handleNonstopCacheException(nonStopCacheException); } }
Example #19
Source File: NonstopAwareNaturalIdRegionAccessStrategy.java From J2Cache with Apache License 2.0 | 5 votes |
@Override public void unlockRegion(SoftLock lock) throws CacheException { try { this.actualStrategy.unlockRegion(lock); } catch (NonStopCacheException nonStopCacheException) { hibernateNonstopExceptionHandler.handleNonstopCacheException(nonStopCacheException); } }
Example #20
Source File: AbstractReadWriteJ2CacheAccessStrategy.java From J2Cache with Apache License 2.0 | 5 votes |
public final SoftLock lockItem(Object key, Object version) throws CacheException { region().writeLock(key); try { final Lockable item = (Lockable) region().get(key); final long timeout = region().nextTimestamp() + region().getTimeout(); final Lock lock = (item == null) ? new Lock(timeout, uuid, nextLockId(), version) : item.lock(timeout, uuid, nextLockId()); region().put(key, lock); return lock; } finally { region().writeUnlock(key); } }
Example #21
Source File: DefaultReactiveRefreshEventListener.java From hibernate-reactive with GNU Lesser General Public License v2.1 | 5 votes |
private void evictCachedCollections(Type[] types, Serializable id, EventSource source) throws HibernateException { final ActionQueue actionQueue = source.getActionQueue(); final SessionFactoryImplementor factory = source.getFactory(); final MetamodelImplementor metamodel = factory.getMetamodel(); for ( Type type : types ) { if ( type.isCollectionType() ) { CollectionPersister collectionPersister = metamodel.collectionPersister( ( (CollectionType) type ).getRole() ); if ( collectionPersister.hasCache() ) { final CollectionDataAccess cache = collectionPersister.getCacheAccessStrategy(); final Object ck = cache.generateCacheKey( id, collectionPersister, factory, source.getTenantIdentifier() ); final SoftLock lock = cache.lockItem( source, ck, null ); cache.remove( source, ck ); actionQueue.registerProcess( (success, session) -> cache.unlockItem( session, ck, lock ) ); } } else if ( type.isComponentType() ) { CompositeType actype = (CompositeType) type; evictCachedCollections( actype.getSubtypes(), id, source ); } } }
Example #22
Source File: NonstopAwareCollectionRegionAccessStrategy.java From J2Cache with Apache License 2.0 | 5 votes |
@Override public SoftLock lockItem(SharedSessionContractImplementor session, Object key, Object version) throws CacheException { try { return this.actualStrategy.lockItem(session, key, version); } catch (NonStopCacheException nonStopCacheException) { hibernateNonstopExceptionHandler.handleNonstopCacheException(nonStopCacheException); return null; } }
Example #23
Source File: NonstopAwareCollectionRegionAccessStrategy.java From J2Cache with Apache License 2.0 | 5 votes |
@Override public SoftLock lockRegion() throws CacheException { try { return this.actualStrategy.lockRegion(); } catch (NonStopCacheException nonStopCacheException) { hibernateNonstopExceptionHandler.handleNonstopCacheException(nonStopCacheException); return null; } }
Example #24
Source File: NonstopAwareCollectionRegionAccessStrategy.java From J2Cache with Apache License 2.0 | 5 votes |
@Override public void unlockItem(SharedSessionContractImplementor session, Object key, SoftLock lock) throws CacheException { try { this.actualStrategy.unlockItem(session, key, lock); } catch (NonStopCacheException nonStopCacheException) { hibernateNonstopExceptionHandler.handleNonstopCacheException(nonStopCacheException); } }
Example #25
Source File: NonstopAwareCollectionRegionAccessStrategy.java From J2Cache with Apache License 2.0 | 5 votes |
@Override public void unlockRegion(SoftLock lock) throws CacheException { try { this.actualStrategy.unlockRegion(lock); } catch (NonStopCacheException nonStopCacheException) { hibernateNonstopExceptionHandler.handleNonstopCacheException(nonStopCacheException); } }
Example #26
Source File: NonstopAwareEntityRegionAccessStrategy.java From J2Cache with Apache License 2.0 | 5 votes |
@Override public boolean afterUpdate(SharedSessionContractImplementor session, Object key, Object value, Object currentVersion, Object previousVersion, SoftLock lock) throws CacheException { try { return this.actualStrategy.afterUpdate(session, key, value, currentVersion, previousVersion, lock); } catch (NonStopCacheException nonStopCacheException) { hibernateNonstopExceptionHandler.handleNonstopCacheException(nonStopCacheException); return false; } }
Example #27
Source File: AbstractReadWriteJ2CacheAccessStrategy.java From J2Cache with Apache License 2.0 | 5 votes |
public final void unlockItem(SharedSessionContractImplementor session, Object key, SoftLock lock) throws CacheException { region().writeLock(key); try { final Lockable item = (Lockable) region().get(key); if ((item != null) && item.isUnlockable(lock)) { decrementLock(key, (Lock) item); } else { handleLockExpiry(key, item); } } finally { region().writeUnlock(key); } }
Example #28
Source File: NonstopAwareEntityRegionAccessStrategy.java From J2Cache with Apache License 2.0 | 5 votes |
@Override public void unlockRegion(SoftLock lock) throws CacheException { try { this.actualStrategy.unlockRegion(lock); } catch (NonStopCacheException nonStopCacheException) { hibernateNonstopExceptionHandler.handleNonstopCacheException(nonStopCacheException); } }
Example #29
Source File: NonstopAwareEntityRegionAccessStrategy.java From J2Cache with Apache License 2.0 | 5 votes |
@Override public void unlockItem(SharedSessionContractImplementor session, Object key, SoftLock lock) throws CacheException { try { this.actualStrategy.unlockItem(session, key, lock); } catch (NonStopCacheException nonStopCacheException) { hibernateNonstopExceptionHandler.handleNonstopCacheException(nonStopCacheException); } }
Example #30
Source File: NonstopAwareEntityRegionAccessStrategy.java From J2Cache with Apache License 2.0 | 5 votes |
@Override public SoftLock lockItem(SharedSessionContractImplementor session, Object key, Object version) throws CacheException { try { return this.actualStrategy.lockItem(session, key, version); } catch (NonStopCacheException nonStopCacheException) { hibernateNonstopExceptionHandler.handleNonstopCacheException(nonStopCacheException); return null; } }