• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java NeedsRefreshException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.opensymphony.oscache.base.NeedsRefreshException的典型用法代码示例。如果您正苦于以下问题:Java NeedsRefreshException类的具体用法?Java NeedsRefreshException怎么用?Java NeedsRefreshException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



NeedsRefreshException类属于com.opensymphony.oscache.base包,在下文中一共展示了NeedsRefreshException类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
 
开发者ID:lazerdye,项目名称:arrowheadasp,代码行数:26,代码来源:OSCacheScriptCache.java


示例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;
}
 
开发者ID:wangko27,项目名称:SelfSoftShop,代码行数:27,代码来源:SettingUtil.java


示例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;
}
 
开发者ID:gocd,项目名称:gocd,代码行数:23,代码来源:StageSqlMapDao.java


示例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;
}
 
开发者ID:mybatis,项目名称:ibatis-2,代码行数:21,代码来源:OSCacheController.java


示例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;
	}
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:10,代码来源:OSCache.java


示例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;
}
 
开发者ID:lodsve,项目名称:lodsve-framework,代码行数:11,代码来源:OscacheCache.java


示例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;
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:33,代码来源:OsCacheFacade.java


示例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;
	}
 
开发者ID:bignippleboy,项目名称:ipaas,代码行数:12,代码来源:FwOSCacheService.java


示例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;
}
 
开发者ID:wangko27,项目名称:SelfSoftShop,代码行数:44,代码来源:TemplateConfigUtil.java


示例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;
	}

}
 
开发者ID:545473750,项目名称:zswxsqxt,代码行数:17,代码来源:DicCache.java


示例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;
	}
}
 
开发者ID:545473750,项目名称:zswxsqxt,代码行数:15,代码来源:SysVariableCache.java


示例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();
}
 
开发者ID:sobkowiak,项目名称:aspectj-in-action-code,代码行数:8,代码来源:CacheAspectTest.java


示例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;
}
 
开发者ID:javalite,项目名称:activejdbc,代码行数:15,代码来源:OSCacheManager.java


示例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;
  }
}
 
开发者ID:mybatis,项目名称:ibatis-2,代码行数:11,代码来源:OSCacheController.java


示例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;
}
 
开发者ID:wangko27,项目名称:SelfSoftShop,代码行数:47,代码来源:LogConfigUtil.java


示例16: getPageTemplateConfig

import com.opensymphony.oscache.base.NeedsRefreshException; //导入依赖的package包/类
/**
 * 根据名称获取PageTemplateConfig对象
 * 
 * @return PageTemplateConfig对象
 */
public static PageTemplateConfig getPageTemplateConfig(String name) {
	PageTemplateConfig pageTemplateConfig = null;
	String cacheKey = TEMPLATE_CACHE_KEY_PREFIX + "_PAGE_" + name;
	logger.info("cacheKey:"+cacheKey);
	GeneralCacheAdministrator generalCacheAdministrator = (GeneralCacheAdministrator) SpringUtil.getBean(CACHE_MANAGER_BEAN_NAME);
	try {
		pageTemplateConfig = (PageTemplateConfig) generalCacheAdministrator.getFromCache(cacheKey);
	} catch (NeedsRefreshException needsRefreshException) {
		boolean updateSucceeded = false;
		try {
			Document document = null;
			try {
				File templateXmlFile = new File(CommonUtil.getWebRootPath() + TEMPLATE_XML_FILE_PATH);

		        logger.info("templateXmlFile path:"+templateXmlFile.getAbsolutePath());
				SAXReader saxReader = new SAXReader();
				document = saxReader.read(templateXmlFile);
			} catch (Exception e) {
				e.printStackTrace();
			}
			Element element = (Element)document.selectSingleNode("/shopxx/page/" + name);
			String description = element.element("description").getTextTrim();
			String templatePath = element.element("templatePath").getTextTrim();
			
			pageTemplateConfig = new PageTemplateConfig();
			if (element.element("htmlPath") != null) {
				String htmlPath = element.element("htmlPath").getTextTrim();
				pageTemplateConfig.setHtmlPath(htmlPath);
			}
			pageTemplateConfig.setName(element.getName());
			pageTemplateConfig.setDescription(description);
			pageTemplateConfig.setTemplatePath(templatePath);
			
			generalCacheAdministrator.putInCache(cacheKey, pageTemplateConfig);
			updateSucceeded = true;
		} finally {
            if (!updateSucceeded) {
            	generalCacheAdministrator.cancelUpdate(cacheKey);
            }
        }
	}
	return pageTemplateConfig;
}
 
开发者ID:wangko27,项目名称:SelfSoftShop,代码行数:49,代码来源:TemplateConfigUtil.java



注:本文中的com.opensymphony.oscache.base.NeedsRefreshException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PersistentManager类代码示例发布时间:2022-05-22
下一篇:
Java WebApplicationType类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap