1 16 package net.sf.dozer.util.mapping.util; 17 18 import java.io.File ; 19 import java.net.MalformedURLException ; 20 import java.net.URL ; 21 22 import net.sf.dozer.util.mapping.MappingException; 23 24 28 public class Loader { 29 30 public URL getResource(String resource) { 31 URL result = Thread.currentThread().getContextClassLoader().getResource(resource); 32 33 if (result == null) { 35 ClassLoader classLoader = Loader.class.getClassLoader(); 36 if(classLoader != null) { 37 result = classLoader.getResource(resource); 38 } 39 } 40 41 if (result == null) { 43 result = ClassLoader.getSystemResource(resource); 44 } 45 46 if (resource.startsWith(MapperConstants.FILE_PREFIX)) { 48 try { 49 return new File (resource.substring(MapperConstants.FILE_PREFIX.length())).toURL(); 50 } catch (MalformedURLException e) { 51 throw new MappingException(e); 52 } 53 } 54 55 return result; 56 } 57 58 } | Popular Tags |