Method calls are another area where OGNL needs to do lookups for methods based on dynamic information. The MethodAccessor interface provides a hook into how OGNL calls a method. When a static or instance method is requested the implementor of this interface is called to actually execute the method.
public interface MethodAccessor { Object callStaticMethod( Map context, Class targetClass, String methodName, List args ) throws MethodFailedException; Object callMethod( Map context, Object target, String methodName, List args ) throws MethodFailedException; }
You can set a method accessor on a class-by-class basis using OgnlRuntime.setMethodAccessor()
. The is a default method accessor for Object
(which simply finds an appropriate method based
on method name and argument types and uses reflection to call the method).