@Override public Object extractPrincipal(X509Certificate cert) { try { Element element = cache.get(cert); if (element != null) { return element.getObjectValue(); } } catch (CacheException cacheException) { throw new DataRetrievalFailureException("Cache failure: " + cacheException.getMessage()); } final Object principal = delegate.extractPrincipal(cert); cache.put(new Element(cert, principal)); return principal; } }
if ( e.getMessage().startsWith( "Cannot parseConfiguration CacheManager. Attempt to create a new instance of " + "CacheManager using the diskStorePath" "Attempt to restart an already started EhCacheRegionFactory. " + "Use sessionFactory.close() between repeated calls to buildSessionFactory. " + "Consider using SingletonEhCacheRegionFactory. Error from ehcache was: " + e.getMessage() );
if (e.getMessage().startsWith( "Cannot parseConfiguration CacheManager. Attempt to create a new instance of " + "CacheManager using the diskStorePath"))
if (e.getMessage().startsWith("Cannot parseConfiguration CacheManager. Attempt to create a new instance of " + "CacheManager using the diskStorePath")) { throw new CacheException("Attempt to restart an already started EhCacheProvider. Use sessionFactory.close() " + " between repeated calls to buildSessionFactory. Consider using SingletonEhCacheProvider. Error from " + " ehcache was: " + e.getMessage()); } else { throw e;
if (e.getMessage().startsWith( "Cannot parseConfiguration CacheManager. Attempt to create a new instance of " + "CacheManager using the diskStorePath"))
if (e.getMessage().startsWith("Cannot parseConfiguration CacheManager. Attempt to create a new instance of " + "CacheManager using the diskStorePath")) { throw new CacheException("Attempt to restart an already started EhCacheRegionFactory. " + "Use sessionFactory.close() between repeated calls to buildSessionFactory. " + "Consider using SingletonEhCacheRegionFactory. Error from ehcache was: " + e.getMessage()); } else { throw new CacheException(e);
/** * Initialize the given {@link Ehcache} without adding it to the {@link CacheManager}. * * @param cache * @param registerCacheConfig */ void initializeEhcache(final Ehcache cache, final boolean registerCacheConfig) { if (!registerCacheConfig) { cache.getCacheConfiguration().setupFor(this, registerCacheConfig, getParentCacheName(cache)); } else { cache.getCacheConfiguration().setupFor(this); } cache.setCacheManager(this); cache.setTransactionManagerLookup(transactionManagerLookup); cache.initialise(); if (!runtimeCfg.allowsDynamicCacheConfig()) { cache.disableDynamicFeatures(); } if (!registerCacheConfig) { associateShadowCache(cache); } try { cache.bootstrap(); } catch (CacheException e) { LOG.warn("Cache " + cache.getName() + "requested bootstrap but a CacheException occured. " + e.getMessage(), e); } }
public UserDetails getUserFromCache(X509Certificate userCert) { Element element = null; try { element = cache.get(userCert); } catch (CacheException cacheException) { throw new DataRetrievalFailureException("Cache failure: " + cacheException.getMessage()); } if (logger.isDebugEnabled()) { String subjectDN = "unknown"; if ((userCert != null) && (userCert.getSubjectDN() != null)) { subjectDN = userCert.getSubjectDN().toString(); } logger.debug("X.509 Cache hit. SubjectDN: " + subjectDN); } if (element == null) { return null; } else { return (UserDetails) element.getValue(); } }
@Override public UserDetails getUserFromCache(X509Certificate userCert) { Element element = null; try { element = cache.get(userCert); } catch (CacheException cacheException) { throw new DataRetrievalFailureException("Cache failure: " + cacheException.getMessage()); } if (logger.isDebugEnabled()) { String subjectDN = "unknown"; if ((userCert != null) && (userCert.getSubjectDN() != null)) { subjectDN = userCert.getSubjectDN().toString(); } logger.debug("X.509 Cache hit. SubjectDN: " + subjectDN); } if (element == null) { return null; } else { return (UserDetails) element.getObjectValue(); } }
@Override public UserDetails getUserFromCache(X509Certificate userCert) { Element element = null; try { element = cache.get(userCert); } catch (CacheException cacheException) { throw new DataRetrievalFailureException("Cache failure: " + cacheException.getMessage()); } if (logger.isDebugEnabled()) { String subjectDN = "unknown"; if ((userCert != null) && (userCert.getSubjectDN() != null)) { subjectDN = userCert.getSubjectDN().toString(); } logger.debug("X.509 Cache hit. SubjectDN: " + subjectDN); } if (element == null) { return null; } else { return (UserDetails) element.getObjectValue(); } }
public UserDetails getUserFromCache(String username) { Element element = null; try { element = cache.get(username); } catch (CacheException cacheException) { throw new DataRetrievalFailureException("Cache failure: " + cacheException.getMessage()); } if (logger.isDebugEnabled()) { logger.debug("Cache hit: " + (element != null) + "; username: " + username); } if (element == null) { return null; } else { return (UserDetails) element.getValue(); } }
@Override public UserDetails getUserFromCache(X509Certificate userCert) { Element element = null; try { element = cache.get(userCert); } catch (CacheException cacheException) { throw new DataRetrievalFailureException("Cache failure: " + cacheException.getMessage()); } if (logger.isDebugEnabled()) { String subjectDN = "unknown"; if ((userCert != null) && (userCert.getSubjectDN() != null)) { subjectDN = userCert.getSubjectDN().toString(); } logger.debug("X.509 Cache hit. SubjectDN: " + subjectDN); } if (element == null) { return null; } else { return (UserDetails) element.getObjectValue(); } }
public CasAuthenticationToken getByTicketId(String serviceTicket) { Element element = null; try { element = cache.get(serviceTicket); } catch (CacheException cacheException) { throw new DataRetrievalFailureException("Cache failure: " + cacheException.getMessage()); } if (logger.isDebugEnabled()) { logger.debug("Cache hit: " + (element != null) + "; service ticket: " + serviceTicket); } if (element == null) { return null; } else { return (CasAuthenticationToken) element.getValue(); } }
public BasicAclEntry[] getEntriesFromCache(AclObjectIdentity aclObjectIdentity) { Element element = null; try { element = cache.get(aclObjectIdentity); } catch (CacheException cacheException) { throw new DataRetrievalFailureException("Cache failure: " + cacheException.getMessage()); } // Return null if cache element has expired or not found if (element == null) { if (logger.isDebugEnabled()) { logger.debug("Cache miss: " + aclObjectIdentity); } return null; } if (logger.isDebugEnabled()) { logger.debug("Cache hit: " + (element != null) + "; object: " + aclObjectIdentity); } BasicAclEntryHolder holder = (BasicAclEntryHolder) element.getValue(); return holder.getBasicAclEntries(); }
/** * Accessor for the size of the cache. * @see org.datanucleus.cache.Level2Cache#getSize() */ public int getSize() { try { int size = defaultCache.getSize(); for (Iterator<Cache> i = caches.values().iterator(); i.hasNext();) { size += i.next().getSize(); } return size; } catch (IllegalStateException e) { NucleusLogger.CACHE.warn("Error invoking Cache.getSize : " + e.getMessage()); } catch (CacheException e) { NucleusLogger.CACHE.warn("Error invoking Cache.getSIze : " + e.getMessage()); } return 0; }
public TimeExpiryMemoryStore(Ehcache cache, Store diskStore, Object[] locks) { super(cache, diskStore); try { map = loadMapInstance(cache.getName(), locks); ((SpoolingTimeExpiryMap) map).initialize(); } catch (CacheException e) { LOG.error(cache.getName() + "Cache: Cannot start TimeExpiryMemoryStore. Initial cause was " + e.getMessage(), e); } }
/** * Accessor for the size of the cache. * @see org.datanucleus.cache.Level2Cache#getSize() */ public int getSize() { try { return cache.getSize(); } catch (IllegalStateException e) { NucleusLogger.CACHE.warn("Error invoking Cache.getSize : " + e.getMessage()); } catch (CacheException e) { NucleusLogger.CACHE.warn("Error invoking Cache.getSize : " + e.getMessage()); } return 0; }
/** * Reset the cache. */ @Override public void resetCache( ) { try { if ( _cache != null ) { _cache.removeAll( ); } } catch( IllegalStateException e ) { AppLogService.error( e.getMessage( ), e ); } catch( CacheException e ) { AppLogService.error( e.getMessage( ), e ); } }
/** * Add a new entry to the cache. * * @param key name to be used for the entry. * @param value object that is stored. * @throws CacheException in the event ehcache throws an exception it will be wrapped. */ @Override public void put( Object key, Object value ) throws CacheException { if ( cache == null ) { String error = "put detected null cache name [" + name + "]"; throw new CacheException( GlobalErrIds.FT_NULL_CACHE, error ); } try { cache.put( new Element( key, value ) ); } catch ( net.sf.ehcache.CacheException ce ) { String error = "put cache name [" + name + "] key [" + key + "] caught CacheException=" + ce.getMessage(); throw new CacheException( GlobalErrIds.FT_CACHE_PUT_ERR, error, ce ); } }
@Override public TileStore build() { try { String cache = cfg.getCacheConfiguration(); File f = new File( cache ); if ( !f.isAbsolute() ) { f = metadata.getLocation().resolveToFile( cache ); } CacheManager cmgr = new CacheManager( f.toURI().toURL() ); TileStore tileStore = workspace.getResource( TileStoreProvider.class, cfg.getTileStoreId() ); return new CachingTileStore( tileStore, cmgr, cfg.getCacheName(), metadata ); } catch ( CacheException e ) { // case needed, as NPE's inside exception can occur otherwise throw new ResourceInitException( "Unable to create tile store: " + e.getMessage() ); } catch ( Exception e ) { throw new ResourceInitException( "Unable to create tile store", e ); } }