Re: I don't understand why cfg.setObjectWrapper(new DefaultObjectWrapper()); must be used
Daniel Dekany <[email protected]>
| Newsgroups | gmane.comp.web.freemarker.user |
|---|---|
| Message-ID | <[email protected]> |
Wednesday, June 18, 2008, 3:12:49 PM, Vañó Sempere, José Rafael wrote:
> Hello.
>
> I've seen something I don't understand in freemarker's documentation:
>
> Page
> http://www.freemarker.org/docs/pgui_quickstart_createconfiguration.html
> ("Create a configuration instance")
> says that
> cfg.setObjectWrapper(new DefaultObjectWrapper());
> must be used.
>
> I don't understant why cfg.setObjectWrapper(new DefaultObjectWrapper());
> is necessary.
FreeMarker was miss-designed earlier regarding the singleton wrapper,
so using it is not recommended anymore. It still works if you use
that, like earlier, but I show the current best practice in that
example.
> The default object wrapper is suposed to be a thread-safe singleton, isn't it?
Yes, but it's not read-only in the sense that you can change its
configuration settings. And that's what causes the problem... if
multiple independently developed system components use the singleton,
some may will re-configure it, and thus also re-configuring the
wrapper of the other components. Configuring the singleton should be
banned, but we can't fix it now as that would break many old
applications.
> By the way, I haven't seen that line in freemarker's examples.
Um... that's a problem.
> Thank you very much.
>
> Jose
>
> P.S.: Sorry for my English.
--
Best regards,
Daniel Dekany
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php