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/11/14 07:45:53 UTC
cvs commit: ws-axis/java/src/org/apache/axis/utils JavaUtils.java
gawor 2004/11/13 22:45:53
Modified: java/src/org/apache/axis/utils JavaUtils.java
Log:
optimizations: caches the result of isEnumClass. This is called everytime a BeanSerializerFactory/BeanDeserializerFactory is created.
Revision Changes Path
1.113 +19 -3 ws-axis/java/src/org/apache/axis/utils/JavaUtils.java
Index: JavaUtils.java
===================================================================
RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/utils/JavaUtils.java,v
retrieving revision 1.112
retrieving revision 1.113
diff -u -r1.112 -r1.113
--- JavaUtils.java 22 Sep 2004 00:09:20 -0000 1.112
+++ JavaUtils.java 14 Nov 2004 06:45:53 -0000 1.113
@@ -949,7 +949,13 @@
public HolderException(String msg) { super(msg); }
}
-
+
+ /**
+ * Used to cache a result from IsEnumClassSub().
+ * Class->Boolean mapping.
+ */
+ private static HashMap enumMap = new HashMap();
+
/**
* Determine if the class is a JAX-RPC enum class.
* An enumeration class is recognized by
@@ -958,11 +964,21 @@
* of a setValue(type) method
*/
public static boolean isEnumClass(Class cls) {
+ Boolean b = (Boolean)enumMap.get(cls);
+ if (b == null) {
+ b = (isEnumClassSub(cls)) ? Boolean.TRUE : Boolean.FALSE;
+ enumMap.put(cls, b);
+ }
+ return b.booleanValue();
+ }
+
+ private static boolean isEnumClassSub(Class cls) {
try {
java.lang.reflect.Method[] methods = cls.getMethods();
- java.lang.reflect.Method getValueMethod = null, fromValueMethod = null,
+ java.lang.reflect.Method getValueMethod = null,
+ fromValueMethod = null,
setValueMethod = null, fromStringMethod = null;
-
+
// linear search: in practice, this is faster than
// sorting/searching a short array of methods.
for (int i = 0; i < methods.length; i++) {