Refine search
/** Copied from org.apache.velocity.app.VelocityEngine。 */ private boolean mergeTemplate(String templateName, String encoding, Context context, Writer writer) throws ResourceNotFoundException, ParseErrorException, MethodInvocationException, Exception { Template template = ri.getTemplate(templateName, encoding); if (template == null) { String msg = "VelocityEngine.mergeTemplate() was unable to load template '" + templateName + "'"; ri.getLog().error(msg); throw new ResourceNotFoundException(msg); } else { template.merge(context, writer); return true; } }
/** 初始化resource loader. */ @Override public void init(ExtendedProperties configuration) { rsvc.getLog().info(getLogID() + " : initialization starting."); springLoader = assertNotNull((ResourceLoader) rsvc.getApplicationAttribute(SPRING_RESOURCE_LOADER_KEY), SPRING_RESOURCE_LOADER_KEY); path = normalizeAbsolutePath(configuration.getString("path"), true); assertTrue(!isEmpty(path), "path"); path += "/"; rsvc.getLog().info(getLogID() + " : set path '" + path + "'"); rsvc.getLog().info(getLogID() + " : initialization complete."); }
/** * Standard constructor * @param clazz The class for which this ClassMap gets constructed. */ public ClassMap(final Class clazz, final Log log) { this.clazz = clazz; this.log = log; if (debugReflection && log.isDebugEnabled()) { log.debug("================================================================="); log.debug("== Class: " + clazz); } methodCache = createMethodCache(); if (debugReflection && log.isDebugEnabled()) { log.debug("================================================================="); } }
/** * This is abstract in the base class, so we need it * @param configuration */ public void init( ExtendedProperties configuration) { if (log.isTraceEnabled()) { log.trace("ClasspathResourceLoader : initialization complete."); } }
log.trace("StringResourceLoader : initialization starting."); String repoClass = configuration.getString(REPOSITORY_CLASS, REPOSITORY_CLASS_DEFAULT); String repoName = configuration.getString(REPOSITORY_NAME, REPOSITORY_NAME_DEFAULT); boolean isStatic = configuration.getBoolean(REPOSITORY_STATIC, REPOSITORY_STATIC_DEFAULT); String encoding = configuration.getString(REPOSITORY_ENCODING); if (repository != null && log.isDebugEnabled()) { log.debug("Loaded repository '" + repoName + "' from static repo store"); repository = (StringResourceRepository) rsvc.getApplicationAttribute(repoName); if (repository != null && log.isDebugEnabled()) { log.debug("Loaded repository '" + repoName + "' from application attributes"); setRepository(repoName, this.repository); } else { rsvc.setApplicationAttribute(repoName, this.repository); log.warn("Cannot change class of string repository '" + repoName + "' from " + repository.getClass().getName() + " to " + repoClass); if (log.isInfoEnabled()) { log.info("Changing the default encoding of string repository '" + repoName + "' from " + repository.getEncoding() + " to " + encoding); log.trace("StringResourceLoader : initialization complete.");
int numArgs = node.jjtGetNumChildren(); rs.getLog().error("#macro error : Velocimacro must have name as 1st " + "argument to #macro(). #args = " + numArgs); int firstType = node.jjtGetChild(0).getType(); if(firstType != ParserTreeConstants.JJTWORD)
Object left = jjtGetChild(0).value( context ); Object right = jjtGetChild(1).value( context ); + jjtGetChild( (left == null? 0 : 1) ).literal() + ") of '<=' operation has null value at " + Log.formatFileString(this); if (rsvc.getBoolean(RuntimeConstants.RUNTIME_REFERENCES_STRICT, false)) log.error(msg); return false; + Log.formatFileString(this); if (rsvc.getBoolean(RuntimeConstants.RUNTIME_REFERENCES_STRICT, false)) log.error(msg); return false;
public boolean render(InternalContextAdapter context, Writer writer, Node node) throws IOException, ResourceNotFoundException, ParseErrorException, MethodInvocationException { //render content StringWriter content = new StringWriter(); node.jjtGetChild(0).render(context, content); //compress try { writer.write(xmlCompressor.compress(content.toString())); } catch (Exception e) { writer.write(content.toString()); String msg = "Failed to compress content: "+content.toString(); log.error(msg, e); throw new RuntimeException(msg, e); } return true; }
if (log.isTraceEnabled()) log.trace("FileResourceLoader : initialization starting."); paths.addAll( configuration.getVector("path") ); unicode = configuration.getBoolean("unicode", false); if (log.isDebugEnabled()) log.debug("Do unicode file recognition: " + unicode); if (log.isDebugEnabled()) for( int i=0; i < sz; i++) log.debug("FileResourceLoader : adding path '" + (String) paths.get(i) + "'"); log.trace("FileResourceLoader : initialization complete.");
@Override public boolean render(InternalContextAdapter context, Writer writer, Node node) throws IOException, ResourceNotFoundException, ParseErrorException, MethodInvocationException { if ( node.jjtGetNumChildren() == 0 ) { throw new VelocityException("#require(): argument missing at " + Log.formatFileString(this)); } Resource fisResource = Util.getResource(context); try { writer.write(fisResource.getUri(node.jjtGetChild(0).value(context).toString())); } catch (Exception err) { throw new VelocityException(err.getMessage() + Log.formatFileString(this)); } // ResourceManager.unRef(context); return true; } }
@Override @SuppressWarnings("unchecked") public boolean render(InternalContextAdapter context, Writer writer, Node node) throws IOException, ResourceNotFoundException, ParseErrorException, MethodInvocationException { Resource fisResource = Util.getResource(context); try { // 添加资源 Like Require fisResource.addResource(node.jjtGetChild(0).value(context).toString()); } catch (Exception err) { writer.write(err.getMessage() + " " + Log.formatFileString(this)); log.warn(err.getStackTrace()); } super.render(context, writer, node); // ResourceManager.unRef(context); return true; }
Token t = node.getLastToken(); if (t.image.startsWith(")") || t.image.startsWith("#end")) strictRef = rsvc.getBoolean(RuntimeConstants.RUNTIME_REFERENCES_STRICT, false); for (int n=0; n < node.jjtGetNumChildren(); n++) Node child = node.jjtGetChild(n); if (child.getType() == ParserTreeConstants.JJTWORD) badArgsErrorMsg = "Invalid arg '" + child.getFirstToken().image + "' in macro #" + macroName + " at " + Log.formatFileString(child);
int numArgs = node.jjtGetNumChildren(); argArray[i] = node.jjtGetChild(i).getFirstToken().image; msg.append(numArgs).append(" : "); macroToString(msg, argArray); rsvc.getLog().debug(msg);
/** * {@inheritDoc} * <p> * This implementation initializes the array of uberspectors. * </p> * * @see org.apache.velocity.util.introspection.Uberspect#init() */ @Override public void init() { this.log.debug("Initializing the linking uberspector."); // Create the array String[] arrayClassnames = this.runtime.getConfiguration().getStringArray(UBERSPECT_ARRAY_CLASSNAMES); this.uberspectors = new ArrayList<Uberspect>(arrayClassnames.length); for (String classname : arrayClassnames) { initializeUberspector(classname); } // If the chain is empty, use a SecureUberspector if (this.uberspectors.isEmpty()) { this.log.error("No uberspectors defined! " + "This uberspector is just a placeholder that relies on at least one real uberspector " + "to actually allow method calls. Using SecureUberspector instead as a fallback."); initializeUberspector(SecureUberspector.class.getCanonicalName()); } }
/** * simple init - get the key */ public void init(RuntimeServices rs, InternalContextAdapter context, Node node) throws TemplateInitException { super.init(rs, context, node); // the first child is the block name (key), the second child is the block AST body if ( node.jjtGetNumChildren() != 2 ) { throw new VelocityException("parameter missing: block name at " + Log.formatFileString(this)); } /* * first token is the name of the block. We don't even check the format, * just assume it looks like this: $block_name. Should we check if it has * a '$' or not? */ key = node.jjtGetChild(0).getFirstToken().image.substring(1); /* * default max depth of two is used because intentional recursion is * unlikely and discouraged, so make unintentional ones end fast */ maxDepth = rs.getInt(RuntimeConstants.DEFINE_DIRECTIVE_MAXDEPTH, 2); }
dataSourceName = StringUtils.nullTrim(configuration.getString("resource.datasource")); tableName = StringUtils.nullTrim(configuration.getString("resource.table")); keyColumn = StringUtils.nullTrim(configuration.getString("resource.keycolumn")); templateColumn = StringUtils.nullTrim(configuration.getString("resource.templatecolumn")); timestampColumn = StringUtils.nullTrim(configuration.getString("resource.timestampcolumn")); if (log.isDebugEnabled()) log.debug("DataSourceResourceLoader: using dataSource instance with table \"" + tableName + "\""); log.debug("DataSourceResourceLoader: using columns \"" + keyColumn + "\", \"" + templateColumn + "\" and \"" + timestampColumn + "\""); log.trace("DataSourceResourceLoader initialized."); if (log.isDebugEnabled()) log.debug("DataSourceResourceLoader: using \"" + dataSourceName + "\" datasource with table \"" + tableName + "\""); log.debug("DataSourceResourceLoader: using columns \"" + keyColumn + "\", \"" + templateColumn + "\" and \"" + timestampColumn + "\""); log.trace("DataSourceResourceLoader initialized."); log.error(msg); throw new RuntimeException(msg);
matchRegExp = StringUtils.nullTrim(rs.getConfiguration().getString(getMatchAttribute())); if ((matchRegExp != null) && (matchRegExp.length() == 0)) rs.getLog().error("Invalid regular expression '" + matchRegExp + "'. No escaping will be performed.", E); matchRegExp = null;
/** 初始化resource loader. */ @Override public void init(ExtendedProperties configuration) { rsvc.getLog().info(getLogID() + " : initialization starting."); preloadedResources = createTreeMap(); @SuppressWarnings("unchecked") Map<String, Resource> resources = assertNotNull( (Map<String, Resource>) configuration.getProperty(PRELOADED_RESOURCES_KEY), PRELOADED_RESOURCES_KEY); for (Map.Entry<String, Resource> entry : resources.entrySet()) { String templateName = normalizeTemplateName(entry.getKey()); Resource resource = entry.getValue(); preloadedResources.put(templateName, resource); } rsvc.getLog().info(getLogID() + " : preloaded resources: " + new MapBuilder().appendAll(preloadedResources)); rsvc.getLog().info(getLogID() + " : initialization complete."); }
/** * Create the underlying "pool". * @param rsvc */ public void initialize(RuntimeServices rsvc) { max = rsvc.getInt(RuntimeConstants.PARSER_POOL_SIZE, RuntimeConstants.NUMBER_OF_PARSERS); pool = new SimplePool(max); for (int i = 0; i < max; i++) { pool.put(rsvc.createNewParser()); } if (rsvc.getLog().isDebugEnabled()) { rsvc.getLog().debug("Created '" + max + "' parsers."); } }
log.trace("URLResourceLoader : initialization starting."); roots = configuration.getStringArray("root"); if (log.isDebugEnabled()) log.debug("URLResourceLoader : adding root '" + roots[i] + "'"); timeout = configuration.getInt("timeout", -1); if (timeout > 0) Method read = URLConnection.class.getMethod("setReadTimeout", types); timeoutMethods = new Method[] { conn, read }; log.debug("URLResourceLoader : timeout set to "+timeout); log.debug("URLResourceLoader : Java 1.5+ is required to customize timeout!", nsme); timeout = -1; log.trace("URLResourceLoader : initialization complete.");