Author: doogie
Date: Wed May 26 14:22:51 2010
New Revision: 948446
URL:
http://svn.apache.org/viewvc?rev=948446&view=revLog:
Remove synchronized on masterClassManagers, switching to
FastMap(non-blocking).
Modified:
ofbiz/trunk/framework/base/src/org/ofbiz/base/util/BshUtil.java
Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/BshUtil.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/BshUtil.java?rev=948446&r1=948445&r2=948446&view=diff==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/BshUtil.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/BshUtil.java Wed May 26 14:22:51 2010
@@ -27,6 +27,7 @@ import java.net.URL;
import java.util.HashMap;
import java.util.Map;
+import javolution.util.FastMap;
import org.ofbiz.base.location.FlexibleLocation;
import org.ofbiz.base.util.cache.UtilCache;
@@ -44,7 +45,7 @@ public final class BshUtil {
public static final String module = BshUtil.class.getName();
- protected static Map<ClassLoader, BshClassManager> masterClassManagers = new HashMap<ClassLoader, BshClassManager>();
+ protected static FastMap<ClassLoader, BshClassManager> masterClassManagers = FastMap.newInstance();
public static UtilCache<String, Interpreter.ParsedScript> parsedScripts = UtilCache.createUtilCache("script.BshLocationParsedCache", 0, 0, false);
/**
@@ -109,14 +110,10 @@ public final class BshUtil {
//find the "master" BshClassManager for this classpath
BshClassManager master = BshUtil.masterClassManagers.get(classLoader);
if (master == null) {
- synchronized (OfbizBshBsfEngine.class) {
- master = BshUtil.masterClassManagers.get(classLoader);
- if (master == null) {
- master = BshClassManager.createClassManager();
- master.setClassLoader(classLoader);
- BshUtil.masterClassManagers.put(classLoader, master);
- }
- }
+ master = BshClassManager.createClassManager();
+ master.setClassLoader(classLoader);
+ BshUtil.masterClassManagers.putIfAbsent(classLoader, master);
+ master = BshUtil.masterClassManagers.get(classLoader);
}
if (master != null) {