You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by di...@apache.org on 2003/04/28 14:44:07 UTC
cvs commit: xml-axis/java/src/org/apache/axis/encoding/ser BaseDeserializerFactory.java
dims 2003/04/28 05:44:07
Modified: java/src/org/apache/axis/encoding/ser
BaseDeserializerFactory.java
Log:
Fix for Bug 19080 - Performance bottleneck in BaseDeserializerFactory.getDeserializerMethod()
Notes:
Added a per thread hashmap for caching methods. Avoiding static Hashmap to prevent possible problems (multiple webapps, classloaders, axisengines etc...)
Revision Changes Path
1.13 +27 -1 xml-axis/java/src/org/apache/axis/encoding/ser/BaseDeserializerFactory.java
Index: BaseDeserializerFactory.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/ser/BaseDeserializerFactory.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- BaseDeserializerFactory.java 22 Apr 2003 19:34:27 -0000 1.12
+++ BaseDeserializerFactory.java 28 Apr 2003 12:44:07 -0000 1.13
@@ -61,11 +61,13 @@
import java.lang.reflect.Method;
import java.util.Iterator;
import java.util.Vector;
-
+import java.util.Map;
+import java.util.HashMap;
import javax.xml.namespace.QName;
import javax.xml.rpc.JAXRPCException;
import org.apache.axis.Constants;
+import org.apache.axis.MessageContext;
import org.apache.axis.encoding.Deserializer;
import org.apache.axis.encoding.DeserializerFactory;
import org.apache.axis.utils.ClassUtils;
@@ -86,6 +88,7 @@
transient protected Constructor deserClassConstructor = null;
transient protected Method getDeserializer = null;
+ transient protected ThreadLocal methodCache = new ThreadLocal();
/**
* Constructor
@@ -185,10 +188,31 @@
}
/**
+ * Returns the per thread hashmap (for method caching)
+ */
+ private Map getMethodCache() {
+ Map map = (Map)methodCache.get();
+ if(map == null) {
+ map = new HashMap();
+ methodCache.set(map);
+ }
+ return map;
+ }
+
+ /**
* Returns the "getDeserializer" method if any.
*/
private Method getDeserializerMethod(Class clazz) {
+ String className = clazz.getName();
+ Map cache = getMethodCache();
Method method = null;
+
+ // Check the cache first.
+ if(cache.containsKey(className)) {
+ method = (Method) cache.get(clazz);
+ return method;
+ }
+
try {
method =
clazz.getMethod("getDeserializer",
@@ -208,6 +232,8 @@
} catch (NoSuchMethodException e) {
} catch (ClassNotFoundException e) {}
}
+
+ cache.put(className, method);
return method;
}