/// <summary> simple Init - Get the key</summary> public override void Init(IRuntimeServices rs, IInternalContextAdapter context, INode node) { base.Init(rs, context, node); log = rs.Log; /* * default max depth of two is used because intentional recursion is * unlikely and discouraged, so make unintentional ones end fast */ maxDepth = rs.GetInt(NVelocity.Runtime.RuntimeConstants.DEFINE_DIRECTIVE_MAXDEPTH, 2); /* * 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.GetChild(0).FirstToken.Image.Substring(1); /** * No checking is done. We just grab the second child node and assume * that it's the block! */ block = node.GetChild(1); /** * keep tabs on the template this came from */ definingTemplate = context.CurrentTemplateName; }
/// <summary> Create the underlying "pool".</summary> /// <param name="rsvc"> /// </param> public virtual void Initialize(IRuntimeServices rsvc) { max = rsvc.GetInt(NVelocity.Runtime.RuntimeConstants.PARSER_POOL_SIZE, NVelocity.Runtime.RuntimeConstants.NUMBER_OF_PARSERS); pool = new SimplePool <Parser.Parser>(max); for (int i = 0; i < max; i++) { pool.Put(rsvc.CreateNewParser()); } if (rsvc.Log.DebugEnabled) { rsvc.Log.Debug("Created '" + max + "' parsers."); } }
public void initialize(IRuntimeServices rs) { runtimeServices = rs; int maxSize = runtimeServices.GetInt(RuntimeConstants.RESOURCE_MANAGER_DEFAULTCACHE_SIZE, 89); if (maxSize > 0) { // Create a whole new Map here to avoid hanging on to a // handle to the unsynch'd LRUMap for our lifetime. LRUMap lruCache = LRUMap.Synchronized(new LRUMap(maxSize)); lruCache.AddAll(cache); cache = lruCache; } runtimeServices.Info(string.Format("ResourceCache : initialized. ({0})", GetType())); }
/// <seealso cref="org.apache.velocity.runtime.resource.ResourceCache.Initialize(org.apache.velocity.runtime.RuntimeServices)"> /// </seealso> public virtual void Initialize(IRuntimeServices rs) { rsvc = rs; int maxSize = rsvc.GetInt(NVelocity.Runtime.RuntimeConstants.RESOURCE_MANAGER_DEFAULTCACHE_SIZE, 89); if (maxSize > 0) { // Create a whole new Map here to avoid hanging on to a // handle to the unsynch'd LRUMap for our lifetime. LRUMap lruCache = LRUMap.Synchronized(new LRUMap(maxSize)); lruCache.AddAll(cache); cache = lruCache; } rsvc.Log.Debug("ResourceCache: initialized (" + this.GetType() + ") with " + cache.GetType() + " cache map."); }
public void initialize(IRuntimeServices rs) { runtimeServices = rs; int maxSize = runtimeServices.GetInt(RuntimeConstants.RESOURCE_MANAGER_DEFAULTCACHE_SIZE, 89); if (maxSize > 0) { // Create a whole new Map here to avoid hanging on to a // handle to the unsynch'd LRUMap for our lifetime. LRUMap lruCache = LRUMap.Synchronized(new LRUMap(maxSize)); lruCache.AddAll(cache); cache = lruCache; } runtimeServices.Info(string.Format("ResourceCache : initialized. ({0})", GetType())); }