1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.common.util.spring;
17
18 import java.util.Properties;
19
20 import org.kuali.common.util.Assert;
21 import org.springframework.beans.factory.FactoryBean;
22 import org.springframework.beans.factory.InitializingBean;
23
24
25
26
27 public class SetPropertyFactoryBean implements FactoryBean<Properties>, InitializingBean {
28
29 Properties properties;
30 String key;
31 String value;
32
33 @Override
34 public void afterPropertiesSet() throws Exception {
35 Assert.notNull(properties, "properties is null");
36 Assert.notNull(key, "key is null");
37 Assert.notNull(value, "value is null");
38 properties.setProperty(key, value);
39 }
40
41 @Override
42 public Properties getObject() throws Exception {
43 return properties;
44 }
45
46 @Override
47 public Class<Properties> getObjectType() {
48 return Properties.class;
49 }
50
51 @Override
52 public boolean isSingleton() {
53 return false;
54 }
55
56 public Properties getProperties() {
57 return properties;
58 }
59
60 public void setProperties(Properties properties) {
61 this.properties = properties;
62 }
63
64 public String getKey() {
65 return key;
66 }
67
68 public void setKey(String key) {
69 this.key = key;
70 }
71
72 public String getValue() {
73 return value;
74 }
75
76 public void setValue(String value) {
77 this.value = value;
78 }
79
80 }