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 sc...@apache.org on 2008/05/21 23:59:11 UTC
svn commit: r658891 -
/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImpl.java
Author: scheu
Date: Wed May 21 14:59:11 2008
New Revision: 658891
URL: http://svn.apache.org/viewvc?rev=658891&view=rev
Log:
Quick Change to use a ConcurrentHashMap to avoid contention. Since this is a cache, a SoftReference holds the map
Contributor: David Strite and Rich Scheuerle
Modified:
webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImpl.java
Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImpl.java?rev=658891&r1=658890&r2=658891&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImpl.java (original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImpl.java Wed May 21 14:59:11 2008
@@ -66,6 +66,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.lang.annotation.Annotation;
+import java.lang.ref.SoftReference;
import java.net.ConnectException;
import java.net.URL;
import java.net.UnknownHostException;
@@ -107,8 +108,9 @@
new WeakHashMap<Object, Map<QName, EndpointDescriptionImpl>>();
// Cache classes for the info for resolved handlers
- Map<PortInfo, ResolvedHandlersDescription> resolvedHandlersDescription =
- new WeakHashMap<PortInfo, ResolvedHandlersDescription>();
+ private SoftReference<Map<PortInfo, ResolvedHandlersDescription>> resolvedHandlersDescription =
+ new SoftReference<Map<PortInfo, ResolvedHandlersDescription>>
+ (new ConcurrentHashMap<PortInfo, ResolvedHandlersDescription>());
private static final Log log = LogFactory.getLog(ServiceDescriptionImpl.class);
@@ -2211,12 +2213,27 @@
}
public void setResolvedHandlersDescription(PortInfo portInfo, ResolvedHandlersDescription resolvedHandlersInfo) {
- resolvedHandlersDescription.put(portInfo, resolvedHandlersInfo);
+ // Get the cache and store the handler description
+ Map<PortInfo, ResolvedHandlersDescription> cache = resolvedHandlersDescription.get();
+
+ if (cache == null) {
+ cache = new ConcurrentHashMap<PortInfo, ResolvedHandlersDescription>();
+ resolvedHandlersDescription =
+ new SoftReference<Map<PortInfo, ResolvedHandlersDescription>>(cache);
+
+ }
+ cache.put(portInfo, resolvedHandlersInfo);
}
+
public ResolvedHandlersDescription getResolvedHandlersDescription(PortInfo portInfo) {
- return resolvedHandlersDescription.get(portInfo);
+ Map<PortInfo, ResolvedHandlersDescription> cache = resolvedHandlersDescription.get();
+
+ return (cache == null) ?
+ null: // No Cache
+ cache.get(portInfo);
+
}
private String resolveWSDLLocationByCatalog(String wsdlLocation) {