comparison artifacts/src/main/java/org/dive4elements/river/artifacts/context/FLYSContext.java @ 5838:5aa05a7a34b7

Rename modules to more fitting names.
author Sascha L. Teichmann <teichmann@intevation.de>
date Thu, 25 Apr 2013 15:23:37 +0200
parents flys-artifacts/src/main/java/org/dive4elements/river/artifacts/context/FLYSContext.java@bd047b71ab37
children 4897a58c8746
comparison
equal deleted inserted replaced
5837:d9901a08d0a6 5838:5aa05a7a34b7
1 package org.dive4elements.river.artifacts.context;
2
3 import java.util.Map;
4
5 import org.apache.log4j.Logger;
6
7 import org.w3c.dom.Document;
8
9 import org.dive4elements.artifactdatabase.DefaultArtifactContext;
10 import org.dive4elements.artifacts.CallContext;
11 import org.dive4elements.river.exports.OutGenerator;
12
13
14 /**
15 * This class is used to store application wide information in a global context.
16 *
17 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
18 */
19 public class FLYSContext extends DefaultArtifactContext {
20
21 /** The logger used in this class. */
22 private static Logger logger = Logger.getLogger(FLYSContext.class);
23
24 /** The key that is used to store the StateEngine in the context. */
25 public static final String ARTIFACT_KEY =
26 "artifact";
27
28 /** The key that is used to store the TransitionEngine in the context. */
29 public static final String TRANSITION_ENGINE_KEY =
30 "artifact.transition.engine";
31
32 /** The key that is used to store the StateEngine in the context. */
33 public static final String STATE_ENGINE_KEY =
34 "artifact.state.engine";
35
36 /** The key that is used to store the Map of OutGenerator classes in the
37 * context. */
38 public static final String OUTGENERATORS_KEY =
39 "flys.export.outgenerators";
40
41 /** The key that is used to store the map of themes in the context. */
42 public static final String THEMES =
43 "flys.themes.map";
44
45 /** The key that is used to store a map of theme mappings in the context. */
46 public static final String THEME_MAPPING =
47 "flys.themes.mapping.map";
48
49 /** The key that is used to store a map of WMS urls for each river. */
50 public static final String RIVER_WMS =
51 "flys.floodmap.river.wms";
52
53 /** The key that is used to store an instance of Scheduler in the context.*/
54 public static final String SCHEDULER =
55 "flys.wsplgen.scheduler";
56
57 /** Key to store the configured modules in the context. */
58 public static final String MODULES = "flys.modules";
59
60
61 /**
62 * The default constructor.
63 */
64 public FLYSContext() {
65 super();
66 }
67
68
69 /**
70 * A constructor with a config document.
71 */
72 public FLYSContext(Document config) {
73 super(config);
74 }
75
76 /**
77 * Returns the OutGenerator for a specified <i>type</i>.
78 *
79 * @param name The name of the output type.
80 * @param type Defines the type of the desired OutGenerator.
81 *
82 * @return Instance of an OutGenerator for specified <i>type</i>.
83 */
84 public static OutGenerator getOutGenerator(
85 CallContext context,
86 String name,
87 String type)
88 {
89
90 FLYSContext flysContext = context instanceof FLYSContext
91 ? (FLYSContext) context
92 : (FLYSContext) context.globalContext();
93
94 Map<String, Class> generators = (Map<String, Class>)
95 flysContext.get(FLYSContext.OUTGENERATORS_KEY);
96
97 if (generators == null) {
98 return null;
99 }
100
101 Class clazz = generators.get(name);
102
103 try {
104 return clazz != null ? (OutGenerator) clazz.newInstance() : null;
105 }
106 catch (InstantiationException ie) {
107 logger.error(ie, ie);
108 }
109 catch (IllegalAccessException iae) {
110 logger.error(iae, iae);
111 }
112
113 return null;
114 }
115 }
116 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org