Re: Spring Custom Template Loader
Daniel Dekany <[email protected]>
| Newsgroups | gmane.comp.web.freemarker.user |
|---|---|
| Message-ID | <[email protected]> |
Tuesday, May 26, 2009, 3:51:44 PM, Scott Purcell wrote: > > Hello, > > I wrote a custom freemarker.cache.TemplateLoader class that will > use my database for pulling out the template data. > > I am using Spring and want to set this new TemplateLoader so I can > try my new class. How is this accomplished? I am looking at > FreeMarkerConfigurationFactory but do not see anywhere unless it is > a property to inject my custom loader into? FreeMarker has no "setting" for that, which means you can't set that in Spring inside <property name="freemarkerSettings">. The only way to set it is through the API of the freemarker.template.Configuration instance. Now, the loader is often specific to the Web application framework, and thus the framework can have some assumptions about it... so be careful with the replacement. For that reason using a MultiTemplateLoader is maybe a good idea, where the first loader is that you about to replace, and the second one is your custom one. What is the best practice of doing the above under Spring, I don't know right now out of my head. But be sure the replacement of Spring's default TemplateLoader happens before multiple threads start accessing the freemarker.template.Configuration object, i.e., before the serving of the HTTP requests was started. > Thanks, > > Scott > > > > CONFIDENTIALITY NOTICE > This e-mail message and any attachments are only for the use of the > intended recipient and may contain information that is privileged, > confidential or exempt from disclosure under applicable law. If you > are not the intended recipient, any disclosure, distribution or > other use of this e-mail message or attachments is prohibited. If > you have received this e-mail message in error, please delete and > notify the sender immediately. Thank you. -- Best regards, Daniel Dekany ------------------------------------------------------------------------------ Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT is a gathering of tech-side developers & brand creativity professionals. Meet the minds behind Google Creative Lab, Visual Complexity, Processing, & iPhoneDevCamp as they present alongside digital heavyweights like Barbarian Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com