API / Apache FreeMarker Interview questions
What is the difference between BeansWrapper and DefaultObjectWrapper?
DefaultObjectWrapper extends BeansWrapper and is the wrapper application code is expected to use directly; it adds FreeMarker-aware handling for the engine's own built-in collection types (such as SimpleHash and SimpleSequence) and applies safer, more template-friendly defaults on top of the plain bean-introspection behavior.
| Aspect | BeansWrapper | DefaultObjectWrapper |
| Relationship | Base class | Subclass of BeansWrapper |
| Typical use | Lower-level building block, used internally or for special integrations | Recommended default for Configuration.setObjectWrapper() |
| Handling of FreeMarker's own model types | Treated like any other Java object | Recognized and handled specially |
In day-to-day application code there is rarely a reason to instantiate BeansWrapper directly - it exists mainly as the shared foundation that other, more template-appropriate wrappers build on.
More Related questions...