Update of /var/cvs/src/org/mmbase/util In directory james.mmbase.org:/tmp/cvs-serv18307
Modified Files: Tag: MMBase-1_8 ResourceLoader.java Log Message: backport of resourceloader See also: http://cvs.mmbase.org/viewcvs/src/org/mmbase/util Index: ResourceLoader.java =================================================================== RCS file: /var/cvs/src/org/mmbase/util/ResourceLoader.java,v retrieving revision 1.39.2.12 retrieving revision 1.39.2.13 diff -u -b -r1.39.2.12 -r1.39.2.13 --- ResourceLoader.java 12 Nov 2008 16:38:01 -0000 1.39.2.12 +++ ResourceLoader.java 13 Nov 2008 13:08:10 -0000 1.39.2.13 @@ -98,7 +98,7 @@ * <p>For property-files, the java-unicode-escaping is undone on loading, and applied on saving, so there is no need to think of that.</p> * @author Michiel Meeuwissen * @since MMBase-1.8 - * @version $Id: ResourceLoader.java,v 1.39.2.12 2008/11/12 16:38:01 michiel Exp $ + * @version $Id: ResourceLoader.java,v 1.39.2.13 2008/11/13 13:08:10 michiel Exp $ */ public class ResourceLoader extends ClassLoader { @@ -290,6 +290,7 @@ return path; } + /** * Utility method to return the name of the directory of a resource-name. This does not include * any /-chars any more. @@ -1701,10 +1702,10 @@ readClassWeights(); } - - - - private static final Comparator urlComparator = new Comparator() { + private static Comparator urlComparator; + private static Comparator getUrlComparator() { + if (urlComparator == null) { + urlComparator = new Comparator() { public int compare(final Object o1, final Object o2) { URL u1 = (URL) o1; URL u2 = (URL) o2; @@ -1712,6 +1713,7 @@ int w2 = 0; boolean foundw1 = false; boolean foundw2 = false; + if (classWeights != null) { Iterator i = classWeights.entrySet().iterator(); while (i.hasNext()) { Map.Entry e = (Map.Entry) i.next(); @@ -1726,6 +1728,7 @@ foundw2 = true; } } + } int r = w2 - 1; return r == 0 ? u1.toString().compareTo(u2.toString()) : r; @@ -1734,7 +1737,9 @@ return o == this; } }; - + } + return urlComparator; + } protected class ClassLoaderURLStreamHandler extends PathURLStreamHandler { @@ -1780,7 +1785,7 @@ * @since MMBase-1.9.1 */ protected SortedSet getSortedResources(String name) throws IOException { - SortedSet result = new TreeSet(urlComparator); + SortedSet result = new TreeSet(getUrlComparator()); Enumeration e = getClassLoader().getResources(getClassResourceName(name)); while (e.hasMoreElements()) { _______________________________________________ Cvs mailing list Cvs@lists.mmbase.org http://lists.mmbase.org/mailman/listinfo/cvs