This is cleaner, more obvious what's going on underneath, but since the 
DefaultTemplateResolver will be the most commonly used you
could just leave the current setting methods as they are and just document that 
if you set a different TemplateResolver they will be
ignored.

-David


On Wed, 2017-02-15 at 14:56 +0100, Daniel Dekany wrote:
> An interesting consequence of introducing the TemplateResolver concept
> is that it the earlier top-level configuration settings, like
> templateLoader, templateLookupStrategy, templateNameFormat,
> cacheStorage, and templateUpdateDelayMillisecond should now be the
> settings (JavaBean properties) of DefaultTemplateResolver, not of
> Configuration. In theory at least. It's the same things as with
> ObjectWrapper, where multiple implementations are possible, and each
> has different settings.
> 
> This has some inconvenient consequences for the majority who uses the
> DefaultTemplateResolver. Earlier, you have written:
> 
>   cfg.setTemplateLoader(new FooTemplateLoader())
>   cfg.setTemplateUpdateDelayMilliseconds(10_000);
> 
> but now you had to write either:
> 
>   DefaultTemplateResolver dtr = new DefaultTemplateResolver();
>   dtr.setTemplateLoader(new FooTemplateLoader());
>   dtr.setTemplateUpdateDelayMilliseconds(10_000);
>   cfg.setTemplateResolver(dtr);
> 
> or alternatively:
> 
>   DefaultTemplateResolver dtr = (DefaultTemplateResolver) 
> dtr.getTemplateResolver();
>   dtr.setTemplateLoader(new FooTemplateLoader());
>   dtr.setTemplateUpdateDelayMilliseconds(10_000);
> 
> Also configuring with j.u.Properties becomes different, because you
> can't have this anymore:
> 
>   templateLoader = com.example.FooTemplateLoader
>   templateUpdateDelay = 10s
> 
> I guess instead it should be something like:
> 
>   templateResolver.templateLoader = com.example.FooTemplateLoader
>   templateResolver.templateUpdateDelay = 10s
> 
> which is a syntax that we don't yet support (dotted setting names).
> This syntax we do support though (in FM2):
> 
>   templateResolver=DefaultTemplateResolver( \
>           templateLoader = com.example.FooTemplateLoader, \
>           templateUpdateDelayMilliseconds = 10_000 \
>   )
> 
> but it has the problem that you can't, for example, set the
> templateUpdateDelay without also specifying the whole templateResolver
> with all of its settings. So that's where the dotted notation is
> better. OTOH for some other things the above syntax is better, like
> for specifying the templateConfigurations (see
> http://freemarker.org/docs/pgui_config_templateconfigurations.html).
> So I think we should have both, and since we must ensure that
> templateResolver=com.example.MyTemplateResolver is "executed" earlier
> than templateResolver.mySetting=foo anyway, if mySetting is specified
> on both places (i.e., you have
> templateResolver=com.example.MyTemplateResolver(mySetting="foo")
> there), then obviously templateResolver.mySetting wins.
> 
> And if we support the dotted notation in j.u.Properties, that should
> work for the objectWrapper setting too, naturally.
> 
> 
> 

Reply via email to