* @return The new graphic resource.
* @throws IllegalArgumentException When the "value" attribute of the given component is absent or does not
* represent a method expression referring an existing method taking at least one argument.
*/
public static GraphicResource create(FacesContext context, ValueExpression value, Object lastModified) {
MethodReference methodReference = ExpressionInspector.getMethodReference(context.getELContext(), value);
if (methodReference.getMethod() == null) {
throw new IllegalArgumentException(String.format(ERROR_UNKNOWN_METHOD, value.getExpressionString()));
}
String name = getResourceName(methodReference);
if (!ALLOWED_METHODS.containsKey(name)) { // No need to validate everytime when already known.
Class<? extends Object> beanClass = methodReference.getBase().getClass();
if (!isOneAnnotationPresent(beanClass, REQUIRED_ANNOTATION_TYPES)) {
throw new IllegalArgumentException(String.format(ERROR_INVALID_SCOPE, beanClass));
}
ALLOWED_METHODS.put(name, new MethodReference(methodReference.getBase(), methodReference.getMethod()));
}
Object[] params = methodReference.getActualParameters();
String[] convertedParams = convertToStrings(context, params, methodReference.getMethod().getParameterTypes());
return new GraphicResource(name, convertedParams, lastModified);
}