當前位置: 首頁>>代碼示例>>Java>>正文


Java RuntimeServices類代碼示例

本文整理匯總了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);
    }
}
 
開發者ID:decebals,項目名稱:pippo,代碼行數:20,代碼來源:VelocityTemplateEngine.java

示例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 + '\'');
}
 
開發者ID:sakaiproject,項目名稱:sakai,代碼行數:21,代碼來源:SLF4JLogChute.java

示例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);
        }

    }
 
開發者ID:mulesoft-labs,項目名稱:connector-certification-tools,代碼行數:26,代碼來源:DirectoryStructureRule.java

示例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());
}
 
開發者ID:mybatis,項目名稱:velocity-scripting,代碼行數:27,代碼來源:InDirective.java

示例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;
}
 
開發者ID:osswangxining,項目名稱:iotplatform,代碼行數:11,代碼來源:VelocityUtils.java

示例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);
  }
}
 
開發者ID:yuexiahandao,項目名稱:MybatisCode,代碼行數:15,代碼來源:VelocitySqlSource.java

示例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;
}
 
開發者ID:callakrsos,項目名稱:Gargoyle,代碼行數:19,代碼來源:MailUtil.java

示例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();
}
 
開發者ID:ThomasYangZi,項目名稱:mblog,代碼行數:11,代碼來源:BaseDirective.java

示例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;
}
 
開發者ID:thingsboard,項目名稱:thingsboard,代碼行數:11,代碼來源:VelocityUtils.java

示例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);
    }
}
 
開發者ID:l-ra,項目名稱:openeet-android,代碼行數:15,代碼來源:AndroidAssetLoader.java

示例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);
}
 
開發者ID:ad3n,項目名稱:htmlcompressor,代碼行數:14,代碼來源:JavaScriptCompressorDirective.java

示例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);
}
 
開發者ID:ad3n,項目名稱:htmlcompressor,代碼行數:10,代碼來源:CssCompressorDirective.java

示例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));
}
 
開發者ID:ad3n,項目名稱:htmlcompressor,代碼行數:11,代碼來源:XmlCompressorDirective.java

示例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();
    }
}
 
開發者ID:wanghuizi,項目名稱:fengduo,代碼行數:10,代碼來源:VelocityResourceManagerImpl.java

示例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);
	}
}
 
開發者ID:xiyelife,項目名稱:jresplus,代碼行數:16,代碼來源:XssRejectEventHandler.java


注:本文中的org.apache.velocity.runtime.RuntimeServices類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。