package com.iamberry.wechat.utils;

import freemarker.template.Version;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import freemarker.ext.beans.BeansWrapper;
import freemarker.template.TemplateHashModel;
import freemarker.template.TemplateModelException;

/**
 * 增加调用静态方法的类
 * @author 献
 * @company 深圳爱贝源科技有限公司
 * @website www.iamberry.com
 * @tel 18271840547
 * @date 2017/5/15
 */
public class StaticModelUtil {

    private static Logger logger = LoggerFactory.getLogger(StaticModelUtil.class);
    private final static BeansWrapper wrapper = new BeansWrapper(new Version(2, 3, 25));
    private final static TemplateHashModel staticModels = wrapper.getStaticModels();

    public static TemplateHashModel useStaticPacker(String className) {
        TemplateHashModel fileStatics = null;
        try {
            fileStatics = (TemplateHashModel) staticModels.get(className);
        } catch (TemplateModelException e) {
            logger.error("", e);
        }
        return fileStatics;
    }
}
