1 18 19 package org.objectweb.kilim.repository; 20 21 import java.io.InputStream ; 22 23 import org.objectweb.kilim.KilimLoggerFactory; 24 import org.objectweb.util.monolog.api.BasicLevel; 25 import org.objectweb.util.monolog.api.Logger; 26 27 31 public class ClassLoaderResourceLoader implements ResourceLoader { 32 33 private static boolean DEBUG_ON = false; 34 private static Logger logger = KilimLoggerFactory.getSingleton().getLogger("org.objectweb.kilim.repository"); 35 36 40 public ClassLoaderResourceLoader(ClassLoader resourceLoader) { 41 this.resourceLoader = resourceLoader; 42 } 43 44 47 public InputStream getResource(String resourceName) throws ResourceNotFoundException { 48 if (DEBUG_ON && logger.isLoggable(BasicLevel.DEBUG)) { 49 logger.log(BasicLevel.DEBUG, "Getting resource \"" + resourceName + "\"."); 50 } 51 InputStream res = resourceLoader.getResourceAsStream(resourceName); 52 53 if (res == null) { 54 throw new ResourceNotFoundException(resourceName); 55 } 56 57 return res; 58 } 59 60 private ClassLoader resourceLoader; 61 62 } 63 | Popular Tags |