Re: Best way to pass parameter to custom TemplateLoader?

Brian Pontarelli <[email protected]>
Newsgroups gmane.comp.web.freemarker.user
Message-ID <[email protected]>
I believe that Jetty still uses a single execution thread, but I could be wrong. The NIO module handles the incoming server socket connections and reads/writes in a single thread. That's the standard NIO model. Your only option might be a thread local. I haven't looked at the APIs, but I have had to do this with a number of frameworks because of the same issue you are having.

-bp


On Jul 11, 2011, at 11:04 AM, Chris wrote:

> I'm trying to implement a custom TemplateLoader for freemarker. This 
> loader needs to examine the HttpServletRequest to know where to get the 
> template source.
> 
> Unfortunately, Configuration.getTemplate() does not provide a way to 
> pass arbitrary parameters to the TemplateLoader.
> 
> One possible solution is to use some kind of ThreadLocal scheme. I'm 
> concerned that this may not work because in Jetty, our app server, 
> there's some fancy nio module that handles multiple connections per 
> thread, and I don't entirely understand how it works. Plus I'm 
> suspicious of anything that could lead to hard-to-debug threading issues.
> 
> Another way would be to create an Environment variable and add a custom 
> attribute to it, but unfortunately it appears that an Enviroment can 
> only get created after the template has been created.
> 
> I'm stuck.
> 
> 
> ------------------------------------------------------------------------------
> All of the data generated in your IT infrastructure is seriously valuable.
> Why? It contains a definitive record of application performance, security 
> threats, fraudulent activity, and more. Splunk takes this data and makes 
> sense of it. IT sense. And common sense.
> http://p.sf.net/sfu/splunk-d2d-c2
> _______________________________________________
> FreeMarker-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/freemarker-user


------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security 
threats, fraudulent activity, and more. Splunk takes this data and makes 
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2d-c2
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.