提交 | 用户 | 时间
|
722af2
|
1 |
package com.xxl.job.admin.core.util; |
X |
2 |
|
|
3 |
import freemarker.ext.beans.BeansWrapper; |
|
4 |
import freemarker.ext.beans.BeansWrapperBuilder; |
|
5 |
import freemarker.template.Configuration; |
|
6 |
import freemarker.template.TemplateHashModel; |
|
7 |
import org.slf4j.Logger; |
|
8 |
import org.slf4j.LoggerFactory; |
|
9 |
|
|
10 |
/** |
|
11 |
* ftl util |
|
12 |
* |
|
13 |
* @author xuxueli 2018-01-17 20:37:48 |
|
14 |
*/ |
|
15 |
public class FtlUtil { |
|
16 |
private static Logger logger = LoggerFactory.getLogger(FtlUtil.class); |
|
17 |
|
|
18 |
private static BeansWrapper wrapper = new BeansWrapperBuilder(Configuration.DEFAULT_INCOMPATIBLE_IMPROVEMENTS).build(); //BeansWrapper.getDefaultInstance(); |
|
19 |
|
|
20 |
public static TemplateHashModel generateStaticModel(String packageName) { |
|
21 |
try { |
|
22 |
TemplateHashModel staticModels = wrapper.getStaticModels(); |
|
23 |
TemplateHashModel fileStatics = (TemplateHashModel) staticModels.get(packageName); |
|
24 |
return fileStatics; |
|
25 |
} catch (Exception e) { |
|
26 |
logger.error(e.getMessage(), e); |
|
27 |
} |
|
28 |
return null; |
|
29 |
} |
|
30 |
|
|
31 |
} |