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 ga...@apache.org on 2004/12/02 00:14:10 UTC
cvs commit: ws-axis/java/src/org/apache/axis/description TypeDesc.java
gawor 2004/12/01 15:14:09
Modified: java/src/org/apache/axis/description TypeDesc.java
Log:
cache the result of previous getTypeDescForClass() lookup, reduced the number of reflection calls
Revision Changes Path
1.42 +17 -11 ws-axis/java/src/org/apache/axis/description/TypeDesc.java
Index: TypeDesc.java
===================================================================
RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/description/TypeDesc.java,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -r1.41 -r1.42
--- TypeDesc.java 21 Nov 2004 20:00:19 -0000 1.41
+++ TypeDesc.java 1 Dec 2004 23:14:09 -0000 1.42
@@ -99,24 +99,30 @@
* Eventually we may extend this to provide for external
* metadata config (via files sitting in the classpath, etc).
*
- * (Could introduce a cache here for speed as an optimization)
*/
public static TypeDesc getTypeDescForClass(Class cls)
{
// First see if we have one explicitly registered
+ // or cached from previous lookup
TypeDesc result = (TypeDesc)classMap.get(cls);
- if (result != null) {
- return result;
- }
-
- try {
- Method getTypeDesc = MethodCache.getInstance().getMethod(cls, "getTypeDesc", noClasses);
- if (getTypeDesc != null) {
- return (TypeDesc)getTypeDesc.invoke(null, noObjects);
+
+ if (result == null) {
+ try {
+ Method getTypeDesc =
+ MethodCache.getInstance().getMethod(cls,
+ "getTypeDesc",
+ noClasses);
+ if (getTypeDesc != null) {
+ result = (TypeDesc)getTypeDesc.invoke(null, noObjects);
+ if (result != null) {
+ classMap.put(cls, result);
+ }
+ }
+ } catch (Exception e) {
}
- } catch (Exception e) {
}
- return null;
+
+ return result;
}
/** The Java class for this type */