In most cases a map-like data structure is used to provide data to the template engine. In many cases it is even a java.util.Map. What we could to is to provide some kind of lazy evaluating map which looks up the bean for all calls to get(String).
However, this only works if the engine allows to pass a map. If it just provides a set(String name, Object obj) like API, this won't be possible. In theory, we could collect ALL @Named beans and pass all of them to the engine, but this could lead to performance issues. We could create some kind of proxy for these beans and obtain them lazily, but this could require some kind of bytecode level proxy.
My thoughts about this:
In most cases a map-like data structure is used to provide data to the template engine. In many cases it is even a
java.util.Map
. What we could to is to provide some kind of lazy evaluating map which looks up the bean for all calls toget(String)
.Something like:
However, this only works if the engine allows to pass a map. If it just provides a
set(String name, Object obj)
like API, this won't be possible. In theory, we could collect ALL@Named
beans and pass all of them to the engine, but this could lead to performance issues. We could create some kind of proxy for these beans and obtain them lazily, but this could require some kind of bytecode level proxy.