Currently there's no published API to capture those calls. So the best
you can do is what you did. Of course it can break in any future
FreeMarker releases... so at least add a runtime check that you are
actually overriding that method, and give an explanation error message
if you don't. I add to my TODO considering a such feature, but that's
the best I can do for now.
As of Spring, I have no experience with Spring+FreeMarker, but maybe
it sets the beans wrapper itself in FreeMarkerConfigurer and
overwrites you setting. It should work otherwise.
Thursday, October 30, 2014, 10:46:42 PM, dmgcodevil wrote:
> Hi falks,
> I'm developing project where I use freemarker. There is need to
> intercept method invocation in BeansWrapper namely 'invokeMethod'.
> TemplateModel invokeMethod(Object object, Method method, Object args)
> This method has private-package access level. I looked into source but
> didn't find a way how i can intercept this method. I need to know which
> fileds of my domain object are called on ftls. I need to generate log
> something like this:
> ftl name: 'user.ftl' uses ''com.github.User' class and invokes next
> methods: 'getName' and etc.
> Please could you help me? I use spring+freemarker
> I tried register my own BeansWrapper
> <bean id="freemarkerConfig"
> <property name="templateLoaderPath" value="/WEB-INF/ftl/"/>
> <property name="freemarkerSettings">
> but see that in BeanModel
> retval = wrapper.invokeMethod(object, pd.getReadMethod(), null);
> wrapper is instance of freemarker.ext.beans.BeansWrapper but not my
> Could you give me advice ?