When navigating an OGNL expression many of the elements that are found are properties. Properties can be many things depending on the object being accessed. Most of the time these property names resolve to JavaBeans
properties that conform to the set/get pattern. Other objects (such as Map
) access properties as keyed values. Regardless of access methodology the OGNL syntax remains the same. Under the hood, however, there are
PropertyAccessor
objects that handle the conversion of property name to an actual access to an objects' properties.
public interface PropertyAccessor { Object getProperty( Map context, Object target, Object name ) throws OgnlException; void setProperty( Map context, Object target, Object name, Object value ) throws OgnlException; }
You can set a property accessor on a class-by-class basis using OgnlRuntime.setPropertyAccessor()
. There are default property accessors for Object
(which uses JavaBeans patterns to extract
properties) and Map
(which uses the property name as a key).