1 | |
package org.kuali.spring.util; |
2 | |
|
3 | |
import java.util.Properties; |
4 | |
|
5 | |
import org.springframework.beans.factory.BeanFactory; |
6 | |
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer; |
7 | |
import org.springframework.core.io.Resource; |
8 | |
import org.springframework.util.DefaultPropertiesPersister; |
9 | |
import org.springframework.util.PropertiesPersister; |
10 | |
|
11 | 0 | public class ConfigurablePropertyPlaceholderConfigurer extends PropertyPlaceholderConfigurer { |
12 | |
public static final boolean DEFAULT_IS_SEARCH_SYSTEM_ENVIRONMENT = true; |
13 | |
public static final boolean DEFAULT_IS_IGNORE_UNRESOLVABLE_PLACEHOLDERS = false; |
14 | |
public static final boolean DEFAULT_IS_LOCAL_OVERRIDE = false; |
15 | |
public static final boolean DEFAULT_IS_IGNORE_RESOURCE_NOT_FOUND = false; |
16 | 0 | private String placeholderPrefix = DEFAULT_PLACEHOLDER_PREFIX; |
17 | 0 | private String placeholderSuffix = DEFAULT_PLACEHOLDER_SUFFIX; |
18 | 0 | private String valueSeparator = DEFAULT_VALUE_SEPARATOR; |
19 | 0 | private int systemPropertiesMode = SYSTEM_PROPERTIES_MODE_FALLBACK; |
20 | 0 | private boolean searchSystemEnvironment = DEFAULT_IS_SEARCH_SYSTEM_ENVIRONMENT; |
21 | 0 | private boolean ignoreUnresolvablePlaceholders = DEFAULT_IS_IGNORE_UNRESOLVABLE_PLACEHOLDERS; |
22 | 0 | private boolean localOverride = DEFAULT_IS_LOCAL_OVERRIDE; |
23 | 0 | private boolean ignoreResourceNotFound = DEFAULT_IS_IGNORE_RESOURCE_NOT_FOUND; |
24 | |
private String nullValue; |
25 | |
private String beanName; |
26 | |
private Properties[] localProperties; |
27 | |
private Resource[] locations; |
28 | |
private String fileEncoding; |
29 | 0 | private PropertiesPersister propertiesPersister = new DefaultPropertiesPersister(); |
30 | |
|
31 | |
private BeanFactory beanFactory; |
32 | |
|
33 | |
public String getSystemPropertiesModeName() { |
34 | 0 | if (getSystemPropertiesMode() == SYSTEM_PROPERTIES_MODE_FALLBACK) { |
35 | 0 | return "SYSTEM_PROPERTIES_MODE_FALLBACK"; |
36 | 0 | } else if (getSystemPropertiesMode() == SYSTEM_PROPERTIES_MODE_NEVER) { |
37 | 0 | return "SYSTEM_PROPERTIES_MODE_NEVER"; |
38 | 0 | } else if (getSystemPropertiesMode() == SYSTEM_PROPERTIES_MODE_OVERRIDE) { |
39 | 0 | return "SYSTEM_PROPERTIES_MODE_OVERRIDE"; |
40 | |
} else { |
41 | 0 | throw new IllegalArgumentException("Unknown system properties mode"); |
42 | |
} |
43 | |
|
44 | |
} |
45 | |
|
46 | |
@Override |
47 | |
public void setPlaceholderPrefix(String placeholderPrefix) { |
48 | 0 | this.placeholderPrefix = placeholderPrefix; |
49 | 0 | super.setPlaceholderPrefix(placeholderPrefix); |
50 | 0 | } |
51 | |
|
52 | |
@Override |
53 | |
public void setPlaceholderSuffix(String placeholderSuffix) { |
54 | 0 | this.placeholderSuffix = placeholderSuffix; |
55 | 0 | super.setPlaceholderSuffix(placeholderSuffix); |
56 | 0 | } |
57 | |
|
58 | |
@Override |
59 | |
public void setValueSeparator(String valueSeparator) { |
60 | 0 | this.valueSeparator = valueSeparator; |
61 | 0 | super.setValueSeparator(valueSeparator); |
62 | 0 | } |
63 | |
|
64 | |
@Override |
65 | |
public void setSystemPropertiesMode(int systemPropertiesMode) { |
66 | 0 | this.systemPropertiesMode = systemPropertiesMode; |
67 | 0 | super.setSystemPropertiesMode(systemPropertiesMode); |
68 | 0 | } |
69 | |
|
70 | |
@Override |
71 | |
public void setSearchSystemEnvironment(boolean searchSystemEnvironment) { |
72 | 0 | this.searchSystemEnvironment = searchSystemEnvironment; |
73 | 0 | super.setSearchSystemEnvironment(searchSystemEnvironment); |
74 | 0 | } |
75 | |
|
76 | |
@Override |
77 | |
public void setIgnoreUnresolvablePlaceholders(boolean ignoreUnresolvablePlaceholders) { |
78 | 0 | this.ignoreUnresolvablePlaceholders = ignoreUnresolvablePlaceholders; |
79 | 0 | super.setIgnoreUnresolvablePlaceholders(ignoreUnresolvablePlaceholders); |
80 | 0 | } |
81 | |
|
82 | |
@Override |
83 | |
public void setNullValue(String nullValue) { |
84 | 0 | this.nullValue = nullValue; |
85 | 0 | super.setNullValue(nullValue); |
86 | 0 | } |
87 | |
|
88 | |
@Override |
89 | |
public void setBeanName(String beanName) { |
90 | 0 | this.beanName = beanName; |
91 | 0 | super.setBeanName(beanName); |
92 | 0 | } |
93 | |
|
94 | |
@Override |
95 | |
public void setBeanFactory(BeanFactory beanFactory) { |
96 | 0 | this.beanFactory = beanFactory; |
97 | 0 | super.setBeanFactory(beanFactory); |
98 | 0 | } |
99 | |
|
100 | |
@Override |
101 | |
public void setSystemPropertiesModeName(String systemPropertiesModeName) { |
102 | 0 | super.setSystemPropertiesModeName(systemPropertiesModeName); |
103 | 0 | } |
104 | |
|
105 | |
@Override |
106 | |
public void setLocations(Resource[] locations) { |
107 | 0 | this.locations = locations; |
108 | 0 | super.setLocations(locations); |
109 | 0 | } |
110 | |
|
111 | |
@Override |
112 | |
public void setLocalOverride(boolean localOverride) { |
113 | 0 | this.localOverride = localOverride; |
114 | 0 | super.setLocalOverride(localOverride); |
115 | 0 | } |
116 | |
|
117 | |
@Override |
118 | |
public void setIgnoreResourceNotFound(boolean ignoreResourceNotFound) { |
119 | 0 | this.ignoreResourceNotFound = ignoreResourceNotFound; |
120 | 0 | super.setIgnoreResourceNotFound(ignoreResourceNotFound); |
121 | 0 | } |
122 | |
|
123 | |
@Override |
124 | |
public void setFileEncoding(String fileEncoding) { |
125 | 0 | this.fileEncoding = fileEncoding; |
126 | 0 | super.setFileEncoding(fileEncoding); |
127 | 0 | } |
128 | |
|
129 | |
@Override |
130 | |
public void setPropertiesPersister(PropertiesPersister propertiesPersister) { |
131 | 0 | this.propertiesPersister = propertiesPersister; |
132 | 0 | super.setPropertiesPersister(propertiesPersister); |
133 | 0 | } |
134 | |
|
135 | |
public String getPlaceholderSuffix() { |
136 | 0 | return placeholderSuffix; |
137 | |
} |
138 | |
|
139 | |
public String getValueSeparator() { |
140 | 0 | return valueSeparator; |
141 | |
} |
142 | |
|
143 | |
public int getSystemPropertiesMode() { |
144 | 0 | return systemPropertiesMode; |
145 | |
} |
146 | |
|
147 | |
public boolean isSearchSystemEnvironment() { |
148 | 0 | return searchSystemEnvironment; |
149 | |
} |
150 | |
|
151 | |
public boolean isIgnoreUnresolvablePlaceholders() { |
152 | 0 | return ignoreUnresolvablePlaceholders; |
153 | |
} |
154 | |
|
155 | |
public String getNullValue() { |
156 | 0 | return nullValue; |
157 | |
} |
158 | |
|
159 | |
public String getBeanName() { |
160 | 0 | return beanName; |
161 | |
} |
162 | |
|
163 | |
public BeanFactory getBeanFactory() { |
164 | 0 | return beanFactory; |
165 | |
} |
166 | |
|
167 | |
public Properties[] getLocalProperties() { |
168 | 0 | return localProperties; |
169 | |
} |
170 | |
|
171 | |
public void setLocalProperties(Properties[] localProperties) { |
172 | 0 | this.localProperties = localProperties; |
173 | 0 | } |
174 | |
|
175 | |
public Resource[] getLocations() { |
176 | 0 | return locations; |
177 | |
} |
178 | |
|
179 | |
public boolean isLocalOverride() { |
180 | 0 | return localOverride; |
181 | |
} |
182 | |
|
183 | |
public boolean isIgnoreResourceNotFound() { |
184 | 0 | return ignoreResourceNotFound; |
185 | |
} |
186 | |
|
187 | |
public String getFileEncoding() { |
188 | 0 | return fileEncoding; |
189 | |
} |
190 | |
|
191 | |
public PropertiesPersister getPropertiesPersister() { |
192 | 0 | return propertiesPersister; |
193 | |
} |
194 | |
|
195 | |
public String getPlaceholderPrefix() { |
196 | 0 | return placeholderPrefix; |
197 | |
} |
198 | |
|
199 | |
} |