Re: templates path not reloading on clearTemplateCache()
Attila Szegedi <[email protected]>
| Newsgroups | gmane.comp.web.freemarker.user |
|---|---|
| Message-ID | <[email protected]> |
Hm... This is strange - FreeMarker's FileTemplateLoader doesn't use canonicalized paths to load templates... Now, instead of clearing the template cache, you could call Configuration.setDirectoryForTemplateLoading() again with the path (or Configuration.setTemplateLoader() with a recreated FileTemplateLoader). That will recreate the FileTemplateLoader object and should get rid of any stuck state (with the disclaimer that there should be no such stuck state anyway). Changing the template loader also internally triggers cache clearing. There is actually another reason why would you want to recreate the template loader if you're chaning symlinks. The reason is that a FileTemplateLoader will resolve a path to a canonical path on construction, and will refuse to serve files from outside the canonical location the symlink resolves to. Note: it is _not_ using the canonical path to look up templates, it is just comparing the canonical path of the root template directory with the canonical path of the template, and if the former isn't a prefix of the latter, refuses to load the template. Alternatively, you can just create a FileTemplateLoader with the two- arg constructor and pass true for parameter "allowLinking" in the constructor, and then it won't care about canonical paths at all. Attila. On 2009.02.07., at 20:53, Matthew Anderson wrote: > We are having an issue that when we clear the template cache using > clearTemplateCache(), we dont get the new templates. Here is our > settup. > > We have a symlinked path to our templates. > > path to templates that we load: /mypath/templates > This path is a symlink pointing to the real hard linked path for the > templates > ie: v1 of templates path is /local/templates/v1 > v2 of templates path os /local/templates/v2 > > Reproduce steps: > /mypath/templates points to /local/templates/v1 > We deploy new templates to v2 path, and flip the symlink /mypath/ > templates to now point to /local/templates/v2 > > Every five minutes, our service checks to see if the canonical path > has changed for the template dir path, and if it has, then we call > clearTemplateCache() > > However, the templates from v1 path are still getting picked up. Is > there a way to force freemarker to reload the symlink path? It > seems as if there is a handle somewhere to the old symlinked > directory. > > thanks, > matthew ------------------------------------------------------------------------------ Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM) software. With Adobe AIR, Ajax developers can use existing skills and code to build responsive, highly engaging applications that combine the power of local resources and data with the reach of the web. Download the Adobe AIR SDK and Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com