本文整理汇总了Java中com.opensymphony.oscache.base.NeedsRefreshException类的典型用法代码示例。如果您正苦于以下问题:Java NeedsRefreshException类的具体用法?Java NeedsRefreshException怎么用?Java NeedsRefreshException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NeedsRefreshException类属于com.opensymphony.oscache.base包,在下文中一共展示了NeedsRefreshException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: get
import com.opensymphony.oscache.base.NeedsRefreshException; //导入依赖的package包/类
/**
* Get the cached script specified by the given filename/context.
* @see ScriptCache#get(String, AspContext)
*/
public synchronized CachedScript get(String filename, AspContext context) {
if (LOG.isDebugEnabled()) {
LOG.debug("Get: " + filename);
}
CachedScript script;
try {
script = (CachedScript)cache.getFromCache(filename);
script.fileFactory.setContext(context);
if (LOG.isDebugEnabled()) {
LOG.debug("Old cached.");
LOG.debug("Node: " + script.node);
}
} catch(NeedsRefreshException ex) {
if (LOG.isDebugEnabled()) {
LOG.debug("Needs refreshed: " + ex.toString());
}
script = new CachedScript(context);
cache.putInCache(filename, script);
};
return script;
}
示例2: getSetting
import com.opensymphony.oscache.base.NeedsRefreshException; //导入依赖的package包/类
/**
* 获取系统配置信息
*
* @return Setting
*/
public static Setting getSetting() {
Setting setting = null;
GeneralCacheAdministrator generalCacheAdministrator = (GeneralCacheAdministrator) SpringUtil.getBean(CACHE_MANAGER_BEAN_NAME);
try {
setting = (Setting) generalCacheAdministrator.getFromCache(SETTING_CACHE_KEY);
} catch (NeedsRefreshException needsRefreshException) {
boolean updateSucceeded = false;
try {
setting = readSetting();
generalCacheAdministrator.putInCache(SETTING_CACHE_KEY, setting);
updateSucceeded = true;
} catch(Exception e) {
e.printStackTrace();
} finally {
if (!updateSucceeded) {
generalCacheAdministrator.cancelUpdate(SETTING_CACHE_KEY);
}
}
}
return setting;
}
示例3: getDurationOfLastSuccessfulOnAgent
import com.opensymphony.oscache.base.NeedsRefreshException; //导入依赖的package包/类
public Long getDurationOfLastSuccessfulOnAgent(String pipelineName, String stageName, JobInstance job) {
String key = job.getBuildDurationKey(pipelineName, stageName);
Long duration;
try {
duration = (Long) cache.getFromCache(key, CacheEntry.INDEFINITE_EXPIRY);
} catch (NeedsRefreshException nre) {
boolean updated = false;
try {
duration = recalculateBuildDuration(pipelineName, stageName, job);
cache.putInCache(key, duration);
updated = true;
} finally {
if (!updated) {
// It is essential that cancelUpdate is called if the
// cached content could not be rebuilt
cache.cancelUpdate(key);
LOGGER.warn("refresh cancelled for {}", key);
}
}
}
return duration;
}
示例4: removeObject
import com.opensymphony.oscache.base.NeedsRefreshException; //导入依赖的package包/类
public Object removeObject(CacheModel cacheModel, Object key) {
Object result;
String keyString = key.toString();
try {
int refreshPeriod = (int) (cacheModel.getFlushIntervalSeconds());
Object value = CACHE.getFromCache(keyString, refreshPeriod);
if (value != null) {
CACHE.flushEntry(keyString);
}
result = value;
} catch (NeedsRefreshException e) {
try {
CACHE.flushEntry(keyString);
} finally {
CACHE.cancelUpdate(keyString);
result = null;
}
}
return result;
}
示例5: get
import com.opensymphony.oscache.base.NeedsRefreshException; //导入依赖的package包/类
public Object get(Object key) throws CacheException {
try {
return cache.getFromCache( toString(key), refreshPeriod, cron );
}
catch (NeedsRefreshException e) {
cache.cancelUpdate( toString(key) );
return null;
}
}
示例6: lookup
import com.opensymphony.oscache.base.NeedsRefreshException; //导入依赖的package包/类
@Override
protected Object lookup(Object key) {
Object value;
try {
value = admin.getFromCache(key.toString(), expire);
} catch (NeedsRefreshException e) {
value = null;
}
return value;
}
示例7: onGetFromCache
import com.opensymphony.oscache.base.NeedsRefreshException; //导入依赖的package包/类
/**
* @see AbstractCacheProviderFacade#onGetFromCache(Serializable,CachingModel)
*/
protected Object onGetFromCache(Serializable key, CachingModel model) {
OsCacheCachingModel cachingModel = (OsCacheCachingModel) model;
Integer refreshPeriod = cachingModel.getRefreshPeriod();
String cronExpression = cachingModel.getCronExpression();
String newKey = getEntryKey(key);
Object cachedObject = null;
try {
if (null == refreshPeriod) {
cachedObject = cacheManager.getFromCache(newKey);
} else if (null == cronExpression) {
cachedObject = cacheManager.getFromCache(newKey, refreshPeriod
.intValue());
} else {
cachedObject = cacheManager.getFromCache(newKey, refreshPeriod
.intValue(), cronExpression);
}
} catch (NeedsRefreshException needsRefreshException) {
// prevent the cache entry from being locked
// see: http://www.opensymphony.com/oscache/api/com/opensymphony/oscache/base/Cache.html#getFromCache(java.lang.String, int)
cacheManager.cancelUpdate(newKey);
}
return cachedObject;
}
示例8: get
import com.opensymphony.oscache.base.NeedsRefreshException; //导入依赖的package包/类
public Object get(String key) {
Object value = null;
try {
value = admin.getFromCache(key);
} catch (NeedsRefreshException nre) {
admin.cancelUpdate(key);
logger.debug("OSCache对key[{}]缓存get操作, 引发NeedsRefreshException", key);
}
return value;
}
示例9: getMailTemplateConfig
import com.opensymphony.oscache.base.NeedsRefreshException; //导入依赖的package包/类
/**
* 根据名称获取MailTemplateConfig对象
*
* @return MailTemplateConfig对象
*/
public static MailTemplateConfig getMailTemplateConfig(String name) {
MailTemplateConfig mailTemplateConfig = null;
String cacheKey = TEMPLATE_CACHE_KEY_PREFIX + "_MAIL_" + name;
GeneralCacheAdministrator generalCacheAdministrator = (GeneralCacheAdministrator) SpringUtil.getBean(CACHE_MANAGER_BEAN_NAME);
try {
mailTemplateConfig = (MailTemplateConfig) generalCacheAdministrator.getFromCache(cacheKey);
} catch (NeedsRefreshException needsRefreshException) {
boolean updateSucceeded = false;
try {
Document document = null;
try {
File templateXmlFile = new File(CommonUtil.getWebRootPath() + TEMPLATE_XML_FILE_PATH);
SAXReader saxReader = new SAXReader();
document = saxReader.read(templateXmlFile);
} catch (Exception e) {
e.printStackTrace();
}
Element element = (Element)document.selectSingleNode("/shopxx/mail/" + name);
String description = element.element("description").getTextTrim();
String subject = element.element("subject").getTextTrim();
String templatePath = element.element("templatePath").getTextTrim();
mailTemplateConfig = new MailTemplateConfig();
mailTemplateConfig.setName(element.getName());
mailTemplateConfig.setDescription(description);
mailTemplateConfig.setSubject(subject);
mailTemplateConfig.setTemplatePath(templatePath);
generalCacheAdministrator.putInCache(cacheKey, mailTemplateConfig);
updateSucceeded = true;
} finally {
if (!updateSucceeded) {
generalCacheAdministrator.cancelUpdate(cacheKey);
}
}
}
return mailTemplateConfig;
}
示例10: get
import com.opensymphony.oscache.base.NeedsRefreshException; //导入依赖的package包/类
/**
* 根据key标识取得对象
* @param key 标识
* @return 对象
* @throws Exception
*/
public Object get(String key) throws Exception {
try {
return this.getFromCache(KEY_PREFIX + "_" + key,
REFEESHPERIOD);
} catch (NeedsRefreshException e) {
this.cancelUpdate(KEY_PREFIX + "_" + key);
throw e;
}
}
示例11: get
import com.opensymphony.oscache.base.NeedsRefreshException; //导入依赖的package包/类
/**
* 根据key标识取得对象
* @param key 标识
* @return 对象
* @throws Exception
*/
public Object get(String key) throws Exception {
try {
return this.getFromCache(key, REFEESHPERIOD);
} catch (NeedsRefreshException e) {
this.cancelUpdate(KEY_PREFIX + "_" + key);
throw e;
}
}
示例12: cacheMiss
import com.opensymphony.oscache.base.NeedsRefreshException; //导入依赖的package包/类
@Test
public void cacheMiss() throws Exception {
when(mockCache.getFromCache("test:testArg")).thenThrow(
new NeedsRefreshException("miss"));
testService.get("testArg");
verify(mockHelper).get();
}
示例13: getCache
import com.opensymphony.oscache.base.NeedsRefreshException; //导入依赖的package包/类
@Override
public Object getCache(String group, String key) {
try {
return administrator.getFromCache(key);
} catch (NeedsRefreshException nre) {
try{
administrator.cancelUpdate(key);
}catch(Exception e){
return null;
}
}
return null;
}
示例14: getObject
import com.opensymphony.oscache.base.NeedsRefreshException; //导入依赖的package包/类
public Object getObject(CacheModel cacheModel, Object key) {
String keyString = key.toString();
try {
int refreshPeriod = (int) (cacheModel.getFlushIntervalSeconds());
return CACHE.getFromCache(keyString, refreshPeriod);
} catch (NeedsRefreshException e) {
CACHE.cancelUpdate(keyString);
return null;
}
}
示例15: getAllLogConfigList
import com.opensymphony.oscache.base.NeedsRefreshException; //导入依赖的package包/类
/**
* 获得所有日志配置集合
*
* @return 所有日志配置集合
*/
@SuppressWarnings("unchecked")
public static List<LogConfig> getAllLogConfigList() {
List<LogConfig> allLogConfigList = null;
GeneralCacheAdministrator generalCacheAdministrator = (GeneralCacheAdministrator) SpringUtil.getBean(CACHE_MANAGER_BEAN_NAME);
try {
allLogConfigList = (List<LogConfig>) generalCacheAdministrator.getFromCache(ALL_LOG_CONFIG_LIST_CACHE_KEY);
} catch (NeedsRefreshException needsRefreshException) {
boolean updateSucceeded = false;
try {
File shopxxXmlFile = null;
Document document = null;
try {
shopxxXmlFile = new ClassPathResource(SHOPXX_XML_FILE_NAME).getFile();
SAXReader saxReader = new SAXReader();
document = saxReader.read(shopxxXmlFile);
} catch (Exception e) {
e.printStackTrace();
}
List<Node> nodeList = document.selectNodes("/shopxx/logConfig/*");
Iterator<Node> iterator = nodeList.iterator();
allLogConfigList = new ArrayList<LogConfig>();
while (iterator.hasNext()) {
Element element = (Element) iterator.next();
LogConfig logConfig = new LogConfig();
logConfig.setOperation(element.attributeValue("operation"));
logConfig.setActionClass(element.attributeValue("actionClass"));
logConfig.setActionMethod(element.attributeValue("actionMethod"));
allLogConfigList.add(logConfig);
}
generalCacheAdministrator.putInCache(ALL_LOG_CONFIG_LIST_CACHE_KEY, allLogConfigList);
updateSucceeded = true;
} finally {
if (!updateSucceeded) {
generalCacheAdministrator.cancelUpdate(ALL_LOG_CONFIG_LIST_CACHE_KEY);
}
}
}
return allLogConfigList;
}