@Override
public void apply(FaceletContext context, UIComponent parent) throws IOException {
String type = this.type.getValue(context);
final Class<?> cls = toClass(type);
final String var = (this.var != null) ? this.var : type.substring(type.lastIndexOf('.') + 1);
final FunctionMapper originalFunctionMapper = context.getFunctionMapper();
context.setFunctionMapper(new FunctionMapper() {
@Override
public Method resolveFunction(String prefix, String name) {
if (var.equals(prefix)) {
String key = cls + "." + name;
Method function = FUNCTIONS_CACHE.get(key);
if (function == null) {
function = findMethod(cls, name);
FUNCTIONS_CACHE.put(key, function);
}
return function;
}
else {
return originalFunctionMapper.resolveFunction(prefix, name);
}
}
});
}