abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r592174 - in /incubator/abdera/java/trunk: core/src/main/java/org/apache/abdera/factory/ core/src/main/java/org/apache/abdera/model/ parser/src/main/java/org/apache/abdera/parser/stax/
Date Mon, 05 Nov 2007 22:55:58 GMT
Author: jmsnell
Date: Mon Nov  5 14:55:57 2007
New Revision: 592174

URL: http://svn.apache.org/viewvc?rev=592174&view=rev
Log:
Remove the element wrapper cache. It's no longer needed and was causing a memory leak anyway

Modified:
    incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/factory/ExtensionFactoryMap.java
    incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/factory/Factory.java
    incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/ElementWrapper.java
    incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMFactory.java

Modified: incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/factory/ExtensionFactoryMap.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/factory/ExtensionFactoryMap.java?rev=592174&r1=592173&r2=592174&view=diff
==============================================================================
--- incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/factory/ExtensionFactoryMap.java
(original)
+++ incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/factory/ExtensionFactoryMap.java
Mon Nov  5 14:55:57 2007
@@ -20,8 +20,6 @@
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
-import java.util.Map;
-import java.util.WeakHashMap;
 
 import org.apache.abdera.model.Base;
 import org.apache.abdera.model.Document;
@@ -32,41 +30,31 @@
  * It maintains the collection ExtensionFactory instances discovered on 
  * the classpath and a cache of Internal-Wrapper mappings.
  */
+@SuppressWarnings("unchecked") 
 public class ExtensionFactoryMap 
   implements ExtensionFactory {
 
   private final List<ExtensionFactory> factories;
-  private final Map<Element,Element> wrappers;
   
   public ExtensionFactoryMap(List<ExtensionFactory> factories) {
     this.factories = Collections.synchronizedList(factories);
-    this.wrappers = Collections.synchronizedMap(
-      new WeakHashMap<Element,Element>());
   }
 
   @SuppressWarnings("unchecked")
   public <T extends Element> T getElementWrapper(Element internal) {
     if (internal == null) return null;
-    T t = (T)wrappers.get(internal);
-    if (t == null) {
-      synchronized(factories) {
-        for (ExtensionFactory factory : factories) {
-          t = (T) factory.getElementWrapper(internal);
-          if (t != null && t != internal) {
-            setElementWrapper(internal,t);
-            return t;
-          }
+    T t = null;
+    synchronized(factories) {
+      for (ExtensionFactory factory : factories) {
+        t = (T) factory.getElementWrapper(internal);
+        if (t != null && t != internal) {
+          return t;
         }
       }
-      t = (T) internal;
     }
     return (t != null) ? t : (T)internal;
   }
   
-  public void setElementWrapper(Element internal, Element wrapper) {
-    wrappers.put(internal, wrapper);
-  }
-
   public String[] getNamespaces() {
     List<String> ns = new ArrayList<String>();
     synchronized(factories) {

Modified: incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/factory/Factory.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/factory/Factory.java?rev=592174&r1=592173&r2=592174&view=diff
==============================================================================
--- incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/factory/Factory.java
(original)
+++ incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/factory/Factory.java
Mon Nov  5 14:55:57 2007
@@ -637,11 +637,6 @@
   String newUuidUri();
   
   /**
-   * Set an element wrapper
-   */
-  void setElementWrapper(Element element, Element wrapper);
-  
-  /**
    * Get the Abdera instance for this factory
    */
   Abdera getAbdera();

Modified: incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/ElementWrapper.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/ElementWrapper.java?rev=592174&r1=592173&r2=592174&view=diff
==============================================================================
--- incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/ElementWrapper.java
(original)
+++ incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/ElementWrapper.java
Mon Nov  5 14:55:57 2007
@@ -50,7 +50,6 @@
     Element el = factory.newElement(qname);
     internal = (el instanceof ElementWrapper) ?
       ((ElementWrapper)el).getInternal() : el;
-    factory.setElementWrapper(internal, this);
   }
 
   public void addComment(

Modified: incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMFactory.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMFactory.java?rev=592174&r1=592173&r2=592174&view=diff
==============================================================================
--- incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMFactory.java
(original)
+++ incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMFactory.java
Mon Nov  5 14:55:57 2007
@@ -803,10 +803,10 @@
     return FOMHelper.generateUuid();
   }
 
-  public void setElementWrapper(Element internal, Element wrapper) {
-    factoriesMap.setElementWrapper(internal, wrapper);
-  }
-  
+//  public void setElementWrapper(Element internal, Element wrapper) {
+//    factoriesMap.setElementWrapper(internal, wrapper);
+//  }
+//  
   
   public <T extends Element> T getElementWrapper(Element internal) {
     if (internal == null) return null;



Mime
View raw message