本文整理了Java中org.apache.velocity.app.Velocity.setProperty()
方法的一些代码示例,展示了Velocity.setProperty()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Velocity.setProperty()
方法的具体详情如下:
包路径:org.apache.velocity.app.Velocity
类名称:Velocity
方法名:setProperty
[英]Set a Velocity Runtime property.
[中]设置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: 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: org.codehaus.castor/castor-codegen
/**
* Initialises the Velocity engine.
*/
private void initializeVelocity() {
// init velocity
Velocity.setProperty("velocimacro.permissions.allowInline", "true");
Velocity.setProperty("velocimacro.library",
"/org/exolab/castor/builder/printing/templates/library.vm");
Velocity.setProperty("resource.loader", "classPathResource");
Velocity.setProperty("classPathResource.resource.loader.class",
"org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
try {
Velocity.init();
} catch (Exception e) {
System.out.println("init fails!");
e.printStackTrace();
}
}
代码示例来源:origin: velocity/velocity-dep
InlineScopeVMTestCase()
{
super(TEST_CASE_NAME);
try
{
/*
* do our properties locally, and just override the ones we want
* changed
*/
Velocity.setProperty(
Velocity.VM_PERM_ALLOW_INLINE_REPLACE_GLOBAL, "true");
Velocity.setProperty(
Velocity.VM_PERM_INLINE_LOCAL, "true");
Velocity.setProperty(
Velocity.FILE_RESOURCE_LOADER_PATH, FILE_RESOURCE_LOADER_PATH);
Velocity.init();
}
catch (Exception e)
{
System.err.println("Cannot setup " + TEST_CASE_NAME);
System.exit(1);
}
}
代码示例来源:origin: org.finra.herd/herd-service
/**
* Initializes the Velocity engine.
*/
public VelocityHelper()
{
Velocity.setProperty(RuntimeConstants.RUNTIME_REFERENCES_STRICT, true);
Velocity.init();
}
代码示例来源: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: velocity/velocity-dep
public EncodingTestCase()
{
super("EncodingTestCase");
try
{
Velocity.setProperty(
Velocity.FILE_RESOURCE_LOADER_PATH, FILE_RESOURCE_LOADER_PATH);
Velocity.setProperty( Velocity.INPUT_ENCODING, "UTF-8" );
Velocity.init();
}
catch (Exception e)
{
System.err.println("Cannot setup EncodingTestCase!");
e.printStackTrace();
System.exit(1);
}
}
代码示例来源:origin: velocity/velocity-dep
public ContextSafetyTestCase()
{
super("ContextSafetyTestCase");
try
{
Velocity.setProperty(
Velocity.FILE_RESOURCE_LOADER_PATH, FILE_RESOURCE_LOADER_PATH);
Velocity.init();
}
catch (Exception e)
{
System.err.println("Cannot setup ContextSafetyTestCase!");
e.printStackTrace();
System.exit(1);
}
}
代码示例来源:origin: yusuke/samurai
public VelocityHtmlRenderer(String style, String baseurl) {
this.style = style;
this.baseurl = baseurl;
Velocity.setProperty("input.encoding", "UTF-8");
Velocity.setProperty("resource.loader", "class");
Velocity.setProperty("class.resource.loader.class",
"org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
Velocity.setProperty("runtime.log.logsystem.class", "samurai.web.NullVelocityLogger");
try {
Velocity.init();
tableView = Velocity.getTemplate("samurai/web/table.vm");
threaddumpView = Velocity.getTemplate("samurai/web/threaddump.vm");
sequenceView = Velocity.getTemplate("samurai/web/sequence.vm");
} catch (Exception ex) {
ex.printStackTrace();
}
}
代码示例来源:origin: velocity/velocity-dep
public VelocityAppTestCase()
{
super("VelocityAppTestCase");
try
{
Velocity.setProperty(
Velocity.FILE_RESOURCE_LOADER_PATH, FILE_RESOURCE_LOADER_PATH);
Velocity.init();
}
catch (Exception e)
{
System.err.println("Cannot setup VelocityAppTestCase!");
e.printStackTrace();
System.exit(1);
}
}
代码示例来源:origin: velocity/velocity-dep
public VelocimacroTestCase()
{
super("VelocimacroTestCase");
try
{
/*
* setup local scope for templates
*/
Velocity.setProperty( Velocity.VM_PERM_INLINE_LOCAL, Boolean.TRUE);
Velocity.init();
}
catch (Exception e)
{
System.err.println("Cannot setup VelocimacroTestCase!");
System.exit(1);
}
}
代码示例来源:origin: liferay/liferay-mobile-sdk
public static void generate(
VelocityContext context, String templatePath, String filePath,
boolean format)
throws Exception {
String resourceLoader = ClasspathResourceLoader.class.getName();
if (format) {
resourceLoader = FormatterResourceLoader.class.getName();
}
Velocity.setProperty(
RuntimeConstants.VM_LIBRARY, "templates/macros.vm");
Velocity.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath");
Velocity.setProperty("classpath.resource.loader.class", resourceLoader);
Velocity.init();
Template template = Velocity.getTemplate(templatePath);
Writer writer = new FileWriter(filePath);
template.merge(context, writer);
writer.flush();
writer.close();
}
代码示例来源:origin: velocity/velocity-dep
/**
* Default constructor.
*/
public EventHandlingTestCase()
{
super("EventHandlingTestCase");
try
{
/*
* use an alternative logger. Set it up here and pass it in.
*/
Velocity.setProperty(Velocity.RUNTIME_LOG_LOGSYSTEM, this );
Velocity.init();
}
catch (Exception e)
{
System.err.println("Cannot setup event handling test : " + e);
System.exit(1);
}
}
代码示例来源: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: com.googlecode.t7mp/maven-t7-common
@Override
public void execute(Context context) {
final T7Configuration configuration = context.getConfiguration();
try {
Velocity.setProperty(Velocity.RUNTIME_LOG_LOGSYSTEM, new LogNothingLogChute());
Velocity.setProperty(Velocity.RESOURCE_LOADER, "class");
Velocity.setProperty("class.resource.loader.description", "Velocity Classpath Resource Loader");
Velocity.setProperty("class.resource.loader.class", ClasspathResourceLoader.class.getName());
Velocity.init();
Template template = Velocity.getTemplate("com/googlecode/t7mp/conf/catalina.properties");
VelocityContext velocityContext = new VelocityContext();
velocityContext.put("tomcatHttpPort", configuration.getTomcatHttpPort() + "");
velocityContext.put("tomcatShutdownPort", configuration.getTomcatShutdownPort() + "");
velocityContext.put("tomcatShutdownCommand", configuration.getTomcatShutdownCommand());
Writer writer = new FileWriter(new File(configuration.getCatalinaBase(), "/conf/catalina.properties"));
template.merge(velocityContext, writer);
writer.flush();
writer.close();
} catch (Exception e) {
throw new TomcatSetupException(e.getMessage(), e);
}
}
代码示例来源: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");
}
内容来源于网络,如有侵权,请联系作者删除!