本文整理了Java中org.apache.velocity.app.Velocity.init()
方法的一些代码示例,展示了Velocity.init()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Velocity.init()
方法的具体详情如下:
包路径:org.apache.velocity.app.Velocity
类名称:Velocity
方法名:init
[英]initialize the Velocity runtime engine, using the default properties of the Velocity distribution
[中]使用Velocity分布的默认属性初始化Velocity运行时引擎
代码示例来源:origin: looly/hutool
/**
* 初始化Velocity全局属性
*
* @param templateDir 模板所在目录,绝对路径
* @param charset 编码
*/
synchronized public static void init(String templateDir, String charset) {
Velocity.init(_newInitedProp(templateDir, charset));
Velocity.setProperty(Velocity.FILE_RESOURCE_LOADER_CACHE, true); // 使用缓存
isInited = true; // 标记完成初始化
}
代码示例来源:origin: looly/hutool
/**
* 初始化Velocity全局属性
*
* @param templateDir 模板所在目录,绝对路径
* @param charset 编码
*/
synchronized public static void init(String templateDir, String charset) {
Velocity.init(_newInitedProp(templateDir, charset));
Velocity.setProperty(Velocity.FILE_RESOURCE_LOADER_CACHE, true); // 使用缓存
isInited = true; // 标记完成初始化
}
代码示例来源:origin: shuzheng/zheng
/**
* 根据模板生成文件
* @param inputVmFilePath 模板路径
* @param outputFilePath 输出文件路径
* @param context
* @throws Exception
*/
public static void generate(String inputVmFilePath, String outputFilePath, VelocityContext context) throws Exception {
try {
Properties properties = new Properties();
properties.setProperty(VelocityEngine.FILE_RESOURCE_LOADER_PATH, getPath(inputVmFilePath));
Velocity.init(properties);
//VelocityEngine engine = new VelocityEngine();
Template template = Velocity.getTemplate(getFile(inputVmFilePath), "utf-8");
File outputFile = new File(outputFilePath);
FileWriterWithEncoding writer = new FileWriterWithEncoding(outputFile, "utf-8");
template.merge(context, writer);
writer.close();
} catch (Exception ex) {
throw ex;
}
}
代码示例来源:origin: jfinal/jfinal
public void render() {
if (notInit) {
Velocity.init(properties); // Velocity.init("velocity.properties"); // setup
notInit = false;
代码示例来源:origin: com.github.yroffin/jbehaviour-engine
@Override
public void init() {
Velocity.init();
context = new VelocityContext();
}
代码示例来源:origin: Evolveum/midpoint
public VelocityScriptEvaluator(PrismContext prismContext, Protector protector) {
this.prismContext = prismContext;
this.protector = protector;
Properties properties = new Properties();
// properties.put("runtime.references.strict", "true");
Velocity.init(properties);
}
代码示例来源:origin: org.renci.genesis2/genesis2-core
private Genesis2Manager() {
super();
try {
Properties props = new Properties();
props.put("runtime.log.logsystem.class", "org.apache.velocity.runtime.log.NullLogChute");
Velocity.init(props);
} catch (Exception e) {
e.printStackTrace();
}
}
代码示例来源:origin: org.renci.genesis2/genesis2-core
public Genesis2Runnable(Genesis2Job job) {
super();
this.job = job;
try {
Properties props = new Properties();
props.put("runtime.log.logsystem.class", "org.apache.velocity.runtime.log.NullLogChute");
Velocity.init(props);
} catch (Exception e) {
e.printStackTrace();
}
}
代码示例来源:origin: com.atlassian.selenium/atlassian-visual-comparison
public static VelocityContext createContext() throws Exception
{
if (!initialised)
{
Properties p = new Properties();
p.setProperty("resource.loader", "class");
p.setProperty("class.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
Velocity.init(p);
initialised = true;
}
return new VelocityContext();
}
代码示例来源:origin: liuzhibin-cn/address-semantic-search
public void init(){
Properties properties = new Properties();
properties.setProperty(Velocity.INPUT_ENCODING, "UTF-8");
properties.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS,"org.apache.velocity.runtime.log.NullLogSystem");
Velocity.init(properties);
}
代码示例来源:origin: robertjanetzko/LegendsBrowser
private static void initVelocity() {
try {
Application.class.getClassLoader();
LogManager.getLogManager().readConfiguration(ClassLoader.getSystemResourceAsStream("logging.properties"));
} catch (SecurityException | IOException e) {
}
Properties velocityProperties = new Properties();
velocityProperties.setProperty("resource.loader", "classpath");
velocityProperties.setProperty("classpath.resource.loader.class", TemplateLoader.class.getName());
velocityProperties.setProperty("userdirective", "legends.helper.Decorate");
Velocity.init(velocityProperties);
}
代码示例来源:origin: OpenNMS/opennms
private String generateSnmpGraphInternal(Collection<Report> reports, String graphTemplate) {
Velocity.init();
VelocityContext context = new VelocityContext();
context.put("reportsList", reports.iterator());
context.put("reportsBody", reports.iterator());
Template template = Velocity.getTemplate(graphTemplate);
StringWriter sw = new StringWriter();
if (template != null) {
template.merge(context, sw);
}
return sw.toString();
}
代码示例来源:origin: laiweiwei/eweb4j-framework
public String render(Map<String, Object> datas, String template) {
Velocity.init();
VelocityContext context = new VelocityContext();
for (Iterator<Entry<String, Object>> it = datas.entrySet().iterator(); it.hasNext(); ){
Entry<String, Object> e = it.next();
context.put(e.getKey(), e.getValue());
}
StringWriter writer = new StringWriter();
Velocity.evaluate(context, writer, "", template);
return writer.toString();
}
}
代码示例来源:origin: FINRAOS/herd
/**
* Initializes the Velocity engine.
*/
public VelocityHelper()
{
Velocity.setProperty(RuntimeConstants.RUNTIME_REFERENCES_STRICT, true);
Velocity.init();
}
代码示例来源:origin: overturetool/overture
/**
* Initializes the Apache Velocity template engine.
*/
protected void initVelocity()
{
Velocity.setProperty("runtime.log.logsystem.class", "org.apache.velocity.runtime.log.NullLogSystem");
Velocity.init();
}
代码示例来源:origin: com.fluxtion.extension/fluxtion-fu-text-builder
private static void initVelocity() throws Exception {
Velocity.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath");
Velocity.setProperty("classpath.resource.loader.class", ClasspathResourceLoader.class.getName());
Velocity.init();
}
代码示例来源:origin: entando/entando-core
@Override
public void init() throws Exception {
try {
Velocity.setProperty(VelocityEngine.RUNTIME_LOG_LOGSYSTEM, this);
Velocity.init();
} catch (Throwable t) {
_logger.error("Error initializing the VelocityEngine", t);
//ApsSystemUtils.logThrowable(t, this, "init");
throw new ApsSystemException("Error initializing the VelocityEngine", t);
}
_logger.debug("{} ready.", this.getName());
}
代码示例来源:origin: com.xiaoleilu/hutool
/**
* 初始化Velocity全局属性
*
* @param templateDir 模板所在目录,绝对路径
*/
synchronized public static void init(String templateDir, String charset) {
Velocity.init(_newInitedProp(templateDir, charset));
Velocity.setProperty(Velocity.FILE_RESOURCE_LOADER_CACHE, true); // 使用缓存
isInited = true; // 标记完成初始化
}
代码示例来源:origin: cn.hutool/hutool-all
/**
* 初始化Velocity全局属性
*
* @param templateDir 模板所在目录,绝对路径
* @param charset 编码
*/
synchronized public static void init(String templateDir, String charset) {
Velocity.init(_newInitedProp(templateDir, charset));
Velocity.setProperty(Velocity.FILE_RESOURCE_LOADER_CACHE, true); // 使用缓存
isInited = true; // 标记完成初始化
}
代码示例来源:origin: org.entando.entando/entando-core-engine
@Override
public void init() throws Exception {
try {
Velocity.setProperty(VelocityEngine.RUNTIME_LOG_LOGSYSTEM, this);
Velocity.init();
} catch (Throwable t) {
ApsSystemUtils.logThrowable(t, this, "init");
throw new ApsSystemException("Error initializing the VelocityEngine", t);
}
ApsSystemUtils.getLogger().debug(this.getName() + ": initialized");
}
内容来源于网络,如有侵权,请联系作者删除!