diff artifacts/src/main/java/org/dive4elements/river/artifacts/context/RiverContextFactory.java @ 7037:5c6fd2c010dd generator-refactoring

Add setup(Element config) method to Generator interface to be initialized from configuration.
author Sascha L. Teichmann <teichmann@intevation.de>
date Wed, 18 Sep 2013 15:04:26 +0200
parents 468d9ebda4ce
children 4e597d435398
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/context/RiverContextFactory.java	Wed Sep 18 10:12:47 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/context/RiverContextFactory.java	Wed Sep 18 15:04:26 2013 +0200
@@ -24,6 +24,8 @@
 import org.dive4elements.river.themes.ThemeFactory;
 import org.dive4elements.river.themes.ThemeGroup;
 import org.dive4elements.river.themes.ThemeMapping;
+import org.dive4elements.river.utils.Pair;
+import org.dive4elements.river.exports.OutGenerator;
 
 import java.io.File;
 import java.util.ArrayList;
@@ -307,7 +309,6 @@
      * @param context the RiverContext.
      */
     protected void configureOutGenerators(Document config, RiverContext context){
-        Map<String, Class<?>> generators = new HashMap<String, Class<?>>();
 
         NodeList outGenerators = (NodeList) XMLUtils.xpath(
             config,
@@ -323,10 +324,13 @@
 
         logger.info("Found " + num + " configured output generators.");
 
+        Map<String, Pair<Class<OutGenerator>, Element>> generators =
+            new HashMap<String, Pair<Class<OutGenerator>, Element>>();
+
         int idx = 0;
 
         for (int i = 0; i < num; i++) {
-            Node item = outGenerators.item(i);
+            Element item = (Element)outGenerators.item(i);
 
             String name = (String) XMLUtils.xpath(
                 item, "@name", XPathConstants.STRING);
@@ -339,7 +343,10 @@
             }
 
             try {
-                generators.put(name, Class.forName(clazz));
+                generators.put(
+                    name,
+                    new Pair<Class<OutGenerator>, Element>(
+                        (Class<OutGenerator>)Class.forName(clazz), item));
 
                 idx++;
             }

http://dive4elements.wald.intevation.org