# HG changeset patch # User Sascha L. Teichmann # Date 1410345759 -7200 # Node ID c87c87544cc64ed92fc8aa0ac800a193897ceff5 # Parent b6d54b946f4c7504abd1cbb89784fcf61a189152 Made call context injectors a list of comma separated classes. diff -r b6d54b946f4c -r c87c87544cc6 artifacts/doc/conf/generators/discharge-diagrams2.xml --- a/artifacts/doc/conf/generators/discharge-diagrams2.xml Wed Sep 10 10:02:46 2014 +0200 +++ b/artifacts/doc/conf/generators/discharge-diagrams2.xml Wed Sep 10 12:42:39 2014 +0200 @@ -4,7 +4,7 @@ + injectors="org.dive4elements.river.exports.injector.HistoricalDischargeInjector"> &discharge-defaults; </output-generator> @@ -12,7 +12,7 @@ <output-generator names="computed_discharge_curve_chartinfo,computed_discharge_curve" class="org.dive4elements.river.exports.DischargeGenerator" converter="org.dive4elements.river.exports.DiagramAttributes" - injector="org.dive4elements.river.exports.injector.ComputedDischargeInjector"> + injectors="org.dive4elements.river.exports.injector.ComputedDischargeInjector"> <title key="chart.computed.discharge.curve.title" default="chart.computed.discharge.curve.title"/> <subtitle key="chart.computed.discharge.curve.subtitle" default="-"> <arg expr="artifact.river"/> @@ -24,7 +24,7 @@ <output-generator names="discharge_curve_chartinfo,discharge_curve" class="org.dive4elements.river.exports.DischargeGenerator" converter="org.dive4elements.river.exports.DiagramAttributes" - injector="org.dive4elements.river.exports.injector.DischargeInjector"> + injectors="org.dive4elements.river.exports.injector.DischargeInjector"> <title key="chart.discharge.curve.title" default="chart.discharge.curve.title"/> <subtitle key="chart.computed.discharge.curve.subtitle" default="-"> <arg expr="artifact.river"/> @@ -36,7 +36,7 @@ <output-generator names="fix_wq_curve,fix_wq_curve_chartinfo" class="org.dive4elements.river.exports.DischargeGenerator" converter="org.dive4elements.river.exports.DiagramAttributes" - injector="org.dive4elements.river.exports.injector.FixWQInjector"> + injectors="org.dive4elements.river.exports.injector.FixWQInjector"> <title key="chart.fixings.discharge.curve.title" default="Fixierungsanalyse W/Q"/> <subtitle key="chart.computed.discharge.curve.subtitle" default="-"> <arg expr="artifact.river"/> diff -r b6d54b946f4c -r c87c87544cc6 artifacts/src/main/java/org/dive4elements/river/artifacts/context/RiverContextFactory.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/context/RiverContextFactory.java Wed Sep 10 10:02:46 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/context/RiverContextFactory.java Wed Sep 10 12:42:39 2014 +0200 @@ -352,10 +352,10 @@ for (int i = 0; i < num; i++) { Element item = (Element)outGenerators.item(i); - String names = item.getAttribute("names").trim(); - String clazz = item.getAttribute("class").trim(); - String converter = item.getAttribute("converter").trim(); - String injector = item.getAttribute("injector").trim(); + String names = item.getAttribute("names").trim(); + String clazz = item.getAttribute("class").trim(); + String converter = item.getAttribute("converter").trim(); + String injectors = item.getAttribute("injectors").trim(); if (names.isEmpty() || clazz.isEmpty()) { continue; @@ -391,28 +391,32 @@ } } - ContextInjector ci = null; + List<ContextInjector> cis = null; - if (!injector.isEmpty()) { - try { - ci = (ContextInjector)Class.forName(injector) - .newInstance(); - ci.setup(item); - } - catch (ClassNotFoundException cnfe) { - log.error(cnfe, cnfe); - } - catch (InstantiationException ie) { - log.error(ie); - } - catch (IllegalAccessException iae) { - log.error(iae); + if (!injectors.isEmpty()) { + cis = new ArrayList<ContextInjector>(); + for (String injector: injectors.split("[\\s,]+")) { + try { + ContextInjector ci = (ContextInjector)Class.forName(injector) + .newInstance(); + ci.setup(item); + cis.add(ci); + } + catch (ClassNotFoundException cnfe) { + log.error(cnfe, cnfe); + } + catch (InstantiationException ie) { + log.error(ie); + } + catch (IllegalAccessException iae) { + log.error(iae); + } } } - for (String key: names.split("[\\s,]")) { + for (String key: names.split("[\\s,]+")) { if (!(key = key.trim()).isEmpty()) { - generators.putGenerator(key, generatorClass, cfg, ci); + generators.putGenerator(key, generatorClass, cfg, cis); idx++; } } diff -r b6d54b946f4c -r c87c87544cc6 artifacts/src/main/java/org/dive4elements/river/exports/GeneratorLookup.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/GeneratorLookup.java Wed Sep 10 10:02:46 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/GeneratorLookup.java Wed Sep 10 12:42:39 2014 +0200 @@ -9,6 +9,7 @@ package org.dive4elements.river.exports; import java.util.HashMap; +import java.util.List; import java.util.Map; import org.dive4elements.artifacts.ContextInjector; @@ -19,14 +20,14 @@ implements FacetFilter { public static final class Item { - private Class<OutGenerator> generator; - private Object ctx; - private ContextInjector ci; + private Class<OutGenerator> generator; + private Object ctx; + private List<ContextInjector> cis; - public Item(Class<OutGenerator> generator, Object ctx, ContextInjector ci) { + public Item(Class<OutGenerator> generator, Object ctx, List<ContextInjector> cis) { this.generator = generator; this.ctx = ctx; - this.ci = ci; + this.cis = cis; } public Class<OutGenerator> getGenerator() { @@ -37,8 +38,8 @@ return ctx; } - public ContextInjector getContextInjector() { - return ci; + public List<ContextInjector> getContextInjectors() { + return cis; } } // class Item @@ -49,12 +50,12 @@ } public void putGenerator( - String outName, - Class<OutGenerator> generatorClass, - Object ctx, - ContextInjector ci + String outName, + Class<OutGenerator> generatorClass, + Object ctx, + List<ContextInjector> cis ) { - Item item = new Item(generatorClass, ctx, ci); + Item item = new Item(generatorClass, ctx, cis); generators.put(outName, item); } diff -r b6d54b946f4c -r c87c87544cc6 artifacts/src/main/java/org/dive4elements/river/exports/OutputHelper.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/OutputHelper.java Wed Sep 10 10:02:46 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/OutputHelper.java Wed Sep 10 12:42:39 2014 +0200 @@ -55,7 +55,7 @@ this.identifier = identifier; } - private static ContextInjector getContextInjector(CallContext context, String out) { + private static List<ContextInjector> getContextInjectors(CallContext context, String out) { RiverContext flysContext = context instanceof RiverContext ? (RiverContext)context : (RiverContext)context.globalContext(); @@ -69,7 +69,7 @@ GeneratorLookup.Item item = generators.getGenerator(out); return item != null - ? item.getContextInjector() + ? item.getContextInjectors() : null; } /** @@ -102,7 +102,7 @@ List<ArtifactAndFacet> dataProviders = doBlackboardPass(themeList, context, outName); - ContextInjector ci = getContextInjector(context, outName); + List<ContextInjector> cis = getContextInjectors(context, outName); try { for (int i = 0, T = themeList.size(); i < T; i++) { @@ -131,8 +131,11 @@ continue; } - if (ci != null) { - ci.injectContext(context, dataProviders.get(i).getArtifact(), request); + if (cis != null) { + for (ContextInjector ci: cis) { + ci.injectContext( + context, dataProviders.get(i).getArtifact(), request); + } } if (outName.equals("sq_overview")) {