@Override public Object getFromCache(Object key, SharedSessionContractImplementor session) { try { final Element element = getCache().get( key ); if ( element == null ) { return null; } else { return element.getObjectValue(); } } catch (net.sf.ehcache.CacheException e) { if ( e instanceof NonStopCacheException ) { HibernateNonstopCacheExceptionHandler.getInstance() .handleNonstopCacheException( (NonStopCacheException) e ); return null; } else { throw new CacheException( e ); } } }
/** * {@inheritDoc} */ public CollectionRegionAccessStrategy createCollectionRegionAccessStrategy(EhcacheCollectionRegion collectionRegion, AccessType accessType) { return new NonstopAwareCollectionRegionAccessStrategy(actualFactory.createCollectionRegionAccessStrategy(collectionRegion, accessType), HibernateNonstopCacheExceptionHandler.getInstance()); }
/** * {@inheritDoc} */ public EntityRegionAccessStrategy createEntityRegionAccessStrategy(EhcacheEntityRegion entityRegion, AccessType accessType) { return new NonstopAwareEntityRegionAccessStrategy(actualFactory.createEntityRegionAccessStrategy(entityRegion, accessType), HibernateNonstopCacheExceptionHandler.getInstance()); }
/** * {@inheritDoc} * * @see org.hibernate.cache.access.EntityRegionAccessStrategy#removeAll() */ public void removeAll() throws CacheException { try { actualStrategy.removeAll(); } catch (NonStopCacheException nonStopCacheException) { hibernateNonstopExceptionHandler.handleNonstopCacheException(nonStopCacheException); } }
@Override public void evictData(Object key) { try { getCache().remove( key ); } catch (ClassCastException | IllegalStateException e) { throw new CacheException( e ); } catch (net.sf.ehcache.CacheException e) { if ( e instanceof NonStopCacheException ) { HibernateNonstopCacheExceptionHandler.getInstance() .handleNonstopCacheException( (NonStopCacheException) e ); } else { throw new CacheException( e ); } } }
/** * {@inheritDoc} * * @see org.hibernate.cache.access.EntityRegionAccessStrategy#unlockItem(java.lang.Object, org.hibernate.cache.access.SoftLock) */ public void unlockItem(Object key, SoftLock lock) throws CacheException { try { actualStrategy.unlockItem(key, lock); } catch (NonStopCacheException nonStopCacheException) { hibernateNonstopExceptionHandler.handleNonstopCacheException(nonStopCacheException); } }
@Override public void evictData() { try { getCache().removeAll(); } catch (IllegalStateException e) { throw new CacheException( e ); } catch (net.sf.ehcache.CacheException e) { if ( e instanceof NonStopCacheException ) { HibernateNonstopCacheExceptionHandler.getInstance() .handleNonstopCacheException( (NonStopCacheException) e ); } else { throw new CacheException( e ); } } }
/** * {@inheritDoc} * * @see org.hibernate.cache.access.EntityRegionAccessStrategy#removeAll() */ public void removeAll() throws CacheException { try { actualStrategy.removeAll(); } catch (NonStopCacheException nonStopCacheException) { hibernateNonstopExceptionHandler.handleNonstopCacheException(nonStopCacheException); } }
@Override public void putIntoCache(Object key, Object value, SharedSessionContractImplementor session) { try { final Element element = new Element( key, value ); getCache().put( element ); } catch (IllegalArgumentException | IllegalStateException e) { throw new CacheException( e ); } catch (net.sf.ehcache.CacheException e) { if ( e instanceof NonStopCacheException ) { HibernateNonstopCacheExceptionHandler.getInstance() .handleNonstopCacheException( (NonStopCacheException) e ); } else { throw new CacheException( e ); } } }
/** * {@inheritDoc} * * @see org.hibernate.cache.access.EntityRegionAccessStrategy#remove(java.lang.Object) */ public void remove(Object key) throws CacheException { try { actualStrategy.remove(key); } catch (NonStopCacheException nonStopCacheException) { hibernateNonstopExceptionHandler.handleNonstopCacheException(nonStopCacheException); } }
@Override public void release() { try { getCache().getCacheManager().removeCache( getCache().getName() ); } catch (IllegalStateException e) { //When Spring and Hibernate are both involved this will happen in normal shutdown operation. //Do not throw an exception, simply log this one. LOG.debug( "This can happen if multiple frameworks both try to shutdown ehcache", e ); } catch (net.sf.ehcache.CacheException e) { if ( e instanceof NonStopCacheException ) { HibernateNonstopCacheExceptionHandler.getInstance() .handleNonstopCacheException( (NonStopCacheException) e ); } else { throw new CacheException( e ); } } } }
/** * {@inheritDoc} * * @see org.hibernate.cache.access.EntityRegionAccessStrategy#evict(java.lang.Object) */ public void evict(Object key) throws CacheException { try { actualStrategy.evict(key); } catch (NonStopCacheException nonStopCacheException) { hibernateNonstopExceptionHandler.handleNonstopCacheException(nonStopCacheException); } }
/** * {@inheritDoc} * * @see org.hibernate.cache.access.EntityRegionAccessStrategy#remove(java.lang.Object) */ public void remove(Object key) throws CacheException { try { actualStrategy.remove(key); } catch (NonStopCacheException nonStopCacheException) { hibernateNonstopExceptionHandler.handleNonstopCacheException(nonStopCacheException); } }
/** * {@inheritDoc} * * @see org.hibernate.cache.access.EntityRegionAccessStrategy#evict(java.lang.Object) */ public void evict(Object key) throws CacheException { try { actualStrategy.evict(key); } catch (NonStopCacheException nonStopCacheException) { hibernateNonstopExceptionHandler.handleNonstopCacheException(nonStopCacheException); } }
/** * {@inheritDoc} * * @see org.hibernate.cache.access.EntityRegionAccessStrategy#evictAll() */ public void evictAll() throws CacheException { try { actualStrategy.evictAll(); } catch (NonStopCacheException nonStopCacheException) { hibernateNonstopExceptionHandler.handleNonstopCacheException(nonStopCacheException); } }
/** * {@inheritDoc} * * @see org.hibernate.cache.access.EntityRegionAccessStrategy#unlockItem(java.lang.Object, org.hibernate.cache.access.SoftLock) */ public void unlockItem(Object key, SoftLock lock) throws CacheException { try { actualStrategy.unlockItem(key, lock); } catch (NonStopCacheException nonStopCacheException) { hibernateNonstopExceptionHandler.handleNonstopCacheException(nonStopCacheException); } }
/** * {@inheritDoc} * * @see org.hibernate.cache.access.EntityRegionAccessStrategy#unlockRegion(org.hibernate.cache.access.SoftLock) */ public void unlockRegion(SoftLock lock) throws CacheException { try { actualStrategy.unlockRegion(lock); } catch (NonStopCacheException nonStopCacheException) { hibernateNonstopExceptionHandler.handleNonstopCacheException(nonStopCacheException); } }
/** * {@inheritDoc} * * @see org.hibernate.cache.access.EntityRegionAccessStrategy#get(java.lang.Object, long) */ public Object get(Object key, long txTimestamp) throws CacheException { try { return actualStrategy.get(key, txTimestamp); } catch (NonStopCacheException nonStopCacheException) { hibernateNonstopExceptionHandler.handleNonstopCacheException(nonStopCacheException); return null; } }
/** * {@inheritDoc} * * @see org.hibernate.cache.access.EntityRegionAccessStrategy#lockItem(java.lang.Object, java.lang.Object) */ public SoftLock lockItem(Object key, Object version) throws CacheException { try { return actualStrategy.lockItem(key, version); } catch (NonStopCacheException nonStopCacheException) { hibernateNonstopExceptionHandler.handleNonstopCacheException(nonStopCacheException); return null; } }
/** * {@inheritDoc} * * @see org.hibernate.cache.access.EntityRegionAccessStrategy#evictAll() */ public void evictAll() throws CacheException { try { actualStrategy.evictAll(); } catch (NonStopCacheException nonStopCacheException) { hibernateNonstopExceptionHandler.handleNonstopCacheException(nonStopCacheException); } }