abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r532398 - in /incubator/abdera/java/trunk: core/src/main/java/org/apache/abdera/factory/ExtensionFactoryMap.java parser/src/main/java/org/apache/abdera/parser/stax/FOMFactory.java
Date Wed, 25 Apr 2007 16:06:42 GMT
Author: jmsnell
Date: Wed Apr 25 09:06:40 2007
New Revision: 532398

URL: http://svn.apache.org/viewvc?view=rev&rev=532398
Log:
thread safety part 2. wrap the factories list using Collections.synchronizedList and do not
expose the list directly to anyone else.

Modified:
    incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/factory/ExtensionFactoryMap.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?view=diff&rev=532398&r1=532397&r2=532398
==============================================================================
--- 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
Wed Apr 25 09:06:40 2007
@@ -35,7 +35,7 @@
   private final Map<Element,Element> wrappers;
   
   public ExtensionFactoryMap(List<ExtensionFactory> factories) {
-    this.factories = factories;;
+    this.factories = Collections.synchronizedList(factories);
     this.wrappers = Collections.synchronizedMap(
       new WeakHashMap<Element,Element>());
   }
@@ -88,8 +88,9 @@
     Factory factory) {
       return null;
   }
-
-  public List<ExtensionFactory> getFactories() {
-    return factories;
+  
+  public void addFactory(ExtensionFactory factory) {
+    if (!factories.contains(factory))
+      factories.add(factory);
   }
 }

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?view=diff&rev=532398&r1=532397&r2=532398
==============================================================================
--- 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
Wed Apr 25 09:06:40 2007
@@ -424,21 +424,16 @@
       return (ATOM_NS.equals(ns) || APP_NS.equals(ns)) ?
         el : factoriesMap.getElementWrapper(el);
   }
-
-  private List<ExtensionFactory> getExtensionFactories() {
-    return factoriesMap.getFactories();
-  }
   
   @SuppressWarnings("unchecked")
-  public Element newExtensionElement(
+  private Element newExtensionElement(
     QName qname,
     OMContainer parent,
     OMXMLParserWrapper parserWrapper) {
     Element element = (parserWrapper == null) ?
       new FOMExtensibleElement(qname, parent, this) :
       new FOMExtensibleElement(qname, parent, this, parserWrapper);
-    //return factoriesMap.getElementWrapper(element);
-      return element;
+    return element;
   }
   
   public Control newControl() {
@@ -779,7 +774,7 @@
   }
 
   public void registerExtension(ExtensionFactory factory) {
-    getExtensionFactories().add(factory);
+    factoriesMap.addFactory(factory);
   }
 
   public Categories newCategories() {



Mime
View raw message