Package railo.runtime.functions.cache

Source Code of railo.runtime.functions.cache.CacheGetDefaultCacheName

package railo.runtime.functions.cache;

import railo.runtime.PageContext;
import railo.runtime.cache.CacheConnection;
import railo.runtime.config.ConfigImpl;
import railo.runtime.exp.ExpressionException;
import railo.runtime.exp.FunctionException;
import railo.runtime.exp.PageException;
import railo.runtime.ext.function.Function;

/**
*
*/
public final class CacheGetDefaultCacheName implements Function {

  private static final long serialVersionUID = 6115589794465960484L;

  public static String call(PageContext pc, String strType) throws PageException {
    int type = Util.toType(strType,ConfigImpl.CACHE_DEFAULT_NONE);
    if(type==ConfigImpl.CACHE_DEFAULT_NONE)
      throw new FunctionException(pc,"CacheGetDefaultCacheName",1,"type","invalid type defintion ["+strType+"], valid types are [object,resource,template,query]");
   
    ConfigImpl config=(ConfigImpl) pc.getConfig();
    CacheConnection conn = config.getCacheDefaultConnection(type);
    if(conn==null)
      throw new ExpressionException("there is no default cache defined for type ["+strType+"]");
   
    return conn.getName();
  }
}
TOP

Related Classes of railo.runtime.functions.cache.CacheGetDefaultCacheName

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.