Java Code Examples for freemarker.template.Configuration

The following examples show how to use freemarker.template.Configuration. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: Vert.X-generator   Source File: CreateFileUtil.java    License: MIT License 6 votes vote down vote up
/**
 * 执行创建文件
 * 
 * @param content
 *          模板所需要的上下文
 * @param templeteName
 *          模板的名字 示例:Entity.ftl
 * @param projectPath
 *          生成的项目路径 示例:D://create
 * @param packageName
 *          包名 示例:com.szmirren
 * @param fileName
 *          文件名 示例:Entity.java
 * @param codeFormat
 *          输出的字符编码格式 示例:UTF-8
 * @throws Exception
 */
public static void createFile(GeneratorContent content, String templeteName, String projectPath, String packageName, String fileName,
		String codeFormat, boolean isOverride) throws Exception {
	String outputPath = projectPath + "/" + packageName.replace(".", "/") + "/";
	if (!isOverride) {
		if (Files.exists(Paths.get(outputPath + fileName))) {
			LOG.debug("设置了文件存在不覆盖,文件已经存在,忽略本文件的创建");
			return;
		}
	}
	Configuration config = new Configuration(Configuration.VERSION_2_3_23);
	String tempPath = Paths.get(Constant.TEMPLATE_DIR_NAME).toFile().getName();
	config.setDirectoryForTemplateLoading(new File(tempPath));
	config.setObjectWrapper(new DefaultObjectWrapper(Configuration.VERSION_2_3_23));
	config.setDefaultEncoding("utf-8");
	Template template = config.getTemplate(templeteName);
	Map<String, Object> item = new HashMap<>();
	item.put("content", content);
	if (!Files.exists(Paths.get(outputPath))) {
		Files.createDirectories(Paths.get(outputPath));
	}
	try (Writer writer = new OutputStreamWriter(new FileOutputStream(outputPath + fileName), codeFormat)) {
		template.process(item, writer);
	}
}
 
Example 2
@SuppressWarnings({ "rawtypes", "unchecked" })
public static List<String> getAvailableAutoInclude(Configuration conf, List<String> autoIncludes) {
    List<String> results = new ArrayList();
    for (String autoInclude : autoIncludes) {
        autoInclude =autoInclude.replace(StringUtil.BACK_SLASH, StringUtil.SLASH);
        try {
            Template t = new Template("__auto_include_test__", new StringReader("1"), conf);
            conf.setAutoIncludes(Arrays.asList(new String[] { autoInclude }));
            t.process(new HashMap(), new StringWriter());
            results.add(autoInclude);
        } catch (Exception e) {

        }
    }
    return results;
}
 
Example 3
Source Project: aws-mock   Source File: TemplateUtilsTest.java    License: MIT License 6 votes vote down vote up
@Test(expected = AwsMockException.class)
public void Test_getProcessTemplateExceptionWithNoData() throws Exception {

    Configuration config = Mockito.mock(Configuration.class);
    Template template = Mockito.mock(Template.class);

    Whitebox.setInternalState(TemplateUtils.class, "conf", config);
    Mockito.doNothing().when(config)
            .setClassForTemplateLoading(Mockito.eq(TemplateUtils.class), Mockito.anyString());

    Mockito.when(config.getTemplate(Mockito.anyString())).thenReturn(template);
    Mockito.doThrow(new TemplateException("Forced TemplateException", null)).when(template)
            .process(Mockito.any(), Mockito.any(Writer.class));

    TemplateUtils.get(errFTemplateFile, null);

}
 
Example 4
Source Project: scipio-erp   Source File: AttributeExpander.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Gets a (String)TemplateInvoker with compiled Freemarker template for the attribute
 * content inline template.
 * <p>
 * TODO: decide cache... can make CmsAttributeTemplate-specific cache (by id or so, faster) but
 * may get memory duplication with #interpretStd calls (cached by body, because no id/name avail)
 * -> could do both at once maybe? share the Template instance between 2 cache...
 * TODO: subject to refactor/move
 * TODO?: FUTURE: this does NOT wrap the TemplateInvoker in a TemplateModel for time being...
 * we will rely on the default ObjectWrapper(s) to wrap the StringTemplateInvoker
 * in a freemarker StringModel (BeanModel) which renders throughs the ?string built-in
 * or string evaluation.
 */
public static TemplateInvoker getStringTemplateInvokerForContent(String tmplStr, Map<String, Object> ctxVars, CmsPageContext pageContext) throws TemplateException, IOException {
    Configuration config = CmsRenderTemplate.TemplateRenderer.getDefaultCmsConfig();

    // TODO: REVIEW: cache selection is a problem...
    // instead of by template body we could cache by some derivative unique name
    // derived from the CmsAttributeTemplate ID (maybe?)
    // would likely be much faster

    UtilCache<String, Template> cache = TemplateSource.getTemplateInlineSelfCacheForConfig(config, null);
    if (cache == null) {
        Debug.logWarning("Cms: could not determine"
                + " an inline template cache to use; not using cache", module);
    }
    TemplateSource templateSource = TemplateSource.getForInline(null, tmplStr, cache, config, true);

    // NOTE: must get StringInvoker so BeansWrapper's StringModel can invoke toString()
    // NOTE: context parameters could be passed to the template using InvokeOptions.ctxVars...
    // but not yet needed
    TemplateInvoker invoker = TemplateInvoker.getInvoker(templateSource, new InvokeOptions(null, null, null, ctxVars, false), null);
    return invoker;
}
 
Example 5
Source Project: mogu_blog_v2   Source File: FreemarkerTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testGenerateHtmlByString() throws IOException, TemplateException {
    //创建配置类
    Configuration configuration = new Configuration(Configuration.getVersion());
    //获取模板内容
    //模板内容,这里测试时使用简单的字符串作为模板
    String templateString = "" +
            "<html>\n" +
            "    <head></head>\n" +
            "    <body>\n" +
            "    名称:${name}\n" +
            "    </body>\n" +
            "</html>";

    //加载模板
    //模板加载器
    StringTemplateLoader stringTemplateLoader = new StringTemplateLoader();
    stringTemplateLoader.putTemplate("template", templateString);
    configuration.setTemplateLoader(stringTemplateLoader);
    Template template = configuration.getTemplate("template", "utf-8");

    //数据模型
    Map map = getMap();
    //静态化
    String content = FreeMarkerTemplateUtils.processTemplateIntoString(template, map);
    //静态化内容
    System.out.println(content);
    InputStream inputStream = IOUtils.toInputStream(content);
    //输出文件
    FileOutputStream fileOutputStream = new FileOutputStream(new File("d:/test1.html"));
    IOUtils.copy(inputStream, fileOutputStream);
}
 
Example 6
Source Project: cuba   Source File: TemplateHelper.java    License: Apache License 2.0 6 votes vote down vote up
protected static Map<String, Object> prepareParams(Map<String, ?> parameterValues) {
    Map<String, Object> parameterValuesWithStats = new HashMap<>(parameterValues);
    BeansWrapper beansWrapper = new BeansWrapperBuilder(Configuration.DEFAULT_INCOMPATIBLE_IMPROVEMENTS).build();
    parameterValuesWithStats.put("statics", beansWrapper.getStaticModels());

    @SuppressWarnings("unchecked")
    Map<String, Object> params = LazyMap.lazyMap(parameterValuesWithStats, propertyName -> {
        for (String appProperty : AppContext.getPropertyNames()) {
            if (appProperty.replace(".", "_").equals(propertyName)) {
                return AppContext.getProperty(propertyName);
            }
        }
        return null;
    });

    return params;
}
 
Example 7
Source Project: act   Source File: Service.java    License: GNU General Public License v3.0 6 votes vote down vote up
public Controller(ServiceConfig config, Configuration cfg) {
  this.serviceConfig = config;
  this.cfg = cfg;

  // Do some path munging once to ensure we can build clean URLs.
  this.wikiUrlBase = config.getWikiUrlPrefix();
  this.imagesUrlBase = config.getImageUrlPrefix();

  // Add trailing slashes so we can assume they exist later.
  if (!this.wikiUrlBase.endsWith("/")) {
    this.wikiUrlBase = this.wikiUrlBase + "/";
  }

  if (!this.imagesUrlBase.endsWith("/")) {
    this.imagesUrlBase = this.imagesUrlBase + "/";
  }
}
 
Example 8
/**
 * Generates the text content for the plain password SOAP message.
 * <p>
 * This will be created from a freemarker template.
 *
 * @param path
 *            path to the freemarker template
 * @param user
 *            username to use
 * @param password
 *            password to use
 * @return the text content for the plain passworde message
 * @throws Exception
 *             if any error occurs during the message creation
 */
private static final String getPlainPasswordMessageContent(
        final String path, final String user, final String password)
        throws Exception {
    final Template template; // Freemarker template
    final Map<String, Object> data; // Data for the template
    final ByteArrayOutputStream out; // Steam with the message

    // Prepares the data for the template
    data = new HashMap<String, Object>();
    data.put("user", user);
    data.put("password", password);

    // Processes the template to the output
    out = new ByteArrayOutputStream();
    template = new Configuration(Configuration.VERSION_2_3_0)
            .getTemplate(path);
    template.process(data, new OutputStreamWriter(out));

    return new String(out.toByteArray());
}
 
Example 9
private String determineTemplateName(final String messageTemplateLocation,
                                     final String defaultMessageTemplateName,
                                     final Configuration freeMarkerCfg) {
    String templateName;

    if (messageTemplateLocation != null && messageTemplateLocation.length() > 0) {
        final File messageTemplateFile = new File(messageTemplateLocation);
        try {
            freeMarkerCfg.setDirectoryForTemplateLoading(messageTemplateFile.getParentFile());
        } catch (IOException ioEx) {
            throw new HipChatNotificationPluginException("Error setting FreeMarker template loading directory: [" + ioEx.getMessage() + "].", ioEx);
        }
        templateName = messageTemplateFile.getName();

    } else {
        freeMarkerCfg.setClassForTemplateLoading(HipChatNotificationPlugin.class, "/templates");
        templateName = defaultMessageTemplateName;
    }

    return templateName;
}
 
Example 10
Source Project: QuickProject   Source File: FilesGenerator.java    License: Apache License 2.0 6 votes vote down vote up
public void generate() throws GlobalConfigException {
    Configuration cfg = new Configuration();
    File tmplDir = globalConfig.getTmplFile();
    try {
        cfg.setDirectoryForTemplateLoading(tmplDir);
    } catch (IOException e) {
        throw new GlobalConfigException("tmplPath", e);
    }
    cfg.setObjectWrapper(new DefaultObjectWrapper());
    for (Module module : modules) {
        logger.debug("module:" + module.getName());
        for (Bean bean : module.getBeans()) {
            logger.debug("bean:" + bean.getName());
            Map dataMap = new HashMap();
            dataMap.put("bean", bean);
            dataMap.put("module", module);
            dataMap.put("generate", generate);
            dataMap.put("config", config);
            dataMap.put("now", DateFormatUtils.ISO_DATE_FORMAT.format(new Date()));

            generate(cfg, dataMap);
        }
    }
}
 
Example 11
Source Project: spring-boot-actuator-logview   Source File: LogViewEndpoint.java    License: MIT License 5 votes vote down vote up
public LogViewEndpoint(String loggingPath, List<String> stylesheets) {
    this.loggingPath = loggingPath;
    this.stylesheets = stylesheets;
    fileProviders = asList(new FileSystemFileProvider(),
            new ZipArchiveFileProvider(),
            new TarGzArchiveFileProvider());
    freemarkerConfig = new Configuration(Configuration.DEFAULT_INCOMPATIBLE_IMPROVEMENTS);
    freemarkerConfig.setClassForTemplateLoading(this.getClass(), "/templates");
}
 
Example 12
Source Project: BlogManagePlatform   Source File: FreemarkerRender.java    License: Apache License 2.0 5 votes vote down vote up
@PostConstruct
private void init() {
	configuration = ContextUtil.bean(Configuration.class);
	FreeMarkerProperties properties = ContextUtil.bean(FreeMarkerProperties.class);
	loaderPath = properties.getTemplateLoaderPath()[0];
	suffix = properties.getSuffix();
	for (RenderMode mode : RenderMode.values()) {
		reverterMap.put(mode, ReflectUtil.instance(mode.getReverter()));
	}
	Assert.notNull(configuration, "configuration must not be null");
	Assert.notNull(loaderPath, "loaderPath must not be null");
	Assert.notNull(suffix, "suffix must not be null");
}
 
Example 13
Source Project: sailfish-core   Source File: TemplateWrapperFactory.java    License: Apache License 2.0 5 votes vote down vote up
public TemplateWrapperFactory(String templatesPackagePath) {
    configuration = new Configuration(Configuration.VERSION_2_3_24);

    configuration.setTemplateLoader(new ClassTemplateLoader(HtmlReport.class, templatesPackagePath));
    configuration.setDefaultEncoding("UTF-8");
    configuration.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
    configuration.setAPIBuiltinEnabled(true);
    configuration.setObjectWrapper(new BeansWrapperBuilder(Configuration.VERSION_2_3_24).build());
    configuration.setRecognizeStandardFileExtensions(true);
}
 
Example 14
protected void initFreemarker(HttpServletRequest request,
		HttpServletResponse response, RequestContext reqCtx)
		throws TemplateModelException {
	Configuration config = new Configuration();
	DefaultObjectWrapper wrapper = new DefaultObjectWrapper();
	config.setTemplateExceptionHandler(TemplateExceptionHandler.HTML_DEBUG_HANDLER);
	config.setObjectWrapper(wrapper);
	config.setTemplateExceptionHandler(TemplateExceptionHandler.DEBUG_HANDLER);
	TemplateModel templateModel = this.createModel(wrapper, this.getServletContext(), request, response);
	ExecutorBeanContainer ebc = new ExecutorBeanContainer(config, templateModel);
	reqCtx.addExtraParam(SystemConstants.EXTRAPAR_EXECUTOR_BEAN_CONTAINER, ebc);
}
 
Example 15
Source Project: fast-family-master   Source File: ControllerGenerator.java    License: Apache License 2.0 5 votes vote down vote up
private static void genController(String className,
                                  String classComment,
                                  String urlStr,
                                  String resourcePath,
                                  GeneratorConfig generatorConfig) {
    Map<String, Object> paramMap = new HashMap<>();
    paramMap.put("className", className);
    paramMap.put("classComment", classComment);
    paramMap.put("sysTime", new Date());
    paramMap.put("packageName", generatorConfig.getPackageName());
    paramMap.put("url", urlStr);
    Version version = new Version("2.3.27");
    Configuration configuration = new Configuration(version);
    try {
        URL url = ControllerGenerator.class.getClassLoader().getResource(resourcePath);
        configuration.setDirectoryForTemplateLoading(new File(url.getPath()));
        configuration.setObjectWrapper(new DefaultObjectWrapper(version));
        String filePath = generatorConfig.getSrcBasePath() + "controller//";
        String savePath = filePath + className + "Controller.java";
        File dirPath = new File(filePath);
        if (!dirPath.exists()) {
            dirPath.mkdirs();
        }
        try (FileWriter fileWriter = new FileWriter(new File(savePath))) {
            Template template = configuration.getTemplate("/controller.ftl");
            template.process(paramMap, fileWriter);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example 16
Source Project: freeacs   Source File: UnitDashboardRoute.java    License: MIT License 5 votes vote down vote up
public UnitDashboardRoute(
    Configuration configuration, ObjectMapper objectMapper, DataSource mainDs) {
  this.unitStatusPage = new UnitStatusPage();
  this.unitStatusPage.setMainDataSource(mainDs);
  this.configuration = configuration;
  this.objectMapper = objectMapper;
}
 
Example 17
Source Project: FlyCms   Source File: Areaslist.java    License: MIT License 5 votes vote down vote up
@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
public void execute(Environment env, Map params, TemplateModel[] loopVars,
		TemplateDirectiveBody body) throws TemplateException, IOException {
	DefaultObjectWrapperBuilder builder = new DefaultObjectWrapperBuilder(Configuration.VERSION_2_3_25);
	// 获取页面的参数
	//指定父级id
	int parentId = 0;
	
	//处理标签变量
	Map<String, TemplateModel> paramWrap = new HashMap<String, TemplateModel>(params);
	for(String str:paramWrap.keySet()){ 
		if("parentId".equals(str)){
			if(!NumberUtils.isNumber(paramWrap.get(str).toString())) {
				parentId=0;
			}else {
				if(!StringHelperUtils.checkInteger(paramWrap.get(str).toString())) {
					parentId=0;
				}else {
					parentId = Integer.parseInt(paramWrap.get(str).toString());
				}
			}
		}
	}
	// 获取文件的分页
	try {
		List<Areas> pageVo = areasService.selectAreasByPid(parentId);
		env.setVariable("areaslist", builder.build().wrap(pageVo));
	} catch (Exception e) {
		env.setVariable("areaslist", builder.build().wrap(null));
	}
	body.render(env.getOut());
}
 
Example 18
Source Project: aws-scala-sdk   Source File: Freemarker.java    License: Apache License 2.0 5 votes vote down vote up
public Freemarker() {
    Configuration config = new Configuration(Configuration.VERSION_2_3_21);

    config.setClassForTemplateLoading(Freemarker.class, "/templates");
    config.setDefaultEncoding("UTF-8");

    CONFIGURATION = config;
}
 
Example 19
Source Project: rice   Source File: XmlIngester.java    License: Educational Community License v2.0 5 votes vote down vote up
@Override
public void testSetUp() {
    super.testSetUp();
    // generated load users and group resources
    cfg = new Configuration();
    cfg.setTemplateLoader(new ClassTemplateLoader(getClass().getClassLoader().getClass(), DIR_TMPL));
}
 
Example 20
Source Project: jeewx   Source File: DbTableProcess.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 模版配置
 * @param resource
 * @return
 */
private static Configuration getConfig(String resource) {

	Configuration cfg = new Configuration();
	cfg.setDefaultEncoding("UTF-8");
	cfg.setClassForTemplateLoading(DbTableProcess.class, resource);
	return cfg;
}
 
Example 21
Source Project: spring-analysis-note   Source File: FreeMarkerConfigurerTests.java    License: MIT License 5 votes vote down vote up
@Test
@SuppressWarnings("rawtypes")
public void freeMarkerConfigurationFactoryBeanWithNonFileResourceLoaderPath() throws Exception {
	FreeMarkerConfigurationFactoryBean fcfb = new FreeMarkerConfigurationFactoryBean();
	fcfb.setTemplateLoaderPath("file:/mydir");
	Properties settings = new Properties();
	settings.setProperty("localized_lookup", "false");
	fcfb.setFreemarkerSettings(settings);
	fcfb.setResourceLoader(new ResourceLoader() {
		@Override
		public Resource getResource(String location) {
			if (!("file:/mydir".equals(location) || "file:/mydir/test".equals(location))) {
				throw new IllegalArgumentException(location);
			}
			return new ByteArrayResource("test".getBytes(), "test");
		}
		@Override
		public ClassLoader getClassLoader() {
			return getClass().getClassLoader();
		}
	});
	fcfb.afterPropertiesSet();
	assertThat(fcfb.getObject(), instanceOf(Configuration.class));
	Configuration fc = fcfb.getObject();
	Template ft = fc.getTemplate("test");
	assertEquals("test", FreeMarkerTemplateUtils.processTemplateIntoString(ft, new HashMap()));
}
 
Example 22
Source Project: opoopress   Source File: FreeMarkerRenderer.java    License: Apache License 2.0 5 votes vote down vote up
private void initializeAutoIncludeTemplates(Site site, Configuration configuration) {
    List<String> autoIncludeTemplates = site.get(PROPERTY_PREFIX + "auto_include_templates");
    if (autoIncludeTemplates != null && !autoIncludeTemplates.isEmpty()) {
        for (String template : autoIncludeTemplates) {
            configuration.addAutoInclude(template);
            log.debug("Add auto include: " + template);
        }
    }
}
 
Example 23
private static BeansWrapper getBeansWrapper(){
	//创建builder:
    BeansWrapperBuilder builder = new BeansWrapperBuilder(Configuration.getVersion());
    // 设置所需的beanswrapper属性
    //builder.setUseModelCache(true);是否启用缓存
    //builder.setExposeFields(true);//是否启用返回类的公共实例。
    builder.setSimpleMapWrapper(true);//模板能使用Map方法
    // Get the singleton:
    BeansWrapper beansWrapper = builder.build();
	
	return beansWrapper;
}
 
Example 24
Source Project: frostmourne   Source File: TemplateService.java    License: MIT License 5 votes vote down vote up
private String process(Configuration config, String key, Map<String, Object> env) {
    try {
        Template template = config.getTemplate(key, "utf-8");
        StringWriter writer = new StringWriter();
        template.process(env, writer);
        return writer.toString();
    } catch (Exception ex) {
        throw new RuntimeException(ex);
    }
}
 
Example 25
Source Project: geowave   Source File: LandsatIT.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void processParameters(final OperationParams params) throws Exception {
  store = dataStoreOptions.createDataStore();
  dataStorePluginOptions = dataStoreOptions;
  indices = new Index[] {new SpatialIndexBuilder().createIndex()};
  coverageNameTemplate =
      new Template(
          "name",
          new StringReader(ingestOptions.getCoverageName()),
          new Configuration());
}
 
Example 26
Source Project: kaif   Source File: MailComposer.java    License: Apache License 2.0 5 votes vote down vote up
@VisibleForTesting
MailComposer(MessageSource messageSource,
    Configuration configuration,
    MailProperties mailProperties) {
  this.messageSource = messageSource;
  this.configuration = configuration;
  this.mailProperties = mailProperties;
}
 
Example 27
Source Project: cloudbreak   Source File: UserDataBuilderTest.java    License: Apache License 2.0 5 votes vote down vote up
@Before
public void setup() throws IOException, TemplateException {
    FreeMarkerConfigurationFactoryBean factoryBean = new FreeMarkerConfigurationFactoryBean();
    factoryBean.setPreferFileSystemAccess(false);
    factoryBean.setTemplateLoaderPath("classpath:/");
    factoryBean.afterPropertiesSet();
    Configuration configuration = factoryBean.getObject();
    underTest.setFreemarkerConfiguration(configuration);

    UserDataBuilderParams params = new UserDataBuilderParams();
    params.setCustomData("date >> /tmp/time.txt");

    ReflectionTestUtils.setField(underTest, "userDataBuilderParams", params);
}
 
Example 28
Source Project: testability-explorer   Source File: SourceReportTest.java    License: Apache License 2.0 5 votes vote down vote up
protected void setUp() throws Exception {
  super.setUp();
  ClassPath classPath =
      new ClassPathFactory().createFromPaths("src/test/java", "core/src/test/java");
  SourceLoader loader = new SourceLoader(classPath);
  report = new SourceReportGenerator(new GradeCategories(0, 0), loader, null, new CostModel(),
          new Date(), 10, new Configuration());
  computer = new MetricComputer(new JavaClassRepository(), null,
          new RegExpWhiteList(), 1);
}
 
Example 29
Source Project: raml-module-builder   Source File: FacetManager.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * indicate the table name to query + facet on
 * @param onTable
 */
public FacetManager(String onTable){
  this.table = onTable;
  if(FacetManager.cfg == null){
    //do this ONLY ONCE
    FacetManager.cfg = new Configuration(new Version(2, 3, 26));
    // Where do we load the templates from:
    cfg.setClassForTemplateLoading(FacetManager.class, "/templates/facets");
    cfg.setDefaultEncoding("UTF-8");
    cfg.setLocale(Locale.US);
    cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
  }
}
 
Example 30
/****
	 * must be invoke after contruction
	 */
	public void initialize() {
		if(isInitialized())
			return ;
		
		TemplateLoader loader = getTempateLoader();
		Assert.notNull(loader);
		try {
			this.configuration = new Configuration(Configuration.VERSION_2_3_0);
			this.configuration.setObjectWrapper(getBeansWrapper());
			this.configuration.setOutputEncoding(this.encoding);
			//设置默认不自动格式化数字……以防sb……
			this.configuration.setNumberFormat("#");
//			this.cfg.setDirectoryForTemplateLoading(new File(templateDir));
			
			/*if(templateProvider!=null){
				this.configuration.setTemplateLoader(new DynamicTemplateLoader(templateProvider));
			}*/
			if(LangUtils.isNotEmpty(getFreemarkerVariables()))
				configuration.setAllSharedVariables(new SimpleHash(freemarkerVariables, configuration.getObjectWrapper()));
			
			//template loader
			/*if(!LangUtils.isEmpty(templatePaths)){
				TemplateLoader loader = FtlUtils.getTemplateLoader(resourceLoader, templatePaths);
				this.configuration.setTemplateLoader(loader);
			}*/
			this.configuration.setTemplateLoader(loader);
			
			this.buildConfigration(this.configuration);
			
			initialized = true;
		} catch (Exception e) {
			throw new BaseException("create freemarker template error : " + e.getMessage(), e);
		}
	}