Configuration initialization per web request issue

Albert Kam <[email protected]> Sun, 10 Feb 2013 11:58:54 +0700
Newsgroups gmane.comp.web.freemarker.user
Message-ID <CAMT20g8PC-pMCK9XiR+2is7DjvC9pcznzVqsM=OPbDaO+2g3ag@mail.gmail.com>
I want to use freemarker's multiple StringTemplateLoader-s per each
request. This means that i will have to new Configuration() per each
request, right ?
I wonder if this is the right way to do it, since i've read somewhere that
Configuration should be initialized once per webapp because it's expensive ?

Why do i need this approach is because i want to get locale specific
templates per request, which i put inside a properties file, and then fill
up the templates.

Example of the entry in the properties file :
my.template.key1=my.freemarker.template1.here
my.template.key2=my.freemarker.template2.here

So the logic what i have in mind is :
- i have the keys in the UI (dynamiclly obtained)
- i load templates with resourcebundle depending of current user's locale
- initialize configuration object
- setup multiple string template loaders with those i load from
resourcebundle and set them to configuration object via MultiTemplateLoader
- setup the models n get the template outputs
- print them onto UI response

All of these can happen per web request.

Is this approach appropriate ? Thank you !

-- 
Do not pursue the past. Do not lose yourself in the future.
The past no longer is. The future has not yet come.
Looking deeply at life as it is in the very here and now,
the practitioner dwells in stability and freedom.
(Thich Nhat Hanh)

------------------------------------------------------------------------------
Free Next-Gen Firewall Hardware Offer
Buy your Sophos next-gen firewall before the end March 2013 
and get the hardware for free! Learn more.
http://p.sf.net/sfu/sophos-d2d-feb

_______________________________________________
FreeMarker-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freemarker-user