1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.kew.plugin; |
17 | |
|
18 | |
import org.kuali.rice.core.api.config.property.Config; |
19 | |
import org.kuali.rice.core.impl.config.property.ConfigParserImplConfig; |
20 | |
|
21 | |
import java.io.File; |
22 | |
import java.net.MalformedURLException; |
23 | |
import java.net.URL; |
24 | |
import java.util.ArrayList; |
25 | |
import java.util.HashMap; |
26 | |
import java.util.List; |
27 | |
import java.util.Map; |
28 | |
import java.util.Properties; |
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
public class PluginConfig extends ConfigParserImplConfig { |
39 | |
|
40 | |
private String resourceLoaderClassname; |
41 | 0 | private List listeners = new ArrayList(); |
42 | |
private Properties parentProperties; |
43 | |
private Map parentObjects; |
44 | |
private Config parentConfig; |
45 | |
|
46 | |
public PluginConfig(URL url, Config parentConfig) { |
47 | 0 | super(url.toString()); |
48 | 0 | this.parentProperties = parentConfig.getProperties(); |
49 | 0 | this.parentObjects = parentConfig.getObjects(); |
50 | 0 | this.parentConfig = parentConfig; |
51 | 0 | } |
52 | |
|
53 | |
public PluginConfig(File configFile, Config parentConfig) throws MalformedURLException { |
54 | 0 | this(configFile.toURI().toURL(), parentConfig); |
55 | 0 | } |
56 | |
|
57 | |
public Properties getBaseProperties() { |
58 | 0 | return this.parentProperties; |
59 | |
} |
60 | |
|
61 | |
public Map getBaseObjects() { |
62 | 0 | return this.parentObjects; |
63 | |
} |
64 | |
|
65 | |
public void addListener(String listenerClass) { |
66 | 0 | listeners.add(listenerClass); |
67 | 0 | } |
68 | |
|
69 | |
public List getListeners() { |
70 | 0 | return listeners; |
71 | |
} |
72 | |
|
73 | |
public void setResourceLoaderClassname(String resourceLoaderClassname) { |
74 | 0 | this.resourceLoaderClassname = resourceLoaderClassname; |
75 | 0 | } |
76 | |
|
77 | |
public String getResourceLoaderClassname() { |
78 | 0 | return resourceLoaderClassname; |
79 | |
} |
80 | |
|
81 | |
public String toString() { |
82 | 0 | return "[PluginConfig: resourceLoaderClassname: " + getResourceLoaderClassname() + "]"; |
83 | |
} |
84 | |
|
85 | |
|
86 | |
@Override |
87 | |
public Object getObject(String key) { |
88 | 0 | Object object = super.getObject(key); |
89 | 0 | if (object == null && parentConfig != null) { |
90 | 0 | object = parentConfig.getObject(key); |
91 | |
} |
92 | 0 | return object; |
93 | |
} |
94 | |
|
95 | |
@Override |
96 | |
public Map<String, Object> getObjects() { |
97 | 0 | Map<String, Object> finalObjects = new HashMap<String, Object>(super.getObjects()); |
98 | 0 | if (parentConfig != null) { |
99 | 0 | Map<String, Object> parentObjects = parentConfig.getObjects(); |
100 | 0 | for (String key : parentObjects.keySet()) { |
101 | 0 | if (!finalObjects.containsKey(key)) { |
102 | 0 | finalObjects.put(key, parentObjects.get(key)); |
103 | |
} |
104 | |
} |
105 | |
} |
106 | |
|
107 | 0 | return finalObjects; |
108 | |
} |
109 | |
} |