/** * @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 + '\''); }
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); } }
@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); } }
@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()); }
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; }
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); } }
/** * @작성자 : 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; }
/** * 重载init方法,初始自定义指令的配制参数 */ @Override public void init(RuntimeServices rs, InternalContextAdapter context, Node node) throws TemplateInitException { super.init(rs, context, node); initBean(); }
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); } }
@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); }
@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); }
@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)); }
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(); } }
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); } }
/********** 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 + "'"); }
/********** 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 + "'"); }
@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!"); } }
@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()); }
public void init(RuntimeServices arg0) throws Exception { // TODO Auto-generated method stub }
@Override public void init(RuntimeServices rs) throws Exception { // nothing to do }
@Override public void setRuntimeServices(final RuntimeServices runtimeServices) { this.runtimeServices = runtimeServices; }
@Override public void init(RuntimeServices arg0) throws Exception { }
@Override public void init(RuntimeServices runtimeServices) throws Exception { }
public void init(final RuntimeServices srv) throws Exception { // nothing }
public void setRuntimeServices(RuntimeServices rs) { this.rs = rs; }
protected RuntimeServices getRuntimeServices() { return this.rs; }
@Override public void init(RuntimeServices rs) throws Exception { }
@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); } }
/** * 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); }
@Override public void init(final RuntimeServices runtimeServices) throws Exception { // empty }
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) ; }
public void init(RuntimeServices rs, InternalContextAdapter context, Node node) throws TemplateInitException { super.init(rs, context, node); this.guzzContext = (GuzzContext) rs.getApplicationAttribute(GUZZ_CONTEXT_NAME) ; }