Java Mailing List Archive

Home » FreeMarker-user »

Re: [FreeMarker-user] Removing templates manually from a cache.

Daniel Dekany


Replies: Find Java Web Hosting

Author LoginPost Reply
Thursday, December 15, 2011, 8:22:19 PM, Frank Zeyda wrote:

> Hi Daniel,
> Many thanks for such a quick reply and fix.
>> BTW the whole delay business has a design issue... it should be
>> per-template-loader. After all, what the ideal delay depends on how
>> resource consuming checking if the source was changed is.
> Yes, I agree. The delayed loading mechanism, for instance, does not equally
> make sense for all template loaders. So each loader should ideally be able to
> specify its own caching policy.
>> So, I just wonder of a 0 delay for the StringTemplateLoader and non-0 for the
>> FileTemplateLoader would solve your problem. Anyway, you can't do that...
> Yes, I suppose it would if this was possible.
>> You are supposed use the CacheStorage API only indirectly, trough the
>> Configuration API. Or at least I suppose that was the intent of the
>> authors.
> I see. I think that despite the above there is still the possibility of
> providing custom cache implementations at the user's end, so maybe for this
> reason the design was chosen.

I doubt that. So there is the TemplateCache class, which has only one
implementation shipped, and it has a TemplateLoader and a
TemplateStorage plugged into it. The last two has multiple
implementations, and they can be replaced through the Configuration

>> Can you get the TemplateCache instance at all? There's no
>> Configuration.getTemplateCache, nor setTemplateCache. I think the only
>> reason TemplateCache is public is that access control in Java is
>> overly simplistic for any product that has sub-packages.
> Ah, actually Configuration has a method void setCacheStorage(CacheStorage). So
> by creating and setting one's own cache, it is possible to get a reference to
> it!

You confuse the classes here. That's CacheStorage, not TemplateCache.

>> Anyway... I have added Configuration.removeTemlateFromCache to the 2.3
>> branch. Tell me if it works. Here's the build:
>> ...
> Great. Many thanks once more for looking at this so quickly!
> I checked out the svn sources to find out the signature of the method. It seems
> work without problems.
> PS: It would be nice to commit this branch to the maven repository to some
> point; I could then download it dynamically as part of my build process. For now
> I am using the attached freemarker.jar.

Sorry, we have no nightly Maven repo, and you are not supposed to push
nightly builds into the Maven Central Repo. That's their policy. So
until this is released (end of January, I hope), you can install it to
your local Maven repo, so the way your app is built remains exactly
the same as if it was in the Central repo.

> All the best,
> Frank

Best regards,
Daniel Dekany

10 Tips for Better Server Consolidation
Server virtualization is being driven by many needs.
But none more important than the need to reduce IT complexity
while improving strategic productivity. Learn More!
FreeMarker-user mailing list
©2008 - Jax Systems, LLC, U.S.A.