/** * Resolves a URL of the resource specified using the provided class as hint to start the search. For searching * the resource the consumer's classloader is used. * @param resource * the path the resource. The path can be either absolute or relative to the consumers location. * @param consumer * the consumer class of the resource. It's classloader is used for the lookup and it's location is used * as reference point for resolving relative path names * @return */ public URL resolve(String resource, Class consumer){ final ClassLoader ccl = Thread.currentThread().getContextClassLoader(); final String resourcePath = resolvePath(resource, consumer); URL contentUrl = null; if (ccl != null) { contentUrl = ccl.getResource(resourcePath); } if (contentUrl == null) { contentUrl = consumer.getResource(resourcePath); } if(failOnMissingResource && contentUrl == null){ throw new AssertionError("Resource " + resource + " not found"); } return contentUrl; }