Author: bimargulies
Date: Wed Mar 12 15:58:34 2008
New Revision: 636566
URL: http://svn.apache.org/viewvc?rev=636566&view=rev
Log:
cache method->wrapper-Class relationships, for a not entirely trivial
speedup of repeated endpoint initialization.
Modified:
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceConfiguration.java
Modified:
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceConfiguration.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceConfiguration.java?rev=636566&r1=636565&r2=636566&view=diff
==============================================================================
---
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceConfiguration.java
(original)
+++
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceConfiguration.java
Wed Mar 12 15:58:34 2008
@@ -25,6 +25,8 @@
import java.lang.reflect.Method;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
+import java.util.HashMap;
+import java.util.Map;
import java.util.concurrent.Future;
import javax.jws.Oneway;
@@ -57,9 +59,20 @@
public class JaxWsServiceConfiguration extends AbstractServiceConfiguration {
private JaxWsImplementorInfo implInfo;
+ /**
+ * We retrieve the wrapper methods more than once
+ * while creating an endpoint. So caching the wrapper
+ * classes saves CPU time.
+ *
+ * It would also be good to cache across creations,
+ * but Method.equals isn't good enough.
+ */
+ private Map<Object, Class> responseMethodClassCache;
+ private Map<Object, Class> requestMethodClassCache;
public JaxWsServiceConfiguration() {
-
+ responseMethodClassCache = new HashMap<Object, Class>();
+ requestMethodClassCache = new HashMap<Object, Class>();
}
@Override
@@ -506,6 +519,11 @@
@Override
public Class getResponseWrapper(Method selected) {
+ Class cachedClass = responseMethodClassCache.get(selected);
+ if (cachedClass != null) {
+ return cachedClass;
+ }
+
Method m = getDeclaredMethod(selected);
ResponseWrapper rw = m.getAnnotation(ResponseWrapper.class);
@@ -518,8 +536,15 @@
}
if (clsName.length() > 0) {
+ cachedClass = responseMethodClassCache.get(clsName);
+ if (cachedClass != null) {
+ return cachedClass;
+ }
try {
- return ClassLoaderUtils.loadClass(clsName,
implInfo.getEndpointClass());
+ Class r = ClassLoaderUtils.loadClass(clsName,
implInfo.getEndpointClass());
+ responseMethodClassCache.put(clsName, r);
+ responseMethodClassCache.put(selected, r);
+ return r;
} catch (ClassNotFoundException e) {
//do nothing, we will mock a schema for wrapper bean later on
}
@@ -558,6 +583,11 @@
@Override
public Class getRequestWrapper(Method selected) {
+ Class cachedClass = requestMethodClassCache.get(selected);
+ if (cachedClass != null) {
+ return cachedClass;
+ }
+
Method m = getDeclaredMethod(selected);
RequestWrapper rw = m.getAnnotation(RequestWrapper.class);
@@ -569,8 +599,15 @@
}
if (clsName.length() > 0) {
+ cachedClass = requestMethodClassCache.get(clsName);
+ if (cachedClass != null) {
+ return cachedClass;
+ }
try {
- return ClassLoaderUtils.loadClass(clsName,
implInfo.getEndpointClass());
+ Class r = ClassLoaderUtils.loadClass(clsName,
implInfo.getEndpointClass());
+ requestMethodClassCache.put(clsName, r);
+ requestMethodClassCache.put(selected, r);
+ return r;
} catch (ClassNotFoundException e) {
//do nothing, we will mock a schema for wrapper bean later on
}