You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@abdera.apache.org by jm...@apache.org on 2008/05/12 17:36:37 UTC
svn commit: r655532 - in
/incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util:
AbderaConfiguration.java Configuration.java
Author: jmsnell
Date: Mon May 12 08:36:37 2008
New Revision: 655532
URL: http://svn.apache.org/viewvc?rev=655532&view=rev
Log:
https://issues.apache.org/jira/browse/ABDERA-156
>From David Calavera: "AbderaConfiguration allows to add extensions at runtime" ... AbderaConfiguration should allow to add NamedParsers, NamedWriters, ExtensionFactories or StreamWriters at runtime, I think the Configuration interface has to include these "add" methods.
Modified:
incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/AbderaConfiguration.java
incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/Configuration.java
Modified: incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/AbderaConfiguration.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/AbderaConfiguration.java?rev=655532&r1=655531&r2=655532&view=diff
==============================================================================
--- incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/AbderaConfiguration.java (original)
+++ incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/AbderaConfiguration.java Mon May 12 08:36:37 2008
@@ -39,6 +39,8 @@
import org.apache.abdera.writer.Writer;
import org.apache.abdera.writer.WriterFactory;
import org.apache.abdera.xpath.XPath;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
/**
* Provides the basic configuration for the Abdera default implementation. This
@@ -48,6 +50,7 @@
implements Constants, Configuration {
private static final long serialVersionUID = 7460203853824337559L;
+ private final static Log log = LogFactory.getLog(AbderaConfiguration.class);
/**
* Returns the default configuration. Every call to this method returns
@@ -138,8 +141,11 @@
*/
public AbderaConfiguration addExtensionFactory(ExtensionFactory factory) {
List<ExtensionFactory> factories = getExtensionFactories();
- if (!factories.contains(factory))
+ if (!factories.contains(factory)) {
factories.add(factory);
+ } else {
+ log.warn("These extensions are already registered: " + factory.getNamespaces());
+ }
return this;
}
@@ -155,7 +161,11 @@
*/
public AbderaConfiguration addNamedWriter(NamedWriter writer) {
Map<String,NamedWriter> writers = getNamedWriters();
- writers.put(writer.getName(), writer);
+ if (!writers.containsKey(writer.getName())) {
+ writers.put(writer.getName(), writer);
+ } else {
+ log.warn("The NamedWriter is already registered: " + writer.getName());
+ }
return this;
}
@@ -222,7 +232,11 @@
*/
public AbderaConfiguration addNamedParser(NamedParser parser) {
Map<String,NamedParser> parsers = getNamedParsers();
- parsers.put(parser.getName(), parser);
+ if (!parsers.containsKey(parser.getName())) {
+ parsers.put(parser.getName(), parser);
+ } else {
+ log.warn("The NamedParser is already registered: " + parser.getName());
+ }
return this;
}
@@ -230,7 +244,13 @@
* Registers a StreamWriter implementation
*/
public AbderaConfiguration addStreamWriter(Class<? extends StreamWriter> sw) {
- getStreamWriters().put(getName(sw), sw);
+ Map<String,Class<? extends StreamWriter>> streamWriters = getStreamWriters();
+ String swName = getName(sw);
+ if (!streamWriters.containsKey(swName)) {
+ streamWriters.put(swName, sw);
+ } else {
+ log.warn("The StreamWriter is already registered: " + swName);
+ }
return this;
}
Modified: incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/Configuration.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/Configuration.java?rev=655532&r1=655531&r2=655532&view=diff
==============================================================================
--- incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/Configuration.java (original)
+++ incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/Configuration.java Mon May 12 08:36:37 2008
@@ -106,4 +106,32 @@
public abstract Object clone();
+
+ /**
+ * Registers a new NamedParser, this method doesn't override a parser if already exists.
+ * @param parser is the new NamedParser to add
+ * @return the instance of the configuration class
+ */
+ public Configuration addNamedParser(NamedParser parser);
+
+ /**
+ * Registers a new NamedWriter, this method doesn't override a writer if already exists.
+ * @param writer is the new NamedWriter to add
+ * @return the instance of the configuration class
+ */
+ public Configuration addNamedWriter(NamedWriter writer);
+
+ /**
+ * Registers a new ExtensionFactory, this method doesn't override an extensionFactory if already exists.
+ * @param factory is the new ExtensionFactory to add
+ * @return the instance of the configuration class
+ */
+ public Configuration addExtensionFactory(ExtensionFactory factory);
+
+ /**
+ * Registers a new StreamWriter, this method doesn't override a streamWriter if already exists.
+ * @param sw is the new StreamWriter to add
+ * @return the instance of the configuration class
+ */
+ public Configuration addStreamWriter(Class<? extends StreamWriter> sw);
}
\ No newline at end of file