how does CacheReloadContext work? (was A WM brain bender)

Alex Twisleton-Wykeham-Fiennes <[email protected]>
Newsgroups gmane.comp.java.webmacro.user
Message-ID <[email protected]>
All,

a question this time:  If I want to extend my EvaluatingTemplateLoader to play 
nice with the caching construct then I am a little bit confused about the 
logic of the CacheReloadContext.  If I have the following code:-

package org.cord.node;

import org.webmacro.*;
import org.webmacro.engine.*;
import org.webmacro.resource.*;

public class EvaluatingTemplateLoader
  extends AbstractTemplateLoader 
{
  public final static String PROTOCOL = "evaluate:";

  public void setConfig(String config) 
  {
  }

  public Template load(String query,
                       CacheElement ce) 
    throws ResourceException
  {
    if (! query.startsWith(PROTOCOL)) {
      return null;
    }
    ce.setReloadContext(new CacheReloadContext() {
        public boolean shouldReload() 
        {
          return false;
        }
      });
    return new StringTemplate(broker,
                              query.substring(PROTOCOL.length()));
  }
}

then does that mean for a given value of query (which in this case actually 
holds the evaluatable content of the template) that the CacheManager will not 
invoke load(query,ce) on the EvaluatingTemplateLoader after the initial 
request?

If this is the case, then will the CacheManager expire the mapping of 
query:StringTemplate after some time (based around the implementation of 
CacheManager) or does it mean that it will try and hold onto it forever, 
thereby polluting the cache space?

My gut reaction is that the above is correct because the CacheReloadContext 
appears to relate to whether or not the relationship between query & 
resolvedQueryContent has changed, which in this case is guaranteed never to 
happen.

Thanks for you help

Alex


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.