axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From barre...@apache.org
Subject svn commit: r688823 - in /webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl: DescriptionFactoryImpl.java ServiceDescriptionImpl.java
Date Mon, 25 Aug 2008 18:56:23 GMT
Author: barrettj
Date: Mon Aug 25 11:56:22 2008
New Revision: 688823

URL: http://svn.apache.org/viewvc?rev=688823&view=rev
Log:
Synchronize lookup and removal of ServiceDescription in cache.

Modified:
    webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/DescriptionFactoryImpl.java
    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/DescriptionFactoryImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/DescriptionFactoryImpl.java?rev=688823&r1=688822&r2=688823&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/DescriptionFactoryImpl.java
(original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/DescriptionFactoryImpl.java
Mon Aug 25 11:56:22 2008
@@ -482,28 +482,44 @@
     }
 
     /**
-     * Remove the ServiceDescription instance from the client-side cache.
+     * Remove the ServiceDescription instance from the client-side cache if there are no
+     * service delegates using it.  Note this must be done in a sync block so that a lookup

+     * in createServiceDescription doesn't access the cache.
      * 
      * @param svcDesc The instance to be removed.
      */
-    static void removeFromCache(ServiceDescription svcDesc) {
+    static boolean removeFromCache(ServiceDescriptionImpl svcDesc) {
+        boolean svcDescRemoved = false;
         ConfigurationContext configContext = svcDesc.getAxisConfigContext();
         synchronized(configContext) {
-            Set<Map.Entry<DescriptionKey, ServiceDescription>> cacheEntrySet
= 
-                cache.entrySet();
-            Iterator<Map.Entry<DescriptionKey, ServiceDescription>> cacheEntryIterator
=
-                cacheEntrySet.iterator();
-            while (cacheEntryIterator.hasNext()) {
-                Map.Entry<DescriptionKey, ServiceDescription> entry = 
-                    cacheEntryIterator.next();
-                ServiceDescription entrySvcDescValue = entry.getValue();
-                if (svcDesc == entrySvcDescValue) {
-                    cacheEntryIterator.remove();
-                    if (log.isDebugEnabled()) {
-                        log.debug("Removed service description from cache");
+            svcDesc.deregisterUse();
+            if (svcDesc.isInUse()) {
+                if (log.isDebugEnabled()) {
+                    log.debug("ServiceDescription still in use; not removed from cache");
+                }
+                svcDescRemoved = false;
+            } else {
+                if (log.isDebugEnabled()) {
+                    log.debug("ServiceDescription not in use; will be removed from cache");
+                }
+                svcDescRemoved = true;
+                Set<Map.Entry<DescriptionKey, ServiceDescription>> cacheEntrySet
= 
+                    cache.entrySet();
+                Iterator<Map.Entry<DescriptionKey, ServiceDescription>> cacheEntryIterator
=
+                    cacheEntrySet.iterator();
+                while (cacheEntryIterator.hasNext()) {
+                    Map.Entry<DescriptionKey, ServiceDescription> entry = 
+                        cacheEntryIterator.next();
+                    ServiceDescription entrySvcDescValue = entry.getValue();
+                    if (svcDesc == entrySvcDescValue) {
+                        cacheEntryIterator.remove();
+                        if (log.isDebugEnabled()) {
+                            log.debug("Removed service description from cache");
+                        }
                     }
                 }
             }
         }
+        return svcDescRemoved;
     }
 }

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=688823&r1=688822&r2=688823&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
Mon Aug 25 11:56:22 2008
@@ -2465,7 +2465,7 @@
      * only used on the client side.
      * @return
      */
-    private boolean isInUse() {
+    boolean isInUse() {
         return useCount > 0;
     }
     
@@ -2498,24 +2498,22 @@
     public void releaseResources(Object delegate) {
         try {
         if (log.isDebugEnabled()) {
-            log.debug("Entry ServiceDescription release resources with delegate " + delegate);
+            log.debug("ServiceDescription release resources called with delegate " + delegate);
         }
-        if (delegate != null) {
-            deregisterUse();
-        } else {
-            // If no ServiceDelegate specified, then return
-            return;
-        }
-        if (isInUse()) {
+        // If the service desc can be removed from the cache, which means no other service
delegates
+        // are using it, then we will release the resources associated with it.  If it can't
be 
+        // removed because it is still in use, then just return.
+        if (!DescriptionFactoryImpl.removeFromCache(this)) {
             if (log.isDebugEnabled()) {
-                log.debug("ServiceDescription still in use; not released");
+                log.debug("ServiceDesc was not removed from cache, so it will not be released");
             }
             return;
         }
         
-        // Remove the Service Description from the cache before we release the associated

-        // resouces.
-        DescriptionFactoryImpl.removeFromCache(this);
+        if (log.isDebugEnabled()) {
+            log.debug("ServiceDesc was removed from cache, so releasing associated resources");
+        }
+                
         
         // Close all the endpoint descs, both declared and dynamic
         Collection<EndpointDescription> definedEndpoints = definedEndpointDescriptions.values();




Mime
View raw message