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 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 super(url.toString());
48 this.parentProperties = parentConfig.getProperties();
49 this.parentObjects = parentConfig.getObjects();
50 this.parentConfig = parentConfig;
51 }
52
53 public PluginConfig(File configFile, Config parentConfig) throws MalformedURLException {
54 this(configFile.toURI().toURL(), parentConfig);
55 }
56
57 public Properties getBaseProperties() {
58 return this.parentProperties;
59 }
60
61 public Map getBaseObjects() {
62 return this.parentObjects;
63 }
64
65 public void addListener(String listenerClass) {
66 listeners.add(listenerClass);
67 }
68
69 public List getListeners() {
70 return listeners;
71 }
72
73 public void setResourceLoaderClassname(String resourceLoaderClassname) {
74 this.resourceLoaderClassname = resourceLoaderClassname;
75 }
76
77 public String getResourceLoaderClassname() {
78 return resourceLoaderClassname;
79 }
80
81 public String toString() {
82 return "[PluginConfig: resourceLoaderClassname: " + getResourceLoaderClassname() + "]";
83 }
84
85
86 @Override
87 public Object getObject(String key) {
88 Object object = super.getObject(key);
89 if (object == null && parentConfig != null) {
90 object = parentConfig.getObject(key);
91 }
92 return object;
93 }
94
95 @Override
96 public Map<String, Object> getObjects() {
97 Map<String, Object> finalObjects = new HashMap<String, Object>(super.getObjects());
98 if (parentConfig != null) {
99 Map<String, Object> parentObjects = parentConfig.getObjects();
100 for (String key : parentObjects.keySet()) {
101 if (!finalObjects.containsKey(key)) {
102 finalObjects.put(key, parentObjects.get(key));
103 }
104 }
105 }
106
107 return finalObjects;
108 }
109 }