Mercurial Hosting > luan
comparison src/org/eclipse/jetty/util/resource/Resource.java @ 830:7c737c376bc3
remove Loader
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 15 Sep 2016 18:30:38 -0600 |
parents | f89abbfb3a8f |
children | 6939226e0ac4 |
comparison
equal
deleted
inserted
replaced
829:dfa742c663f9 | 830:7c737c376bc3 |
---|---|
30 import java.text.DateFormat; | 30 import java.text.DateFormat; |
31 import java.util.Arrays; | 31 import java.util.Arrays; |
32 import java.util.Date; | 32 import java.util.Date; |
33 | 33 |
34 import org.eclipse.jetty.util.IO; | 34 import org.eclipse.jetty.util.IO; |
35 import org.eclipse.jetty.util.Loader; | |
36 import org.eclipse.jetty.util.StringUtil; | 35 import org.eclipse.jetty.util.StringUtil; |
37 import org.eclipse.jetty.util.URIUtil; | 36 import org.eclipse.jetty.util.URIUtil; |
38 import org.slf4j.Logger; | 37 import org.slf4j.Logger; |
39 import org.slf4j.LoggerFactory; | 38 import org.slf4j.LoggerFactory; |
40 | 39 |
255 return null; | 254 return null; |
256 | 255 |
257 return newResource(url); | 256 return newResource(url); |
258 } | 257 } |
259 | 258 |
260 /* ------------------------------------------------------------ */ | |
261 /** Find a classpath resource. | |
262 */ | |
263 public static Resource newClassPathResource(String resource) | |
264 { | |
265 return newClassPathResource(resource,true,false); | |
266 } | |
267 | |
268 /* ------------------------------------------------------------ */ | |
269 /** Find a classpath resource. | |
270 * The {@link java.lang.Class#getResource(String)} method is used to lookup the resource. If it is not | |
271 * found, then the {@link Loader#getResource(Class, String, boolean)} method is used. | |
272 * If it is still not found, then {@link ClassLoader#getSystemResource(String)} is used. | |
273 * Unlike {@link ClassLoader#getSystemResource(String)} this method does not check for normal resources. | |
274 * @param name The relative name of the resource | |
275 * @param useCaches True if URL caches are to be used. | |
276 * @param checkParents True if forced searching of parent Classloaders is performed to work around | |
277 * loaders with inverted priorities | |
278 * @return Resource or null | |
279 */ | |
280 public static Resource newClassPathResource(String name,boolean useCaches,boolean checkParents) | |
281 { | |
282 URL url=Resource.class.getResource(name); | |
283 | |
284 if (url==null) | |
285 url=Loader.getResource(Resource.class,name,checkParents); | |
286 if (url==null) | |
287 return null; | |
288 return newResource(url,useCaches); | |
289 } | |
290 | |
291 /* ------------------------------------------------------------ */ | 259 /* ------------------------------------------------------------ */ |
292 public static boolean isContainedIn (Resource r, Resource containingResource) throws MalformedURLException | 260 public static boolean isContainedIn (Resource r, Resource containingResource) throws MalformedURLException |
293 { | 261 { |
294 return r.isContainedIn(containingResource); | 262 return r.isContainedIn(containingResource); |
295 } | 263 } |