In the sections on accessing static field and static methods it stated that classes must be full-specified in between the class reference specifier (@
<classname>
@
<field|method>@
).
This is not entirely true; the default ClassResolver
simply looks up the name of the class and assumes that it is fully specified. The ClassResolver
interface is included in the
OGNL context to perform lookup of classes when an expression is evaluated. This makes it possible to specify, for example, a list of imports that are specific to a particular setValue()
or
getValue()
context in order to look up classes. It also makes class references agreeably short because you don't have to full specify a class name.
public interface ClassResolver { public Class classForName(Map context, String className) throws ClassNotFoundException; }
You can set a class resolver on a context basis using the Ognl
methods addDefaultContext()
and createDefaultContext()
.