1 package org.apache.turbine.modules.actions;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.util.Hashtable;
23 import java.util.Iterator;
24 import java.util.Properties;
25 import javax.naming.InitialContext;
26 import javax.naming.NamingException;
27
28 import org.apache.commons.configuration.Configuration;
29
30 import org.apache.turbine.Turbine;
31 import org.apache.turbine.modules.Action;
32 import org.apache.turbine.pipeline.PipelineData;
33 import org.apache.turbine.util.RunData;
34
35
36
37
38
39
40
41
42
43 public class InitContextsAction
44 extends Action
45 {
46
47
48
49
50
51
52
53
54
55 @SuppressWarnings("unchecked")
56 @Deprecated
57 @Override
58 public void doPerform(RunData data)
59 throws NamingException
60 {
61 Configuration conf = Turbine.getConfiguration();
62
63
64
65
66
67
68
69
70 Hashtable<String, Properties> contextPropsList = new Hashtable<String, Properties>();
71 for (Iterator<String> contextKeys = conf.getKeys("context.");
72 contextKeys.hasNext();)
73 {
74 String key = contextKeys.next();
75 int start = key.indexOf(".") + 1;
76 int end = key.indexOf(".", start);
77 String contextName = key.substring(start, end);
78 Properties contextProps = null;
79 if (contextPropsList.containsKey(contextName))
80 {
81 contextProps = contextPropsList.get(contextName);
82 }
83 else
84 {
85 contextProps = new Properties();
86 }
87 contextProps.put(key.substring(end + 1),
88 conf.getString(key));
89 contextPropsList.put(contextName, contextProps);
90 }
91 for (Iterator<String> contextPropsKeys = contextPropsList.keySet().iterator();
92 contextPropsKeys.hasNext();)
93 {
94 String key = contextPropsKeys.next();
95 Properties contextProps = contextPropsList.get(key);
96 InitialContext context = new InitialContext(contextProps);
97 data.getJNDIContexts().put(key, context);
98 }
99 }
100
101
102
103
104
105
106
107
108
109 @Override
110 public void doPerform(PipelineData pipelineData)
111 throws NamingException
112 {
113 RunData data = getRunData(pipelineData);
114 doPerform(data);
115 }
116
117
118 }