@Override
protected Configuration getFreemarkerConfiguration(RepoCtx ctx)
{
if (useRemoteCallbacks)
{
// as per 3.0, 3.1
return super.getFreemarkerConfiguration(ctx);
}
else
{
Configuration cfg = new Configuration();
cfg.setObjectWrapper(new DefaultObjectWrapper());
cfg.setTemplateLoader(new ClassPathRepoTemplateLoader(nodeService, contentService, defaultEncoding));
// TODO review i18n
cfg.setLocalizedLookup(false);
cfg.setIncompatibleImprovements(new Version(2, 3, 20));
cfg.setNewBuiltinClassResolver(TemplateClassResolver.SAFER_RESOLVER);
return cfg;
}
}
java类freemarker.template.Version的实例源码
LocalFeedTaskProcessor.java 文件源码
项目:alfresco-repository
阅读 23
收藏 0
点赞 0
评论 0
Generator.java 文件源码
项目:tkcg
阅读 29
收藏 0
点赞 0
评论 0
private FreemarkerHelper buildFreemarkerHelper(File templateBaseDir) {
Configuration configuration = new Configuration(new Version(2, 3, 0));
try {
TemplateLoader templateLoader = new FileTemplateLoader(templateBaseDir);
configuration.setTemplateLoader(templateLoader);
} catch (IOException e) {
throw new GeneratorException("构建模板助手出错:" + e.getMessage());
}
configuration.setNumberFormat("###############");
configuration.setBooleanFormat("true,false");
configuration.setDefaultEncoding("UTF-8");
// 自动导入公共文件,用于支持灵活变量
if (autoIncludeFile.exists()) {
List<String> autoIncludeList = new ArrayList<>();
autoIncludeList.add(FREEMARKER_AUTO_INCLUDE_SUFFIX);
configuration.setAutoIncludes(autoIncludeList);
}
return new FreemarkerHelper(configuration);
}
SchemaMaker.java 文件源码
项目:raml-module-builder
阅读 22
收藏 0
点赞 0
评论 0
/**
* @param onTable
*/
public SchemaMaker(String tenant, String module, TenantOperation mode, String previousVersion, String rmbVersion){
if(SchemaMaker.cfg == null){
//do this ONLY ONCE
SchemaMaker.cfg = new Configuration(new Version(2, 3, 26));
// Where do we load the templates from:
cfg.setClassForTemplateLoading(SchemaMaker.class, "/templates/db_scripts");
cfg.setDefaultEncoding("UTF-8");
cfg.setLocale(Locale.US);
cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
}
this.tenant = tenant;
this.module = module;
this.mode = mode;
this.previousVersion = previousVersion;
this.rmbVersion = rmbVersion;
}
EmailTemplate.java 文件源码
项目:hawkular-alerts
阅读 25
收藏 0
点赞 0
评论 0
public EmailTemplate() {
ftlCfg = new Configuration(new Version(FREEMARKER_VERSION));
try {
// Check if templates are located from disk or if we are loading default ones.
String templatesDir = System.getenv(EmailPlugin.HAWKULAR_ALERTS_TEMPLATES);
templatesDir = templatesDir == null ? System.getProperty(EmailPlugin.HAWKULAR_ALERTS_TEMPLATES_PROPERY)
: templatesDir;
boolean templatesFromDir = false;
if (templatesDir != null) {
File fileDir = new File(templatesDir);
if (fileDir.exists()) {
ftlCfg.setDirectoryForTemplateLoading(fileDir);
templatesFromDir = true;
}
}
if (!templatesFromDir) {
ftlCfg.setClassForTemplateLoading(this.getClass(), "/");
}
ftlTemplatePlain = ftlCfg.getTemplate(DEFAULT_TEMPLATE_PLAIN, DEFAULT_LOCALE);
ftlTemplateHtml = ftlCfg.getTemplate(DEFAULT_TEMPLATE_HTML, DEFAULT_LOCALE);
} catch (IOException e) {
log.debug(e.getMessage(), e);
throw new RuntimeException("Cannot initialize templates on email plugin: " + e.getMessage());
}
}
DeploymentXmlWriter.java 文件源码
项目:WebSphere-Deployment-Xml-Tool
阅读 24
收藏 0
点赞 0
评论 0
public void save() throws Exception {
genTime = new Date().getTime();
deploymentXmlFile.getParentFile().mkdirs();
Configuration cfg = new Configuration(new Version(2, 3, 22));
cfg.setClassLoaderForTemplateLoading(this.getClass().getClassLoader(), "templates");
cfg.setDefaultEncoding("UTF-8");
cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
Template template = cfg.getTemplate("parent_last.ftl");
FileOutputStream outputStream = new FileOutputStream(deploymentXmlFile);
Writer out = new OutputStreamWriter(outputStream);
template.process(this, out);
outputStream.flush();
outputStream.close();
}
FreemarkerConfiguration.java 文件源码
项目:private-freemarker
阅读 24
收藏 0
点赞 0
评论 0
public static Template getTemplate(String name) {
Template template = null;
try {
Version version = new Version("2.3.0");
Configuration cfg = new Configuration(version);
// 读取ftl模板
cfg.setClassForTemplateLoading(FreemarkerConfiguration.class, "/ftl");
cfg.setClassicCompatible(true);
cfg.setDefaultEncoding("UTF-8");
cfg.setTemplateExceptionHandler(TemplateExceptionHandler.HTML_DEBUG_HANDLER);
cfg.setObjectWrapper(new SaicObjectWrapper(cfg.getIncompatibleImprovements()));
template = cfg.getTemplate(name);
} catch (IOException e) {
e.printStackTrace();
}
return template;
}
LocalFeedTaskProcessor.java 文件源码
项目:community-edition-old
阅读 26
收藏 0
点赞 0
评论 0
@Override
protected Configuration getFreemarkerConfiguration(RepoCtx ctx)
{
if (useRemoteCallbacks)
{
// as per 3.0, 3.1
return super.getFreemarkerConfiguration(ctx);
}
else
{
Configuration cfg = new Configuration();
cfg.setObjectWrapper(new DefaultObjectWrapper());
cfg.setTemplateLoader(new ClassPathRepoTemplateLoader(nodeService, contentService, defaultEncoding));
// TODO review i18n
cfg.setLocalizedLookup(false);
cfg.setIncompatibleImprovements(new Version(2, 3, 20));
cfg.setNewBuiltinClassResolver(TemplateClassResolver.SAFER_RESOLVER);
return cfg;
}
}
AbstractPrintGeneratingTest.java 文件源码
项目:matsuo-core
阅读 22
收藏 0
点赞 0
评论 0
AbstractPrintGeneratingTest() {
targetDirectory.mkdirs();
try {
freeMarkerConfiguration = new Configuration();
freeMarkerConfiguration.setTemplateLoader(new ClassTemplateLoader(Class.class, "/"));
//freeMarkerConfiguration.setDirectoryForTemplateLoading(new File(templateDirectory).getAbsoluteFile());
freeMarkerConfiguration.setObjectWrapper(new DefaultObjectWrapper());
freeMarkerConfiguration.setDefaultEncoding("UTF-8");
freeMarkerConfiguration.setTemplateExceptionHandler(HTML_DEBUG_HANDLER);
freeMarkerConfiguration.setIncompatibleImprovements(new Version(2, 3, 20));
printsRendererService.setFreeMarkerConfiguration(freeMarkerConfiguration);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
FreemarkerConfiguration.java 文件源码
项目:private-freemarker
阅读 26
收藏 0
点赞 0
评论 0
public static Template getTemplate(String name) {
Template template = null;
try {
Version version = new Version("2.3.0");
Configuration cfg = new Configuration(version);
// 读取ftl模板
cfg.setClassForTemplateLoading(FreemarkerConfiguration.class, "/ftl");
cfg.setClassicCompatible(true);
cfg.setDefaultEncoding("UTF-8");
cfg.setTemplateExceptionHandler(TemplateExceptionHandler.HTML_DEBUG_HANDLER);
cfg.setObjectWrapper(new SaicObjectWrapper(cfg.getIncompatibleImprovements()));
template = cfg.getTemplate(name);
} catch (IOException e) {
e.printStackTrace();
}
return template;
}
ApplicationConfiguration.java 文件源码
项目:GMM
阅读 28
收藏 0
点赞 0
评论 0
/**
* FreeMarker (ftl) configuration
*/
@Bean
public FreeMarkerConfigurer freemarkerConfig() throws IOException, TemplateException {
final FreeMarkerConfigurer result = new FreeMarkerConfigurer();
// template path
result.setTemplateLoaderPath("/WEB-INF/ftl/");
result.setDefaultEncoding("UTF-8");
// static access
final Version version = freemarker.template.Configuration.getVersion();
final BeansWrapper wrapper = new BeansWrapper(version);
final TemplateHashModel statics = wrapper.getStaticModels();
final Map<String, Object> shared = new HashMap<>();
for (final Class<?> clazz : ElFunctions.staticClasses) {
shared.put(clazz.getSimpleName(), statics.get(clazz.getName()));
}
result.setFreemarkerVariables(shared);
return result;
}
FreemarkerTemplateUtils.java 文件源码
项目:collect-earth
阅读 24
收藏 0
点赞 0
评论 0
public static boolean applyTemplate(File sourceTemplate, File destinationFile, Map<?, ?> data) throws IOException, TemplateException{
boolean success = true;
// Process the template file using the data in the "data" Map
final Configuration cfg = new Configuration( new Version("2.3.23"));
cfg.setDirectoryForTemplateLoading(sourceTemplate.getParentFile());
// Load template from source folder
final Template template = cfg.getTemplate(sourceTemplate.getName());
// Console output
BufferedWriter fw = null;
try {
fw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(destinationFile), Charset.forName("UTF-8")));
template.process(data, fw);
}finally {
if (fw != null) {
fw.close();
}
}
return success;
}
FeedTaskProcessor.java 文件源码
项目:alfresco-repository
阅读 25
收藏 0
点赞 0
评论 0
protected Configuration getFreemarkerConfiguration(RepoCtx ctx)
{
Configuration cfg = new Configuration();
cfg.setObjectWrapper(new DefaultObjectWrapper());
// custom template loader
cfg.setTemplateLoader(new TemplateWebScriptLoader(ctx.getRepoEndPoint(), ctx.getTicket()));
// TODO review i18n
cfg.setLocalizedLookup(false);
cfg.setIncompatibleImprovements(new Version(2, 3, 20));
cfg.setNewBuiltinClassResolver(TemplateClassResolver.SAFER_RESOLVER);
return cfg;
}
FreeMarkerProcessor.java 文件源码
项目:alfresco-repository
阅读 25
收藏 0
点赞 0
评论 0
/**
* FreeMarker configuration for loading the specified template directly from a String
*
* @param path Pseudo Path to the template
* @param template Template content
*
* @return FreeMarker configuration
*/
protected Configuration getStringConfig(String path, String template)
{
Configuration config = new Configuration();
// setup template cache
config.setCacheStorage(new MruCacheStorage(2, 0));
// use our custom loader to load a template directly from a String
StringTemplateLoader stringTemplateLoader = new StringTemplateLoader();
stringTemplateLoader.putTemplate(path, template);
config.setTemplateLoader(stringTemplateLoader);
// use our custom object wrapper that can deal with QNameMap objects directly
config.setObjectWrapper(qnameObjectWrapper);
// rethrow any exception so we can deal with them
config.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
// set default template encoding
if (defaultEncoding != null)
{
config.setDefaultEncoding(defaultEncoding);
}
config.setIncompatibleImprovements(new Version(2, 3, 20));
config.setNewBuiltinClassResolver(TemplateClassResolver.SAFER_RESOLVER);
return config;
}
I18nMiddleware.java 文件源码
项目:bouncr
阅读 22
收藏 0
点赞 0
评论 0
@Override
public HttpResponse handle(HttpRequest request, MiddlewareChain chain) {
ContentNegotiable negotiable = ContentNegotiable.class.cast(MixinUtils.mixin(request, ContentNegotiable.class));
HttpResponse response = castToHttpResponse(chain.next(request));
if (TemplatedHttpResponse.class.isInstance(response)) {
TemplatedHttpResponse tres = TemplatedHttpResponse.class.cast(response);
ResourceBundle bundle = config.getMessageResource().getBundle(negotiable.getLocale());
tres.getContext().put("t", new ResourceBundleModel(bundle,
new BeansWrapperBuilder(new Version(2,3,23)).build()));
}
return response;
}
ScipioFtlWrappers.java 文件源码
项目:scipio-erp
阅读 25
收藏 0
点赞 0
评论 0
public static ScipioBasicBeansWrapperImpl create(Version incompatibleImprovements, Boolean simpleMapWrapper) {
ScipioBasicBeansWrapperImpl wrapper = new ScipioBasicBeansWrapperImpl(incompatibleImprovements, systemWrapperFactories);
if (simpleMapWrapper != null) {
wrapper.setSimpleMapWrapper(simpleMapWrapper);
}
return wrapper;
}
ScipioFtlWrappers.java 文件源码
项目:scipio-erp
阅读 26
收藏 0
点赞 0
评论 0
public static ScipioBasicDefaultObjectWrapperImpl create(Version incompatibleImprovements,
Boolean simpleMapWrapper, Boolean useAdaptersForContainers) {
ScipioBasicDefaultObjectWrapperImpl wrapper = new ScipioBasicDefaultObjectWrapperImpl(incompatibleImprovements, systemWrapperFactories);
if (simpleMapWrapper != null) {
wrapper.setSimpleMapWrapper(simpleMapWrapper);
}
if (useAdaptersForContainers != null) {
wrapper.setUseAdaptersForContainers(useAdaptersForContainers);
}
return wrapper;
}
ScipioFtlWrappers.java 文件源码
项目:scipio-erp
阅读 24
收藏 0
点赞 0
评论 0
public static ScipioExtendedBeansWrapperImpl create(Version incompatibleImprovements, String encodeLang, Boolean simpleMapWrapper) {
ScipioExtendedBeansWrapperImpl wrapper = new ScipioExtendedBeansWrapperImpl(incompatibleImprovements, systemWrapperFactories, encodeLang);
if (simpleMapWrapper != null) {
wrapper.setSimpleMapWrapper(simpleMapWrapper);
}
return wrapper;
}
ScipioFtlWrappers.java 文件源码
项目:scipio-erp
阅读 24
收藏 0
点赞 0
评论 0
public static ScipioExtendedDefaultObjectWrapperImpl create(Version incompatibleImprovements, String encodeLang,
Boolean simpleMapWrapper, Boolean useAdaptersForContainers) {
ScipioExtendedDefaultObjectWrapperImpl wrapper = new ScipioExtendedDefaultObjectWrapperImpl(incompatibleImprovements, systemWrapperFactories, encodeLang);
if (simpleMapWrapper != null) {
wrapper.setSimpleMapWrapper(simpleMapWrapper);
}
if (useAdaptersForContainers != null) {
wrapper.setUseAdaptersForContainers(useAdaptersForContainers);
}
return wrapper;
}
RallyServiceApp.java 文件源码
项目:service-rally
阅读 23
收藏 0
点赞 0
评论 0
@Bean
public TemplateEngine getTemplateEngine() {
Version version = new Version(2, 3, 25);
freemarker.template.Configuration cfg = new freemarker.template.Configuration(version);
cfg.setClassForTemplateLoading(RallyServiceApp.class, "/");
cfg.setIncompatibleImprovements(version);
cfg.setDefaultEncoding(Charsets.UTF_8.toString());
cfg.setLocale(Locale.US);
cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
return new FreemarkerTemplateEngine(cfg);
}
FacetManager.java 文件源码
项目:raml-module-builder
阅读 24
收藏 0
点赞 0
评论 0
/**
* 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);
}
}
FreemarkerExpressionEvaluator.java 文件源码
项目:jwebrobot
阅读 25
收藏 0
点赞 0
评论 0
private Configuration createConfig(){
Configuration config = new Configuration(new Version(2, 3, 23));
config.setDefaultEncoding("UTF-8");
config.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
config.setCacheStorage(NullCacheStorage.INSTANCE);
return config;
}
StoreProcessor.java 文件源码
项目:Iron
阅读 23
收藏 0
点赞 0
评论 0
private Configuration getFreemarkerConfiguration() {
if (mFreemarkerConfiguration == null) {
mFreemarkerConfiguration = new Configuration(new Version(2, 3, 22));
mFreemarkerConfiguration.setClassForTemplateLoading(getClass(), "");
}
return mFreemarkerConfiguration;
}
PrefsProcessor.java 文件源码
项目:android-prefs
阅读 28
收藏 0
点赞 0
评论 0
private Configuration getFreemarkerConfiguration() {
if (mFreemarkerConfiguration == null) {
mFreemarkerConfiguration = new Configuration(new Version(2, 3, 26));
mFreemarkerConfiguration.setClassForTemplateLoading(getClass(), "");
}
return mFreemarkerConfiguration;
}
Templates.java 文件源码
项目:live-chat-engine
阅读 26
收藏 0
点赞 0
评论 0
public Templates(String dirPath) throws IOException {
this.dirPath = dirPath;
cfg = new Configuration();
cfg.setLocalizedLookup(false);
cfg.setDirectoryForTemplateLoading(new File(this.dirPath));
cfg.setObjectWrapper(new DefaultObjectWrapper());
cfg.setDefaultEncoding("UTF-8");
cfg.setTemplateExceptionHandler(TemplateExceptionHandler.HTML_DEBUG_HANDLER);
cfg.setIncompatibleImprovements(new Version(2, 3, 20));
}
Covert2AcmeGenerator.java 文件源码
项目:ACME-Generator
阅读 26
收藏 0
点赞 0
评论 0
private static Configuration getConfigurationInstance(String destDir) throws IOException {
if (cfg == null) {
try {
cfg = new Configuration();
} catch (Exception e) {
e.printStackTrace();
}
cfg.setDirectoryForTemplateLoading(new File(destDir));
cfg.setObjectWrapper(new DefaultObjectWrapper());
cfg.setDefaultEncoding("UTF-8");
cfg.setTemplateExceptionHandler(TemplateExceptionHandler.HTML_DEBUG_HANDLER);
cfg.setIncompatibleImprovements(new Version(2, 3, 20));
}
return cfg;
}
HttpBodyWriter.java 文件源码
项目:taxii-log-adapter
阅读 23
收藏 0
点赞 0
评论 0
public HttpBodyWriter(TaxiiStatusDao taxiiStatusDao) throws IOException {
this.taxiiStatusDao = taxiiStatusDao;
cfg = new Configuration(new Version(2, 3, 21));
cfg.setDefaultEncoding("UTF-8");
cfg.setTemplateLoader(new ClassTemplateLoader(HttpBodyWriter.class, "templates"));
template = cfg.getTemplate("poll-request.ftl");
templateFulfillment = cfg.getTemplate("poll-fulfillment-request.ftl");
}
ScreenGenerator.java 文件源码
项目:MortarLib
阅读 25
收藏 0
点赞 0
评论 0
private Configuration getFreemarkerConfig() {
Configuration config = new Configuration();
config.setClassForTemplateLoading(ScreenGenerator.class, "template");
config.setIncompatibleImprovements(new Version(2, 3, 20));
config.setDefaultEncoding("UTF-8");
config.setLocale(Locale.US);
config.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
return config;
}
WlpPomBuilder.java 文件源码
项目:jee
阅读 22
收藏 0
点赞 0
评论 0
public WlpPomBuilder() throws IOException {
cfg = new Configuration();
//URL template = Thread.currentThread().getContextClassLoader().getResource(".");
//cfg.setDirectoryForTemplateLoading(new File(template.toString().substring(5)));
cfg.setClassForTemplateLoading(this.getClass(), "/templates");
cfg.setObjectWrapper(new DefaultObjectWrapper());
cfg.setDefaultEncoding("UTF-8");
cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
cfg.setIncompatibleImprovements(new Version(2, 3, 20));
}
FeedTaskProcessor.java 文件源码
项目:community-edition-old
阅读 28
收藏 0
点赞 0
评论 0
protected Configuration getFreemarkerConfiguration(RepoCtx ctx)
{
Configuration cfg = new Configuration();
cfg.setObjectWrapper(new DefaultObjectWrapper());
// custom template loader
cfg.setTemplateLoader(new TemplateWebScriptLoader(ctx.getRepoEndPoint(), ctx.getTicket()));
// TODO review i18n
cfg.setLocalizedLookup(false);
cfg.setIncompatibleImprovements(new Version(2, 3, 20));
cfg.setNewBuiltinClassResolver(TemplateClassResolver.SAFER_RESOLVER);
return cfg;
}
FreeMarkerProcessor.java 文件源码
项目:community-edition-old
阅读 23
收藏 0
点赞 0
评论 0
/**
* Get the FreeMarker configuration for this instance
*
* @return FreeMarker configuration
*/
protected synchronized Configuration getConfig()
{
if (config == null)
{
config = new Configuration();
// setup template cache
config.setCacheStorage(new MruCacheStorage(512, 1024));
// use our custom loader to find templates on the ClassPath
config.setTemplateLoader(new ClassPathRepoTemplateLoader(
this.services.getNodeService(), this.services.getContentService(), defaultEncoding));
// use our custom object wrapper that can deal with QNameMap objects directly
config.setObjectWrapper(qnameObjectWrapper);
// rethrow any exception so we can deal with them
config.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
// localized template lookups off by default - as they create strange noderef lookups
// such as workspace://SpacesStore/01234_en_GB - causes problems for ns.exists() on DB2
config.setLocalizedLookup(localizedLookup);
// set default template encoding
if (defaultEncoding != null)
{
config.setDefaultEncoding(defaultEncoding);
}
config.setIncompatibleImprovements(new Version(2, 3, 20));
config.setNewBuiltinClassResolver(TemplateClassResolver.SAFER_RESOLVER);
}
return config;
}