Author: almaw Date: Tue Jun 5 10:08:48 2007 New Revision: 544556 URL: http://svn.apache.org/viewvc?view=rev&rev=544556 Log: Fix for lazy-init.
Modified: incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/SharedResources.java Modified: incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/SharedResources.java URL: http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/SharedResources.java?view=diff&rev=544556&r1=544555&r2=544556 ============================================================================== --- incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/SharedResources.java (original) +++ incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/SharedResources.java Tue Jun 5 10:08:48 2007 @@ -16,9 +16,11 @@ */ package org.apache.wicket; +import java.lang.ref.WeakReference; import java.util.HashMap; import java.util.Locale; import java.util.Map; +import java.util.WeakHashMap; import org.apache.wicket.util.file.Files; import org.apache.wicket.util.string.AppendingStringBuffer; @@ -92,11 +94,13 @@ } /** Map of Class to alias String */ - private final Map classAliasMap = new HashMap(); - private final Map aliasClassMap = new HashMap(); + private final Map/*<Class, String>*/ classAliasMap = new WeakHashMap(); + + /** Map of alias String to WeakReference(Class) */ + private final Map/*<String, WeakReference<Class>>*/ aliasClassMap = new HashMap(); /** Map of shared resources states */ - private final Map resourceMap = new HashMap(); + private final Map/*<String, Resource>*/ resourceMap = new HashMap(); /** * Construct. @@ -265,7 +269,7 @@ public final void putClassAlias(Class clz, String alias) { classAliasMap.put(clz, alias); - aliasClassMap.put(alias, clz); + aliasClassMap.put(alias, new WeakReference(clz)); } /** @@ -277,7 +281,12 @@ */ public final Class getAliasClass(String alias) { - return (Class)aliasClassMap.get(alias); + Object classRef = aliasClassMap.get(alias); + if (classRef == null) + { + return null; + } + return (Class)((WeakReference)classRef).get(); } /**