logger = logger.branch(TreeLogger.DEBUG, "Finding resources", null);
String[] resources;
// Check for Resource annotations first:
if (method.getAnnotation(Resource.class) != null) {
Resource resource = method.getAnnotation(Resource.class);
resources = resource.value();
} else {
String[][] md = method.getMetaData(METADATA_TAG);
if (md.length == 0) {
logger.log(TreeLogger.ERROR,
"Method " + method.getName() + " does not have a @"
+ Resource.class.getName() + " annotations.", null);
throw new UnableToCompleteException();
}
// Emit a deprecation warning about metadata:
logger.log(TreeLogger.WARN, "Method " + method.getName() + " uses a "
+ "deprecated @gwt.resources metadata annotation. Convert to @"
+ Resource.class.getName(), null);
resources = new String[md.length];
for (int tagIndex = 0; tagIndex < md.length; tagIndex++) {
int lastIndex = md[tagIndex].length - 1;
resources[tagIndex] = md[tagIndex][lastIndex];
}
}
String locale;
try {
PropertyOracle oracle = context.getGeneratorContext().getPropertyOracle();
locale = oracle.getPropertyValue(logger, "locale");
} catch (BadPropertyValueException e) {
locale = null;
}
URL[] toReturn = new URL[resources.length];
boolean error = false;
int tagIndex = 0;
for (String resource : resources) {
// Make sure the name is either absolute or package-relative.
if (resource.indexOf("/") == -1) {
String pkgName = method.getEnclosingType().getPackage().getName();
// This construction handles the default package correctly, too.
resource = pkgName.replace('.', '/') + "/" + resource;
}