public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
if (method.getReturnType() == AbstractImagePrototype.class) {
String url = getImageUrl(method);
return new ClippedImagePrototype(url, 0, 0, 0, 0);
}
throw new GwtTestResourcesException("Not managed return type for image bundle : "
+ method.getReturnType().getSimpleName());
}
private String computeFileSimpleName(Method method) {
String packagePath = method.getDeclaringClass().getPackage().getName().replaceAll(
"\\.", "/");
String relativePath = packagePath + "/" + method.getName();
for (String extension : IMAGE_DEFAULT_EXTENSIONS) {
String possiblePath = relativePath + extension;
if (this.getClass().getResource("/" + possiblePath) != null) {
return method.getName() + extension;
}
}
// should never happened
throw new GwtTestResourcesException("Cannot find an image with path relative to '"
+ relativePath + "'");
}
private String getImageUrl(Method method) {
String fileName;