1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.common.util.property.processor;
17
18 import java.util.Properties;
19
20 import org.kuali.common.util.PropertyUtils;
21 import org.kuali.common.util.property.Constants;
22 import org.kuali.common.util.property.GlobalPropertiesMode;
23 import org.slf4j.Logger;
24 import org.slf4j.LoggerFactory;
25 import org.springframework.util.PropertyPlaceholderHelper;
26
27 public class ResolvePlaceholdersProcessor implements PropertyProcessor {
28
29 private static final Logger logger = LoggerFactory.getLogger(ResolvePlaceholdersProcessor.class);
30
31 PropertyPlaceholderHelper helper = Constants.DEFAULT_PROPERTY_PLACEHOLDER_HELPER;
32 GlobalPropertiesMode globalPropertiesMode = Constants.DEFAULT_GLOBAL_PROPERTIES_MODE;
33
34 public ResolvePlaceholdersProcessor() {
35 this(Constants.DEFAULT_PROPERTY_PLACEHOLDER_HELPER);
36 }
37
38 public ResolvePlaceholdersProcessor(PropertyPlaceholderHelper helper) {
39 this(helper, Constants.DEFAULT_GLOBAL_PROPERTIES_MODE);
40 }
41
42 public ResolvePlaceholdersProcessor(PropertyPlaceholderHelper helper, GlobalPropertiesMode globalPropertiesMode) {
43 super();
44 this.helper = helper;
45 this.globalPropertiesMode = globalPropertiesMode;
46 }
47
48 @Override
49 public void process(Properties properties) {
50 Properties resolvedProperties = PropertyUtils.getResolvedProperties(properties, helper, globalPropertiesMode);
51 if (resolvedProperties.size() > 0) {
52 logger.debug("Resolved {} property values", resolvedProperties.size());
53 properties.putAll(resolvedProperties);
54 }
55 }
56
57 public PropertyPlaceholderHelper getHelper() {
58 return helper;
59 }
60
61 public void setHelper(PropertyPlaceholderHelper helper) {
62 this.helper = helper;
63 }
64
65 public GlobalPropertiesMode getGlobalPropertiesMode() {
66 return globalPropertiesMode;
67 }
68
69 public void setGlobalPropertiesMode(GlobalPropertiesMode globalPropertiesMode) {
70 this.globalPropertiesMode = globalPropertiesMode;
71 }
72 }