首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

Velocity模板缓存配备

2012-12-26 
Velocity模板缓存配置velocity开启缓存,主要用于线上环境,在velocity.properties中file.resource.loader.c

Velocity模板缓存配置
velocity开启缓存,主要用于线上环境,在velocity.properties中

file.resource.loader.cache = truefile.resource.loader.modificationCheckInterval = -1


拨开读取模板代码:

Template t = getTemplate(stack, velocityManager.getVelocityEngine(), invocation, finalLocation, encoding);VelocityResult.java :protected Template getTemplate(ValueStack stack, VelocityEngine velocity, ActionInvocation invocation, String location, String encoding) throws Exception {        if (!location.startsWith("/")) {            location = invocation.getProxy().getNamespace() + "/" + location;        }        Template template = velocity.getTemplate(location, encoding);        return template;    }VelocityEngine.javapublic Template getTemplate(String name, String encoding)        throws ResourceNotFoundException, ParseErrorException, Exception    {        return ri.getTemplate( name, encoding );    }RuntimeInstance.javapublic Template getTemplate(String name, String  encoding)        throws ResourceNotFoundException, ParseErrorException, Exception    {        requireInitialization();        return (Template)                resourceManager.getResource(name,                    ResourceManager.RESOURCE_TEMPLATE, encoding);    }ResourceManagerImpl.javapublic Resource getResource(final String resourceName, final int resourceType, final String encoding)        throws ResourceNotFoundException,            ParseErrorException,            Exception    {        String resourceKey = resourceType + resourceName;        Resource resource = globalCache.get(resourceKey);ResourceCacheImpl.javapublic Resource get( Object key )    {        return (Resource) cache.get( key );    }

热点排行