From: Greg W. (JIRA) <ji...@co...> - 2006-12-12 17:00:49
|
[ http://jira.codehaus.org/browse/JETTY-199?page=comments#action_82495 ] Greg Wilkins commented on JETTY-199: ------------------------------------ Matthew, I think I have implemented this without the new class. I have simply added more static methods on Resource in the same way as we have getSystemResource (which is pretty much the same). Is this good enough? checked into head. /* ------------------------------------------------------------ */ /** Find a classpath resource. */ public static Resource newClassPathResource(String resource) { return newClassPathResource(resource,true,false); } /* ------------------------------------------------------------ */ /** Find a classpath resource. * The {@java.lang.Class#getResource} method is used to lookup the resource. If it is not * found, then the {@link Loader#getResource(Class, String, boolean)} method is used. * If it is still not found, then {@link ClassLoader#getSystemResource(String)} is used. * Unlike {@link #getSystemResource} this method does not check for normal resources. * @param name The relative name of the resouce * @param useCaches True if URL caches are to be used. * @param checkParents True if forced searching of parent classloaders is performed to work around * loaders with inverted priorities * @return Resource or null */ public static Resource newClassPathResource(String name,boolean useCaches,boolean checkParents) { URL url=Resource.class.getResource(name); if (url==null) { try { url=Loader.getResource(Resource.class,name,checkParents); } catch(ClassNotFoundException e) { url=ClassLoader.getSystemResource(name); } } if (url==null) return null; return newResource(url,useCaches); } > Patch to provide new ClassPathResource in jetty with JUnits > ----------------------------------------------------------- > > Key: JETTY-199 > URL: http://jira.codehaus.org/browse/JETTY-199 > Project: Jetty > Issue Type: New Feature > Affects Versions: 6.1.0rc1 > Reporter: Matthew Purland > Attachments: JETTY-199-ClassPathResource.patch > > Original Estimate: 15 minutes > Remaining Estimate: 15 minutes > > This patch includes a new class ClassPathResource to find resources by 1) relative classpath 2) system classpath. This patch also includes additional JUnit tests -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |