Update of /var/cvs/src/org/mmbase/util
In directory james.mmbase.org:/tmp/cvs-serv13778
Modified Files:
ResourceLoader.java
Log Message:
during init of ResourceLoader itself, some of the static members could still be
null
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.80
retrieving revision 1.81
diff -u -b -r1.80 -r1.81
--- ResourceLoader.java 12 Nov 2008 17:09:11 -0000 1.80
+++ ResourceLoader.java 12 Nov 2008 17:33:39 -0000 1.81
@@ -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.80 2008/11/12 17:09:11 michiel Exp $
+ * @version $Id: ResourceLoader.java,v 1.81 2008/11/12 17:33:39 michiel Exp $
*/
public class ResourceLoader extends ClassLoader {
@@ -1748,22 +1748,28 @@
*/
public static int getWeight(final URL u) {
int w = 0;
+ if (classWeights != null) {
for (Map.Entry<Pattern, Integer> e : classWeights.entrySet()) {
if (e.getKey().matcher(u.toExternalForm()).matches()) {
w = e.getValue();
break;
}
}
+ }
return w;
}
- private static final Comparator<URL> urlComparator = new Comparator<URL>()
{
+ private static Comparator<URL> urlComparator;
+ private static Comparator<URL> getUrlComparator() {
+ if (urlComparator == null) {
+ urlComparator = new Comparator<URL>() {
public int compare(final URL u1, final URL u2) {
int w1 = 0;
int w2 = 0;
boolean foundw1 = false;
boolean foundw2 = false;
+ if (classWeights != null) {
for (Map.Entry<Pattern, Integer> e : classWeights.entrySet()) {
Pattern p = e.getKey();
if (! foundw1 && p.matcher(u1.toExternalForm()).matches()) {
@@ -1778,6 +1784,7 @@
}
if (foundw1 && foundw2) break;
}
+ }
int r = w2 - 1;
return r == 0 ? u1.toString().compareTo(u2.toString()) : r;
@@ -1786,6 +1793,9 @@
return o == this;
}
};
+ }
+ return urlComparator;
+ }
@@ -1832,7 +1842,7 @@
* @since MMBase-1.9.1
*/
protected SortedSet<URL> getSortedResources(String name) throws
IOException {
- SortedSet<URL> result = new TreeSet<URL>(urlComparator);
+ SortedSet<URL> result = new TreeSet<URL>(getUrlComparator());
String crn = getClassResourceName(name);
Enumeration<URL> e = getClassLoader().getResources(crn);
while (e.hasMoreElements()) {
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs