當前位置: 首頁>>代碼示例>>Java>>正文


Java CacheException類代碼示例

本文整理匯總了Java中lucee.commons.io.cache.exp.CacheException的典型用法代碼示例。如果您正苦於以下問題:Java CacheException類的具體用法?Java CacheException怎麽用?Java CacheException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


CacheException類屬於lucee.commons.io.cache.exp包,在下文中一共展示了CacheException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getCacheEntry

import lucee.commons.io.cache.exp.CacheException; //導入依賴的package包/類
public CacheEntry getCacheEntry(String key) throws CacheException {
	try {
		misses++;
		Element el = getCache().get(key);
		if(el==null)throw new CacheException("there is no entry in cache with key ["+key+"]");
		hits++;
		misses--;
		return new EHCacheEntry(el);
	}
	catch(IllegalStateException ise) {
		throw new CacheException(ise.getMessage());
	}
	catch(net.sf.ehcache.CacheException ce) {
		throw new CacheException(ce.getMessage());
	}
}
 
開發者ID:lucee,項目名稱:Lucee4,代碼行數:17,代碼來源:EHCache.java

示例2: getValue

import lucee.commons.io.cache.exp.CacheException; //導入依賴的package包/類
@Override
public Object getValue(String key) throws CacheException {
	try {
		misses++;
		Element el = getCache().get(key);
		if(el==null)throw new CacheException("there is no entry in cache with key ["+key+"]");
		misses--;
		hits++;
		return el.getObjectValue();
	}
	catch(IllegalStateException ise) {
		throw new CacheException(ise.getMessage());
	}
	catch(net.sf.ehcache.CacheException ce) {
		throw new CacheException(ce.getMessage());
	}
}
 
開發者ID:lucee,項目名稱:Lucee4,代碼行數:18,代碼來源:EHCache.java

示例3: call

import lucee.commons.io.cache.exp.CacheException; //導入依賴的package包/類
public static Object call(PageContext pc,Struct properties) throws PageException {
	try {
		Object obj=properties.removeEL(OBJECT_TYPE); 
		String objectType=Caster.toString(obj);
		
		CacheConnection[] conns=getCaches(pc,objectType);
		for(int i=0;i<conns.length;i++){
			setProperties(conns[i],properties);
		}
	} catch (CacheException e) {
		throw Caster.toPageException(e);
	}
	
	
	return call(pc, null);
}
 
開發者ID:lucee,項目名稱:Lucee4,代碼行數:17,代碼來源:CacheSetProperties.java

示例4: CacheConnectionImpl

import lucee.commons.io.cache.exp.CacheException; //導入依賴的package包/類
public CacheConnectionImpl(Config config,String name, Class clazz, Struct custom, boolean readOnly, boolean storage) throws CacheException {
	this.name=name;
	this.clazz=clazz;
	if(!Reflector.isInstaneOf(clazz, Cache.class))
		throw new CacheException("class ["+clazz.getName()+"] does not implement interface ["+Cache.class.getName()+"]");
	this.custom=custom;
	this.readOnly=readOnly;
	this.storage=storage;
}
 
開發者ID:lucee,項目名稱:Lucee4,代碼行數:10,代碼來源:CacheConnectionImpl.java

示例5: noCache

import lucee.commons.io.cache.exp.CacheException; //導入依賴的package包/類
private static CacheException noCache(Config config, String cacheName) {
	StringBuilder sb=new StringBuilder("there is no cache defined with name [").append(cacheName).append("], available caches are [");
	Iterator<String> it = ((ConfigImpl)config).getCacheConnections().keySet().iterator();
	if(it.hasNext()){
		sb.append(it.next());
	}
	while(it.hasNext()){
		sb.append(", ").append(it.next());
	}
	sb.append("]");
	
	return new CacheException(sb.toString());
}
 
開發者ID:lucee,項目名稱:Lucee4,代碼行數:14,代碼來源:Util.java

示例6: getCaches

import lucee.commons.io.cache.exp.CacheException; //導入依賴的package包/類
private static CacheConnection[] getCaches(PageContext pc,String cacheName) throws CacheException {
	ConfigImpl config=(ConfigImpl) pc.getConfig();
	if(StringUtil.isEmpty(cacheName)){
		
		return new CacheConnection[]{
				config.getCacheDefaultConnection(ConfigImpl.CACHE_DEFAULT_OBJECT),
				config.getCacheDefaultConnection(ConfigImpl.CACHE_DEFAULT_TEMPLATE)
		}
		;
		// MUST which one is first
	}
	
	ArrayList<CacheConnection> list=new ArrayList<CacheConnection>();
	String name;
	String[] names=ListUtil.listToStringArray(cacheName, ',');
	for(int i=0;i<names.length;i++){
		name=names[i].trim().toLowerCase();
		if(name.equalsIgnoreCase("template"))
			list.add(config.getCacheDefaultConnection(ConfigImpl.CACHE_DEFAULT_TEMPLATE));
		else if(name.equalsIgnoreCase("object"))
			list.add(config.getCacheDefaultConnection(ConfigImpl.CACHE_DEFAULT_OBJECT));
		else{
			CacheConnection cc= config.getCacheConnections().get(name);
			if(cc==null) throw new CacheException("there is no cache defined with name ["+name+"]");
			list.add(cc);
		}
	}
	return list.toArray(new CacheConnection[list.size()]);
}
 
開發者ID:lucee,項目名稱:Lucee4,代碼行數:30,代碼來源:CacheSetProperties.java

示例7: toCacheConnection

import lucee.commons.io.cache.exp.CacheException; //導入依賴的package包/類
public static CacheConnection toCacheConnection(Config config,String name,Struct data) throws ApplicationException, CacheException, ClassException, BundleException {
	// class definition
	String className = Caster.toString(data.get(KeyConstants._class,null),null);
	if(StringUtil.isEmpty(className)) throw new ApplicationException("missing key class in struct the defines a cachec connection");
	ClassDefinition cd=new ClassDefinitionImpl(
		className
		, Caster.toString(data.get(KeyConstants._bundleName,null),null)
		, Caster.toString(data.get(KeyConstants._bundleVersion,null),null)
		, config.getIdentification()
	);
	
	
	CacheConnectionImpl cc = new CacheConnectionImpl(config,name,cd
			,Caster.toStruct(data.get(KeyConstants._custom,null),null)
			,Caster.toBooleanValue(data.get(KeyConstants._readonly,null),false)
			,Caster.toBooleanValue(data.get(KeyConstants._storage,null),false)
	);
	String id=cc.id();
	CacheConnection icc = initCacheConnections.get(id);
	if(icc!=null)return icc;
	try {
		Method m = cd.getClazz().getMethod("init", new Class[] { Config.class, String[].class, Struct[].class });
		if(Modifier.isStatic(m.getModifiers()))
			m.invoke(null, new Object[] { config, new String[]{cc.getName()},new Struct[]{cc.getCustom()}});
		else
			SystemOut.print(config.getErrWriter(), "method [init(Config,String[],Struct[]):void] for class [" + cd.toString() + "] is not static");
		
		initCacheConnections.put(id,cc);
	}
	catch(Throwable t) {ExceptionUtil.rethrowIfNecessary(t);}
	
	return cc;
	
}
 
開發者ID:lucee,項目名稱:Lucee,代碼行數:35,代碼來源:ModernApplicationContext.java

示例8: noCache

import lucee.commons.io.cache.exp.CacheException; //導入依賴的package包/類
public static CacheException noCache(Config config, String cacheName) {
	StringBuilder sb=new StringBuilder("there is no cache defined with name [").append(cacheName).append("], available caches are [");
	Iterator<String> it = ((ConfigImpl)config).getCacheConnections().keySet().iterator();
	if(it.hasNext()){
		sb.append(it.next());
	}
	while(it.hasNext()){
		sb.append(", ").append(it.next());
	}
	sb.append("]");
	
	return new CacheException(sb.toString());
}
 
開發者ID:lucee,項目名稱:Lucee,代碼行數:14,代碼來源:CacheUtil.java

示例9: CacheConnectionImpl

import lucee.commons.io.cache.exp.CacheException; //導入依賴的package包/類
private CacheConnectionImpl(Config config,String name, ClassDefinition<Cache> cd, Class<Cache> clazz, Struct custom, boolean readOnly, boolean storage) throws CacheException {
	this.name=name;
	this.classDefinition=cd;
	this.clazz=clazz;
	if(!Reflector.isInstaneOf(clazz, Cache.class))
		throw new CacheException("class ["+clazz.getName()+"] does not implement interface ["+Cache.class.getName()+"]");
	this.custom=custom==null?new StructImpl():custom;
	this.readOnly=readOnly;
	this.storage=storage;
}
 
開發者ID:lucee,項目名稱:Lucee,代碼行數:11,代碼來源:CacheConnectionImpl.java

示例10: getCaches

import lucee.commons.io.cache.exp.CacheException; //導入依賴的package包/類
private static CacheConnection[] getCaches(PageContext pc,String cacheName) throws CacheException {
	ConfigImpl config=(ConfigImpl) pc.getConfig();
	if(StringUtil.isEmpty(cacheName)){
		
		return new CacheConnection[]{
				config.getCacheDefaultConnection(Config.CACHE_TYPE_OBJECT),
				config.getCacheDefaultConnection(Config.CACHE_TYPE_TEMPLATE)
		}
		;
		// MUST which one is first
	}
	
	ArrayList<CacheConnection> list=new ArrayList<CacheConnection>();
	String name;
	String[] names=ListUtil.listToStringArray(cacheName, ',');
	for(int i=0;i<names.length;i++){
		name=names[i].trim().toLowerCase();
		if(name.equalsIgnoreCase("template"))
			list.add(config.getCacheDefaultConnection(Config.CACHE_TYPE_TEMPLATE));
		else if(name.equalsIgnoreCase("object"))
			list.add(config.getCacheDefaultConnection(Config.CACHE_TYPE_OBJECT));
		else{
			CacheConnection cc= config.getCacheConnections().get(name);
			if(cc==null) throw new CacheException("there is no cache defined with name ["+name+"]");
			list.add(cc);
		}
	}
	return list.toArray(new CacheConnection[list.size()]);
}
 
開發者ID:lucee,項目名稱:Lucee,代碼行數:30,代碼來源:CacheSetProperties.java

示例11: getCacheConnection

import lucee.commons.io.cache.exp.CacheException; //導入依賴的package包/類
public CacheConnection getCacheConnection(String cacheName) throws CacheException {
	cacheName=cacheName.toLowerCase().trim();
	
	CacheConnection cc=null;
	if(getApplicationContext()!=null) cc = ((ApplicationContextSupport)getApplicationContext()).getCacheConnection(cacheName,null);
	if(cc==null) cc= config.getCacheConnections().get(cacheName);
	if(cc==null) throw CacheUtil.noCache(config,cacheName);
	
	return cc;
}
 
開發者ID:lucee,項目名稱:Lucee,代碼行數:11,代碼來源:PageContextImpl.java

示例12: getCacheEntry

import lucee.commons.io.cache.exp.CacheException; //導入依賴的package包/類
@Override
public CacheEntry getCacheEntry(String key) throws CacheException {
	CacheEntry ce = getCacheEntry(key, null);
	if(ce!=null) return ce;
	throw new CacheException("The document with key [" + key + "] has not been found int this cache.");
}
 
開發者ID:lucee,項目名稱:extension-mongodb,代碼行數:7,代碼來源:MongoDBCache.java

示例13: delete

import lucee.commons.io.cache.exp.CacheException; //導入依賴的package包/類
public void delete(String key,boolean throwWhenNotExists) throws IOException {
	if(!cache.remove(key) && throwWhenNotExists)
		throw new CacheException("there is no entry in cache with key ["+key+"]");
}
 
開發者ID:lucee,項目名稱:Lucee4,代碼行數:5,代碼來源:CacheEngine.java

示例14: getCacheEntry

import lucee.commons.io.cache.exp.CacheException; //導入依賴的package包/類
@Override
public CacheEntry getCacheEntry(String key) throws IOException {
	CacheEntry entry = getCacheEntry(key, null);
	if(entry==null) throw new CacheException("there is no valid cache entry with key ["+key+"]");
	return entry;
}
 
開發者ID:lucee,項目名稱:Lucee4,代碼行數:7,代碼來源:CacheSupport.java

示例15: getQuiet

import lucee.commons.io.cache.exp.CacheException; //導入依賴的package包/類
public CacheEntry getQuiet(String key) throws IOException {
	CacheEntry entry = getQuiet(key, null);
	if(entry==null) throw new CacheException("there is no valid cache entry with key ["+key+"]");
	return entry;
}
 
開發者ID:lucee,項目名稱:Lucee4,代碼行數:6,代碼來源:CacheSupport.java


注:本文中的lucee.commons.io.cache.exp.CacheException類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。