Java 类org.apache.velocity.runtime.RuntimeServices 实例源码

项目:sakai    文件:SLF4JLogChute.java   
/**
 * @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 + '\'');
}
项目:connector-certification-tools    文件:DirectoryStructureRule.java   
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);
        }

    }
项目:pippo    文件:VelocityTemplateEngine.java   
@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);
    }
}
项目:sakai    文件:SLF4JLogChute.java   
/**
 * @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 + '\'');
}
项目:velocity-scripting    文件:InDirective.java   
@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());
}
项目:iotplatform    文件:VelocityUtils.java   
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;
}
项目:MybatisCode    文件:VelocitySqlSource.java   
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);
  }
}
项目:Gargoyle    文件:MailUtil.java   
/**
 * @작성자 : 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;
}
项目:mblog    文件:BaseDirective.java   
/** 
 * 重载init方法,初始自定义指令的配制参数 
 */  
@Override  
public void init(RuntimeServices rs, InternalContextAdapter context, Node node)  
    throws TemplateInitException {  
    super.init(rs, context, node);

    initBean();
}
项目:mybatis    文件:VelocitySqlSource.java   
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);
  }
}
项目:thingsboard    文件:VelocityUtils.java   
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;
}
项目:openeet-android    文件:AndroidAssetLoader.java   
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);
    }
}
项目:mybaties    文件:VelocitySqlSource.java   
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);
  }
}
项目:htmlcompressor    文件:JavaScriptCompressorDirective.java   
@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);
}
项目:htmlcompressor    文件:CssCompressorDirective.java   
@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);
}
项目:htmlcompressor    文件:XmlCompressorDirective.java   
@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));
}
项目:play    文件:VelocitySqlSource.java   
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);
  }
}
项目:fengduo    文件:VelocityResourceManagerImpl.java   
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();
    }
}
项目:jresplus    文件:XssRejectEventHandler.java   
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);
    }
}
项目:aludratest    文件:Slf4jLogChute.java   
/********** LogChute methods *************/

    @Override
    public void init(RuntimeServices rs) {
        String name = (String) rs.getProperty(LOGCHUTE_SLF4J_NAME);

        if (name == null) {
            name = DEFAULT_LOG_NAME;
        }
        log = LoggerFactory.getLogger(name);
        log(LogChute.DEBUG_ID, "Slf4jLogChute name is '" + name + "'");
    }
项目:minnal    文件:Slf4jLogChute.java   
/********** LogChute methods *************/

    public void init(RuntimeServices rs)
    {
        String name =
            (String)rs.getProperty(LOGCHUTE_SLF4J_NAME);

        if (name == null)
        {
            name = DEFAULT_LOG_NAME;
        }
        log = LoggerFactory.getLogger(name);
        log(LogChute.DEBUG_ID, "Slf4jLogChute name is '" + name + "'");
    }
项目:simile-butterfly    文件:ButterflyResourceLoader.java   
@Override
public void commonInit(RuntimeServices rs, ExtendedProperties configuration) {
    super.commonInit(rs, configuration);
    Object o = rs.getApplicationAttribute("module");
    if (o != null) {
        _module = (ButterflyModule) o;
    } else {
        throw new RuntimeException("The ButterflyResourceLoader couldn't find an instance to the module!");
    }
}
项目:velocity-scripting    文件:RepeatDirective.java   
@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);
      switch (i) {
        case 2:
          this.separator = value;
          break;
        case 3:
          this.open = value;
          break;
        case 4:
          this.close = value;
          break;
        default:
          break;
      }
    } else {
      throw new TemplateInitException("Syntax error", getTemplateName(), getLine(), getColumn());
    }
  }
  this.uberInfo = new Info(this.getTemplateName(), getLine(), getColumn());
}
项目:mybatis-3    文件:VelocitySqlSource.java   
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);
  }
}
项目:yajsw    文件:VelocityLog.java   
public void init(RuntimeServices arg0) throws Exception
{
    // TODO Auto-generated method stub

}
项目:PrOfESSOS    文件:Slf4jLogger.java   
@Override
   public void init(RuntimeServices rs) throws Exception {
// nothing to do
   }
项目:fsm-packagetype    文件:OptionalIncludeEventHandler.java   
@Override
public void setRuntimeServices(final RuntimeServices runtimeServices) {
  this.runtimeServices = runtimeServices;
}
项目:cibet    文件:VelocityLogger.java   
@Override
public void init(RuntimeServices arg0) throws Exception {
}
项目:openeet-android    文件:Logger.java   
@Override
public void init(RuntimeServices arg0) throws Exception {
}
项目:intellij-ce-playground    文件:FileTemplateUtil.java   
@Override
public void init(RuntimeServices runtimeServices) throws Exception {
}
项目:nexus-public    文件:Slf4jLogChute.java   
public void init(final RuntimeServices srv) throws Exception {
  // nothing
}
项目:java-template-simple    文件:VelocityEscapeHtmlOutput.java   
public void setRuntimeServices(RuntimeServices rs) {
    this.rs = rs;
}
项目:java-template-simple    文件:VelocityEscapeHtmlOutput.java   
protected RuntimeServices getRuntimeServices() {
    return this.rs;
}
项目:jannocessor    文件:VelocityTemplateRenderer.java   
@Override
public void init(RuntimeServices rs) throws Exception {
}
项目:htmlcompressor    文件:HtmlCompressorDirective.java   
@Override
public void init(RuntimeServices rs, InternalContextAdapter context, Node node) throws TemplateInitException {
    super.init(rs, context, node);
    log = rs.getLog();

    boolean compressJavaScript = rs.getBoolean("userdirective.compressHtml.compressJavaScript", false);

    //set compressor properties
    htmlCompressor.setEnabled(rs.getBoolean("userdirective.compressHtml.enabled", true));
    htmlCompressor.setRemoveComments(rs.getBoolean("userdirective.compressHtml.removeComments", true));
    htmlCompressor.setRemoveMultiSpaces(rs.getBoolean("userdirective.compressHtml.removeMultiSpaces", true));
    htmlCompressor.setRemoveIntertagSpaces(rs.getBoolean("userdirective.compressHtml.removeIntertagSpaces", false));
    htmlCompressor.setRemoveQuotes(rs.getBoolean("userdirective.compressHtml.removeQuotes", false));
    htmlCompressor.setPreserveLineBreaks(rs.getBoolean("userdirective.compressHtml.preserveLineBreaks", false));
    htmlCompressor.setCompressJavaScript(compressJavaScript);
    htmlCompressor.setCompressCss(rs.getBoolean("userdirective.compressHtml.compressCss", false));
    htmlCompressor.setYuiJsNoMunge(rs.getBoolean("userdirective.compressHtml.yuiJsNoMunge", false));
    htmlCompressor.setYuiJsPreserveAllSemiColons(rs.getBoolean("userdirective.compressHtml.yuiJsPreserveAllSemiColons", false));
    htmlCompressor.setYuiJsLineBreak(rs.getInt("userdirective.compressHtml.yuiJsLineBreak", -1));
    htmlCompressor.setYuiCssLineBreak(rs.getInt("userdirective.compressHtml.yuiCssLineBreak", -1));
    htmlCompressor.setSimpleDoctype(rs.getBoolean("userdirective.compressHtml.simpleDoctype", false));
    htmlCompressor.setRemoveScriptAttributes(rs.getBoolean("userdirective.compressHtml.removeScriptAttributes", false));
    htmlCompressor.setRemoveStyleAttributes(rs.getBoolean("userdirective.compressHtml.removeStyleAttributes", false));
    htmlCompressor.setRemoveLinkAttributes(rs.getBoolean("userdirective.compressHtml.removeLinkAttributes", false));
    htmlCompressor.setRemoveFormAttributes(rs.getBoolean("userdirective.compressHtml.removeFormAttributes", false));
    htmlCompressor.setRemoveInputAttributes(rs.getBoolean("userdirective.compressHtml.removeInputAttributes", false));
    htmlCompressor.setSimpleBooleanAttributes(rs.getBoolean("userdirective.compressHtml.simpleBooleanAttributes", false));
    htmlCompressor.setRemoveJavaScriptProtocol(rs.getBoolean("userdirective.compressHtml.removeJavaScriptProtocol", false));
    htmlCompressor.setRemoveHttpProtocol(rs.getBoolean("userdirective.compressHtml.removeHttpProtocol", false));
    htmlCompressor.setRemoveHttpsProtocol(rs.getBoolean("userdirective.compressHtml.removeHttpsProtocol", false));


    if(compressJavaScript && rs.getString("userdirective.compressHtml.jsCompressor", HtmlCompressor.JS_COMPRESSOR_YUI).equalsIgnoreCase(HtmlCompressor.JS_COMPRESSOR_CLOSURE)) {
        String closureOptLevel = rs.getString("userdirective.compressHtml.closureOptLevel", ClosureJavaScriptCompressor.COMPILATION_LEVEL_SIMPLE);

        ClosureJavaScriptCompressor closureCompressor = new ClosureJavaScriptCompressor();
        if(closureOptLevel.equalsIgnoreCase(ClosureJavaScriptCompressor.COMPILATION_LEVEL_ADVANCED)) {
            closureCompressor.setCompilationLevel(CompilationLevel.ADVANCED_OPTIMIZATIONS);
        } else if(closureOptLevel.equalsIgnoreCase(ClosureJavaScriptCompressor.COMPILATION_LEVEL_WHITESPACE)) {
            closureCompressor.setCompilationLevel(CompilationLevel.WHITESPACE_ONLY);
        } else {
            closureCompressor.setCompilationLevel(CompilationLevel.SIMPLE_OPTIMIZATIONS);
        }

        htmlCompressor.setJavaScriptCompressor(closureCompressor);
    }
}
项目:jpublish    文件:JPublishResourceLoader.java   
/**
 * Common init method for ResourceLoaders.
 *
 * @param rs            The RuntimeServices
 * @param configuration The configuration
 */

public void commonInit(RuntimeServices rs, ExtendedProperties configuration) {

    if (log.isDebugEnabled())
        log.debug("commonInit()");

    super.commonInit(rs, configuration);

    Object siteContext = rs.getProperty("jpublish.resource.loader.siteContext");
    if (log.isDebugEnabled())
        log.debug("SiteContext from rs: " + siteContext);

    if (siteContext == null) {
        siteContext = configuration.get("jpublish.resource.loader.siteContext");

        if (log.isDebugEnabled())
            log.debug("SiteContext from configuration: " + siteContext);
    }

    setSiteContext((SiteContext) siteContext);
}
项目:watcher    文件:VelocityLogChute.java   
@Override
public void init(RuntimeServices rs) throws Exception {
}
项目:genotype-list    文件:SparkModule.java   
@Override
public void init(final RuntimeServices runtimeServices) throws Exception {
    // empty
}
项目:guzz    文件:GuzzAddInLimitDirective.java   
public void init(RuntimeServices rs, InternalContextAdapter context, Node node) throws TemplateInitException {
    super.init(rs, context, node);

    this.guzzContext = (GuzzContext) rs.getApplicationAttribute(SummonDirective.GUZZ_CONTEXT_NAME) ;
}
项目:guzz    文件:SummonDirective.java   
public void init(RuntimeServices rs, InternalContextAdapter context, Node node) throws TemplateInitException {
    super.init(rs, context, node);

    this.guzzContext = (GuzzContext) rs.getApplicationAttribute(GUZZ_CONTEXT_NAME) ;
}