本文整理匯總了Java中org.apache.velocity.runtime.RuntimeServices類的典型用法代碼示例。如果您正苦於以下問題:Java RuntimeServices類的具體用法?Java RuntimeServices怎麽用?Java RuntimeServices使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
RuntimeServices類屬於org.apache.velocity.runtime包,在下文中一共展示了RuntimeServices類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: renderString
import org.apache.velocity.runtime.RuntimeServices; //導入依賴的package包/類
@Override
public void renderString(String templateContent, Map<String, Object> model, Writer writer) {
// create the velocity context
VelocityContext context = createVelocityContext(model);
// merge the template
try {
RuntimeServices runtimeServices = RuntimeSingleton.getRuntimeServices();
StringReader reader = new StringReader(templateContent);
SimpleNode node = runtimeServices.parse(reader, "StringTemplate");
Template template = new Template();
template.setRuntimeServices(runtimeServices);
template.setData(node);
template.initDocument();
template.merge(context, writer);
} catch (Exception e) {
throw new PippoRuntimeException(e);
}
}
示例2: init
import org.apache.velocity.runtime.RuntimeServices; //導入依賴的package包/類
/**
* @see LogChute#init(RuntimeServices)
*/
public void init(RuntimeServices rs) throws Exception {
// override from velocity.properties
String name = (String) rs.getProperty(RUNTIME_LOG_SLF4J_LOGGER);
if (StringUtils.isBlank(name)) {
// lets try Sakai convention
ServletContext context = (ServletContext) rs.getApplicationAttribute("javax.servlet.ServletContext");
if (context != null) {
name = DEFAULT_LOGGER + "." + context.getServletContextName();
name = name.replace("-", ".");
} else {
// default to "velocity"
name = DEFAULT_LOGGER;
}
}
log(INFO_ID, "SLF4JLogChute using logger '" + name + '\'');
}
示例3: initTemplate
import org.apache.velocity.runtime.RuntimeServices; //導入依賴的package包/類
private void initTemplate(@NonNull final String verifyExpression) throws ParseException {
// Init pattern ...
final RuntimeServices runtimeServices = RuntimeSingleton.getRuntimeServices();
final StringReader reader = new StringReader(verifyExpression);
SimpleNode node = runtimeServices.parse(reader, this.getDocumentation().getId());
final Template template = new Template();
template.setRuntimeServices(runtimeServices);
template.setData(node);
template.initDocument();
this.template = template;
// Parse expression looking for variable ...
final Pattern pattern = Pattern.compile(VELOCITY_VARIABLE);
final Matcher matcher = pattern.matcher(verifyExpression);
while (matcher.find()) {
final String key = matcher.group(1);
final ClassProperty property = ClassProperty.to(key);
this.templateProperties.add(property);
}
}
示例4: init
import org.apache.velocity.runtime.RuntimeServices; //導入依賴的package包/類
@Override
public void init(RuntimeServices rs, InternalContextAdapter context, Node node) {
super.init(rs, context, node);
final int n = node.jjtGetNumChildren() - 1;
for (int i = 1; i < n; i++) {
Node child = node.jjtGetChild(i);
if (i == 1) {
if (child.getType() == ParserTreeConstants.JJTREFERENCE) {
this.var = ((ASTReference) child).getRootString();
}
else {
throw new TemplateInitException("Syntax error", getTemplateName(), getLine(), getColumn());
}
}
else if (child.getType() == ParserTreeConstants.JJTSTRINGLITERAL) {
String value = (String) ((ASTStringLiteral) child).value(context);
if (i == 2) {
this.column = value;
}
}
else {
throw new TemplateInitException("Syntax error", getTemplateName(), getLine(), getColumn());
}
}
this.uberInfo = new Info(this.getTemplateName(), getLine(), getColumn());
}
示例5: create
import org.apache.velocity.runtime.RuntimeServices; //導入依賴的package包/類
public static Template create(String source, String templateName) throws ParseException {
RuntimeServices runtimeServices = RuntimeSingleton.getRuntimeServices();
StringReader reader = new StringReader(source);
SimpleNode node = runtimeServices.parse(reader, templateName);
Template template = new Template();
template.setRuntimeServices(runtimeServices);
template.setData(node);
template.initDocument();
return template;
}
示例6: VelocitySqlSource
import org.apache.velocity.runtime.RuntimeServices; //導入依賴的package包/類
public VelocitySqlSource(Configuration configuration, String scriptText) {
this.configuration = configuration;
try {
RuntimeServices runtimeServices = RuntimeSingleton.getRuntimeServices();
StringReader reader = new StringReader(scriptText);
SimpleNode node = runtimeServices.parse(reader, "Template name");
script = new Template();
script.setRuntimeServices(runtimeServices);
script.setData(node);
script.initDocument();
} catch (Exception ex) {
throw new BuilderException("Error parsing velocity script", ex);
}
}
示例7: createTemplate
import org.apache.velocity.runtime.RuntimeServices; //導入依賴的package包/類
/**
* @작성자 : KYJ
* @작성일 : 2017. 10. 14.
* @param url
* @return
* @throws Exception
*/
public static Template createTemplate(InputStream is) throws Exception {
String readFileToString = ValueUtil.toString(is);
RuntimeServices runtimeServices = RuntimeSingleton.getRuntimeServices();
StringReader reader = new StringReader(readFileToString);
SimpleNode node = runtimeServices.parse(reader, "URLTemplate");
Template template = new Template();
template.setRuntimeServices(runtimeServices);
template.setData(node);
template.initDocument();
return template;
}
示例8: init
import org.apache.velocity.runtime.RuntimeServices; //導入依賴的package包/類
/**
* 重載init方法,初始自定義指令的配製參數
*/
@Override
public void init(RuntimeServices rs, InternalContextAdapter context, Node node)
throws TemplateInitException {
super.init(rs, context, node);
initBean();
}
示例9: create
import org.apache.velocity.runtime.RuntimeServices; //導入依賴的package包/類
public static Template create(String source, String templateName) throws ParseException {
RuntimeServices runtimeServices = RuntimeSingleton.getRuntimeServices();
StringReader reader = new StringReader(source);
SimpleNode node = runtimeServices.parse(reader, templateName);
Template template = new Template();
template.setRuntimeServices(runtimeServices);
template.setData(node);
template.initDocument();
return template;
}
示例10: commonInit
import org.apache.velocity.runtime.RuntimeServices; //導入依賴的package包/類
public void commonInit(RuntimeServices rs, ExtendedProperties configuration) {
super.commonInit(rs,configuration);
Log.i(LOGTAG,"commonInit");
try {
this.assets = (AssetManager) rs.getProperty("asset.resource.loader.manager");
setPath((String) rs.getProperty("asset.resource.loader.path"));
Log.d(LOGTAG,"Assets Path:"+path);
//list = assets.list(path);
}
catch (Exception e){
Log.e(LOGTAG,"Exception wile initing",e);
throw new RuntimeException("Exception while initing", e);
}
}
示例11: init
import org.apache.velocity.runtime.RuntimeServices; //導入依賴的package包/類
@Override
public void init(RuntimeServices rs, InternalContextAdapter context, Node node) throws TemplateInitException {
super.init(rs, context, node);
log = rs.getLog();
//set compressor properties
enabled = rs.getBoolean("userdirective.compressJs.enabled", true);
jsCompressor = rs.getString("userdirective.compressHtml.jsCompressor", HtmlCompressor.JS_COMPRESSOR_YUI);
yuiJsNoMunge = rs.getBoolean("userdirective.compressJs.yuiJsNoMunge", false);
yuiJsPreserveAllSemiColons = rs.getBoolean("userdirective.compressJs.yuiJsPreserveAllSemiColons", false);
yuiJsLineBreak = rs.getInt("userdirective.compressJs.yuiJsLineBreak", -1);
closureOptLevel = rs.getString("userdirective.compressHtml.closureOptLevel", ClosureJavaScriptCompressor.COMPILATION_LEVEL_SIMPLE);
}
示例12: init
import org.apache.velocity.runtime.RuntimeServices; //導入依賴的package包/類
@Override
public void init(RuntimeServices rs, InternalContextAdapter context, Node node) throws TemplateInitException {
super.init(rs, context, node);
log = rs.getLog();
//set compressor properties
enabled = rs.getBoolean("userdirective.compressCss.enabled", true);
yuiCssLineBreak = rs.getInt("userdirective.compressCss.yuiCssLineBreak", -1);
}
示例13: init
import org.apache.velocity.runtime.RuntimeServices; //導入依賴的package包/類
@Override
public void init(RuntimeServices rs, InternalContextAdapter context, Node node) throws TemplateInitException {
super.init(rs, context, node);
log = rs.getLog();
//set compressor properties
xmlCompressor.setEnabled(rs.getBoolean("userdirective.compressXml.enabled", true));
xmlCompressor.setRemoveComments(rs.getBoolean("userdirective.compressXml.removeComments", true));
xmlCompressor.setRemoveIntertagSpaces(rs.getBoolean("userdirective.compressXml.removeIntertagSpaces", true));
}
示例14: initialize
import org.apache.velocity.runtime.RuntimeServices; //導入依賴的package包/類
public synchronized void initialize(final RuntimeServices rsvc) {
try {
super.initialize(rsvc);
log.error("zxc ! Velocity initialize globalCache =" + globalCache);
instance = this;
} catch (Exception e) {
e.printStackTrace();
}
}
示例15: setRuntimeServices
import org.apache.velocity.runtime.RuntimeServices; //導入依賴的package包/類
public void setRuntimeServices(RuntimeServices rs) {
String[] temp = rs.getConfiguration().getStringArray(
DirectOutputVariableConfiguration);
if (temp != null && temp.length > 0) {
for (String s : temp) {
if (StringUtils.isNotBlank(s)) {
directOutputVariables.add(s.trim());
}
}
}
if (logger.isDebugEnabled()) {
logger.debug("init DirectOutputVariable with:"
+ directOutputVariables);
}
}