abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r421675 - in /incubator/abdera/java/trunk: core/src/main/java/org/apache/abdera/factory/Factory.java parser/src/main/java/org/apache/abdera/parser/stax/FOMFactory.java
Date Thu, 13 Jul 2006 18:12:08 GMT
Author: jmsnell
Date: Thu Jul 13 11:12:08 2006
New Revision: 421675

URL: http://svn.apache.org/viewvc?rev=421675&view=rev
Log:
Make it possible to register extension factories dynamically

Modified:
    incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/factory/Factory.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/Factory.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/factory/Factory.java?rev=421675&r1=421674&r2=421675&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
Thu Jul 13 11:12:08 2006
@@ -211,8 +211,20 @@
   
   Div newDiv(Base parent);
 
+  /**
+   * Registers an extension implementation class for this Factory instance only
+   */
   <T extends Base>void registerExtension(QName qname, Class impl);
   
+  /**
+   * Registers an extension factory for this Factory instance only
+   */
+  void registerExtension(ExtensionFactory extensionFactory);
+  
+  /**
+   * Registers an alternative implementation class for the specified base
+   * for this Factory instance.  The alternative MUST extend the base
+   */
   <T extends Base>void registerAlternative(Class<T> base, Class<? extends
T> alternative);
   
 }

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=421675&r1=421674&r2=421675&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
Thu Jul 13 11:12:08 2006
@@ -17,6 +17,7 @@
 */
 package org.apache.abdera.parser.stax;
  
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -94,6 +95,7 @@
   
   private Map<Class,Class> alternatives = null;
   private Map<QName,Class> extensions = null;
+  private List<ExtensionFactory> factories = null;
   
   public Parser newParser() {
     return new FOMParser();
@@ -440,14 +442,21 @@
       return newExtensionElement(qname, parent, null);
   }
 
+  private List<ExtensionFactory> getExtensionFactories() {
+    if (factories == null) {
+      factories = new ArrayList<ExtensionFactory>(
+        org.apache.abdera.util.ServiceUtil.loadExtensionFactories());
+    }
+    return factories;
+  }
+  
   @SuppressWarnings("unchecked")
   public Element newExtensionElement(
     QName qname,
     OMContainer parent,
     OMXMLParserWrapper parserWrapper) {
     Element element = null;
-    List<ExtensionFactory> factories = 
-      org.apache.abdera.util.ServiceUtil.loadExtensionFactories();
+    List<ExtensionFactory> factories = getExtensionFactories();
     Class _class = getExtensionClass(qname);
     if (_class == null && factories != null) {
       for (ExtensionFactory factory : factories) {
@@ -742,6 +751,10 @@
   public void registerExtension(QName qname, Class impl) {
     if (extensions == null) extensions = new HashMap<QName,Class>();
     extensions.put(qname, impl);
+  }
+  
+  public void registerExtension(ExtensionFactory factory) {
+    getExtensionFactories().add(factory);
   }
   
   @SuppressWarnings("unchecked")



Mime
View raw message