01: package org.objectweb.celtix.resource;
02:
03: import java.io.InputStream;
04: import java.net.URL;
05:
06: /**
07: * Resolve resources from the system class path.
08: */
09: public class ClasspathResolver implements ResourceResolver {
10:
11: public <T> T resolve(String resourceName, Class<T> resourceType) {
12: URL url = ClassLoader.getSystemResource(resourceName);
13: if (resourceType.isInstance(url)) {
14: return resourceType.cast(url);
15: }
16: return null;
17: }
18:
19: public InputStream getAsStream(String name) {
20: return ClassLoader.getSystemResourceAsStream(name);
21: }
22: }
|