本文整理匯總了Java中net.sf.ehcache.CacheException.getMessage方法的典型用法代碼示例。如果您正苦於以下問題:Java CacheException.getMessage方法的具體用法?Java CacheException.getMessage怎麽用?Java CacheException.getMessage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net.sf.ehcache.CacheException
的用法示例。
在下文中一共展示了CacheException.getMessage方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getCache
import net.sf.ehcache.CacheException; //導入方法依賴的package包/類
public Object getCache(final Cache cache, final String cahceName) {
Element element = null;
try {
element = cache.get(cahceName);
} catch (CacheException cacheException) {
throw new DataRetrievalFailureException("Cache failure: " + cacheException.getMessage());
}
if (logger.isTraceEnabled()) {
logger.trace("Cache hit: " + (element != null) + "; Cache name: " + cahceName + " Name: " + cache.getName()
+ " ,size: " + cache.getSize());
}
if (element == null) {
return null;
} else {
return element.getValue();
}
}
示例2: get
import net.sf.ehcache.CacheException; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
@Override
public D get(UniqueId uniqueId) {
ArgumentChecker.notNull(uniqueId, "uniqueId");
// Get from cache, which in turn self-populates from the underlying master
Element element;
try {
element = getUidToDocumentCache().get(uniqueId);
} catch (CacheException e) {
throw new DataNotFoundException(e.getMessage());
}
if (element != null && element.getObjectValue() != null) {
// Debug: check result against underlying
if (TEST_AGAINST_UNDERLYING) {
D check = getUnderlying().get(uniqueId);
if (!((D) element.getObjectValue()).equals(check)) {
s_logger.error(getUidToDocumentCache().getName() + " returned:\n" + ((D) element.getObjectValue()) + "\nbut the underlying master returned:\n" + check);
}
}
return (D) element.getObjectValue();
} else {
throw new DataNotFoundException("No document found with the specified UniqueId");
}
}