Author: dkulp
Date: Fri Mar 14 10:46:48 2008
New Revision: 637178
URL: http://svn.apache.org/viewvc?rev=637178&view=rev
Log:
Merged revisions 636566 via svnmerge from
https://svn.apache.org/repos/asf/incubator/cxf/trunk
........
r636566 | bimargulies | 2008-03-12 18:58:34 -0400 (Wed, 12 Mar 2008) | 3 lines
cache method->wrapper-Class relationships, for a not entirely trivial
speedup of repeated endpoint initialization.
........
Modified:
incubator/cxf/branches/2.0.x-fixes/ (props changed)
incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceConfiguration.java
Propchange: incubator/cxf/branches/2.0.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.
Modified:
incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceConfiguration.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceConfiguration.java?rev=637178&r1=637177&r2=637178&view=diff
==============================================================================
---
incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceConfiguration.java
(original)
+++
incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceConfiguration.java
Fri Mar 14 10:46:48 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;
@@ -58,9 +60,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
@@ -500,6 +513,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);
@@ -512,8 +530,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
}
@@ -552,6 +577,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);
@@ -563,8 +593,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
}