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.List;
19 import java.util.Properties;
20
21 import org.kuali.common.util.Mode;
22 import org.kuali.common.util.PropertyUtils;
23 import org.kuali.common.util.property.Constants;
24 import org.slf4j.Logger;
25 import org.slf4j.LoggerFactory;
26
27 public class SetSystemPropertiesProcessor implements PropertyProcessor {
28 private static final Logger logger = LoggerFactory.getLogger(SetSystemPropertiesProcessor.class);
29
30 Mode propertyOverwriteMode;
31 List<String> includes;
32 List<String> excludes;
33
34 public SetSystemPropertiesProcessor() {
35 this(null);
36 }
37
38 public SetSystemPropertiesProcessor(List<String> includes) {
39 super();
40 this.includes = includes;
41 this.propertyOverwriteMode = Constants.DEFAULT_PROPERTY_OVERWRITE_MODE;
42 }
43
44 @Override
45 public void process(Properties properties) {
46 List<String> keys = PropertyUtils.getSortedKeys(properties, includes, excludes);
47 Properties systemProperties = System.getProperties();
48 for (String key : keys) {
49 String value = properties.getProperty(key);
50 logger.info("Setting system property [{}]", key);
51 PropertyUtils.addOrOverrideProperty(systemProperties, key, value, propertyOverwriteMode);
52 }
53 }
54
55 public Mode getPropertyOverwriteMode() {
56 return propertyOverwriteMode;
57 }
58
59 public void setPropertyOverwriteMode(Mode propertyOverwriteMode) {
60 this.propertyOverwriteMode = propertyOverwriteMode;
61 }
62
63 public List<String> getIncludes() {
64 return includes;
65 }
66
67 public void setIncludes(List<String> includes) {
68 this.includes = includes;
69 }
70
71 public List<String> getExcludes() {
72 return excludes;
73 }
74
75 public void setExcludes(List<String> excludes) {
76 this.excludes = excludes;
77 }
78
79 }