You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by jm...@apache.org on 2006/05/14 01:14:22 UTC

svn commit: r406162 - /incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/loader/impl/WSDLDefinitionRegistryImpl.java

Author: jmarino
Date: Sat May 13 16:14:21 2006
New Revision: 406162

URL: http://svn.apache.org/viewcvs?rev=406162&view=rev
Log:
revert changes to WSDLDefinitionRegistryImpl to fix 217 as they accidentally were applied to the previous commit for TUSCANY-367; the change for 217 may work but we need to verify first before applying, hence reverting

Modified:
    incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/loader/impl/WSDLDefinitionRegistryImpl.java

Modified: incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/loader/impl/WSDLDefinitionRegistryImpl.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/loader/impl/WSDLDefinitionRegistryImpl.java?rev=406162&r1=406161&r2=406162&view=diff
==============================================================================
--- incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/loader/impl/WSDLDefinitionRegistryImpl.java (original)
+++ incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/loader/impl/WSDLDefinitionRegistryImpl.java Sat May 13 16:14:21 2006
@@ -17,9 +17,9 @@
 package org.apache.tuscany.core.loader.impl;
 
 import java.io.IOException;
+import java.net.URL;
 import java.net.URI;
 import java.net.URISyntaxException;
-import java.net.URL;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -38,7 +38,6 @@
 import org.osoa.sca.annotations.Scope;
 
 /**
- * A WSDL definition registry with memory leaks. Keying off classloader as a temporary hack to avoid WSDL collisions in different classloaders 
  * @version $Rev$ $Date$
  */
 @org.osoa.sca.annotations.Service(interfaces = {WSDLDefinitionRegistry.class})
@@ -47,8 +46,8 @@
     private final WSDLFactory wsdlFactory;
     private final ExtensionRegistry registry;
 
-    private final Map<ClassLoader, Map<URL, Definition>> definitionsByLocation = new HashMap<ClassLoader, Map<URL, Definition>>();// new HashMap<URL, Definition>();
-    private final Map<ClassLoader, Map<String, List<Definition>>> definitionsByNamespace = new HashMap<ClassLoader, Map<String, List<Definition>>>(); //new HashMap<String, List<Definition>>();
+    private final Map<URL, Definition> definitionsByLocation = new HashMap<URL, Definition>();
+    private final Map<String, List<Definition>> definitionsByNamespace = new HashMap<String, List<Definition>>();
 
     private Monitor monitor;
 
@@ -91,17 +90,10 @@
     }
 
     public Definition loadDefinition(String namespace, URL location) throws IOException, WSDLException {
-        Map<URL, Definition> localCache = definitionsByLocation.get(Thread.currentThread().getContextClassLoader());
-        Definition definition;
-        if (localCache != null) {
-            definition = localCache.get(location);
-            if (definition != null) {
-                // return cached copy
-                return definition;
-            }
-        } else {
-            localCache = new HashMap<URL, Definition>();
-            definitionsByLocation.put(Thread.currentThread().getContextClassLoader(), localCache);
+        Definition definition = definitionsByLocation.get(location);
+        if (definition != null) {
+            // return cached copy
+            return definition;
         }
 
         monitor.readingWSDL(namespace, location);
@@ -116,16 +108,11 @@
         }
 
         monitor.cachingDefinition(definitionNamespace, location);
-        localCache.put(location, definition);
-        Map<String, List<Definition>> localNamespaceCache = definitionsByNamespace.get(Thread.currentThread().getContextClassLoader());
-        if (localNamespaceCache == null) {
-            localNamespaceCache = new HashMap<String, List<Definition>>();
-            definitionsByNamespace.put(Thread.currentThread().getContextClassLoader(), localNamespaceCache);
-        }
-        List<Definition> definitions = localNamespaceCache.get(definitionNamespace);
+        definitionsByLocation.put(location, definition);
+        List<Definition> definitions = definitionsByNamespace.get(definitionNamespace);
         if (definitions == null) {
             definitions = new ArrayList<Definition>();
-            localNamespaceCache.put(definitionNamespace, definitions);
+            definitionsByNamespace.put(definitionNamespace, definitions);
         }
         definitions.add(definition);
 
@@ -133,27 +120,20 @@
     }
 
     public List<Definition> getDefinitionsForNamespace(String namespace) {
-        Map<String, List<Definition>> localNamespaceCache = definitionsByNamespace.get(Thread.currentThread().getContextClassLoader());
-        if (localNamespaceCache != null) {
-            return localNamespaceCache.get(namespace);
-        }
-        return null;
+        return definitionsByNamespace.get(namespace);
     }
 
 
     public PortType getPortType(QName name) {
         String namespace = name.getNamespaceURI();
-        Map<String, List<Definition>> localNamespaceCache = definitionsByNamespace.get(Thread.currentThread().getContextClassLoader());
-        if (localNamespaceCache != null) {
-            List<Definition> definitions = localNamespaceCache.get(namespace);
-            if (definitions == null) {
-                return null;
-            }
-            for (Definition definition : definitions) {
-                PortType portType = definition.getPortType(name);
-                if (portType != null) {
-                    return portType;
-                }
+        List<Definition> definitions = definitionsByNamespace.get(namespace);
+        if (definitions == null) {
+            return null;
+        }
+        for (Definition definition : definitions) {
+            PortType portType = definition.getPortType(name);
+            if (portType != null) {
+                return portType;
             }
         }
         return null;
@@ -161,18 +141,14 @@
 
     public Service getService(QName name) {
         String namespace = name.getNamespaceURI();
-        Map<String, List<Definition>> localNamespaceCache = definitionsByNamespace.get(Thread.currentThread().getContextClassLoader());
-        if (localNamespaceCache != null) {
-            List<Definition> definitions = localNamespaceCache.get(namespace);
-            if (definitions == null) {
-                return null;
-            }
-
-            for (Definition definition : definitions) {
-                Service service = definition.getService(name);
-                if (service != null) {
-                    return service;
-                }
+        List<Definition> definitions = definitionsByNamespace.get(namespace);
+        if (definitions == null) {
+            return null;
+        }
+        for (Definition definition : definitions) {
+            Service service = definition.getService(name);
+            if (service != null) {
+                return service;
             }
         }
         return null;
@@ -180,19 +156,20 @@
 
     public static interface Monitor {
         /**
-         * Monitor event emitted immediately before an attempt is made to read WSDL for the supplied namespace
-         * from the supplied location.
+         * Monitor event emitted immediately before an attempt is made to
+         * read WSDL for the supplied namespace from the supplied location.
          *
          * @param namespace the target namespace expected in the WSDL; may be null
-         * @param location  the location where we will attempt to read the WSDL definition from
+         * @param location the location where we will attempt to read the WSDL definition from
          */
         void readingWSDL(String namespace, URL location);
 
         /**
-         * Monitor event emitted immediately before registering a WSDL definition in the cache.
+         * Monitor event emitted immediately before registering a WSDL definition
+         * in the cache.
          *
          * @param namespace the target namespace for the WSDL
-         * @param location  the location where the WSDL definition was read from
+         * @param location the location where the WSDL definition was read from
          */
         void cachingDefinition(String namespace, URL location);
     }