1 |
|
package org.kuali.spring.util; |
2 |
|
|
3 |
|
import java.util.Properties; |
4 |
|
|
5 |
|
import org.kuali.spring.util.event.DefaultVisitListener; |
6 |
|
import org.kuali.spring.util.event.VisitListener; |
7 |
|
import org.springframework.beans.factory.BeanDefinitionStoreException; |
8 |
|
import org.springframework.beans.factory.config.BeanDefinition; |
9 |
|
import org.springframework.beans.factory.config.BeanDefinitionVisitor; |
10 |
|
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; |
11 |
|
import org.springframework.util.StringValueResolver; |
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
|
|
| 73% |
Uncovered Elements: 17 (63) |
Complexity: 19 |
Complexity Density: 0.45 |
|
16 |
|
public class PropertiesPlaceholderConfigurer extends PlaceholderConfigurer { |
17 |
|
|
18 |
|
private PropertiesLoader loader = new PropertiesLoader(); |
19 |
|
private PropertiesConverter converter = new PropertiesConverter(); |
20 |
|
private PropertiesResolver resolver = new PropertiesResolver(); |
21 |
|
private Properties properties; |
22 |
|
private String nullValue; |
23 |
|
|
|
|
| 77.8% |
Uncovered Elements: 2 (9) |
Complexity: 3 |
Complexity Density: 0.6 |
|
24 |
14
|
protected boolean currentBeanIsMe(String currentBean, ConfigurableListableBeanFactory beanFactoryToProcess) {... |
25 |
14
|
if (!currentBean.equals(getBeanName())) { |
26 |
13
|
return false; |
27 |
|
} |
28 |
1
|
if (!beanFactoryToProcess.equals(getBeanFactory())) { |
29 |
0
|
return false; |
30 |
|
} |
31 |
1
|
return true; |
32 |
|
} |
33 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
34 |
1
|
protected BeanDefinitionVisitor getBeanDefinitionVisitor(StringValueResolver valueResolver) {... |
35 |
1
|
EnhancedBeanDefinitionVisitor visitor = new EnhancedBeanDefinitionVisitor(); |
36 |
1
|
visitor.setValueResolver(valueResolver); |
37 |
1
|
VisitListener listener = new DefaultVisitListener(); |
38 |
1
|
visitor.addListener(listener); |
39 |
1
|
return visitor; |
40 |
|
} |
41 |
|
|
|
|
| 90.9% |
Uncovered Elements: 1 (11) |
Complexity: 3 |
Complexity Density: 0.33 |
|
42 |
1
|
protected void processBeans(ConfigurableListableBeanFactory beanFactory, StringValueResolver valueResolver) {... |
43 |
1
|
BeanDefinitionVisitor visitor = getBeanDefinitionVisitor(valueResolver); |
44 |
1
|
String[] beanNames = beanFactory.getBeanDefinitionNames(); |
45 |
1
|
for (String curName : beanNames) { |
46 |
|
|
47 |
14
|
if (currentBeanIsMe(curName, beanFactory)) { |
48 |
1
|
continue; |
49 |
|
} |
50 |
13
|
BeanDefinition bd = beanFactory.getBeanDefinition(curName); |
51 |
13
|
try { |
52 |
13
|
visitor.visitBeanDefinition(bd); |
53 |
|
} catch (Exception e) { |
54 |
0
|
throw new BeanDefinitionStoreException(bd.getResourceDescription(), curName, e.getMessage(), e); |
55 |
|
} |
56 |
|
} |
57 |
|
} |
58 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
|
59 |
1
|
protected StringValueResolver getStringValueResolver() {... |
60 |
1
|
ValueRetriever retriever = new PropertiesRetriever(this.properties); |
61 |
1
|
DefaultStringValueResolver dsvr = new DefaultStringValueResolver(); |
62 |
1
|
dsvr.setResolver(this.resolver); |
63 |
1
|
dsvr.setNullValue(this.nullValue); |
64 |
1
|
dsvr.setRetriever(retriever); |
65 |
1
|
return dsvr; |
66 |
|
} |
67 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
|
68 |
1
|
@Override... |
69 |
|
protected void processPlaceholders(ConfigurableListableBeanFactory beanFactoryToProcess) { |
70 |
1
|
this.properties = this.loader.loadProperties(); |
71 |
1
|
this.converter.convert(this.properties); |
72 |
1
|
this.resolver.resolve(this.properties); |
73 |
|
|
74 |
1
|
StringValueResolver valueResolver = getStringValueResolver(); |
75 |
|
|
76 |
1
|
processBeans(beanFactoryToProcess, valueResolver); |
77 |
|
|
78 |
|
|
79 |
1
|
beanFactoryToProcess.resolveAliases(valueResolver); |
80 |
|
|
81 |
|
|
82 |
1
|
beanFactoryToProcess.addEmbeddedValueResolver(valueResolver); |
83 |
|
|
84 |
|
} |
85 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
86 |
0
|
public PropertiesLoader getLoader() {... |
87 |
0
|
return loader; |
88 |
|
} |
89 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
90 |
1
|
public void setLoader(PropertiesLoader loader) {... |
91 |
1
|
this.loader = loader; |
92 |
|
} |
93 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
94 |
0
|
public PropertiesConverter getConverter() {... |
95 |
0
|
return converter; |
96 |
|
} |
97 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
98 |
1
|
public void setConverter(PropertiesConverter converter) {... |
99 |
1
|
this.converter = converter; |
100 |
|
} |
101 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
102 |
0
|
public Properties getProperties() {... |
103 |
0
|
return properties; |
104 |
|
} |
105 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
106 |
0
|
public void setProperties(Properties properties) {... |
107 |
0
|
this.properties = properties; |
108 |
|
} |
109 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
110 |
0
|
public PropertiesResolver getResolver() {... |
111 |
0
|
return resolver; |
112 |
|
} |
113 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
114 |
1
|
public void setResolver(PropertiesResolver resolver) {... |
115 |
1
|
this.resolver = resolver; |
116 |
|
} |
117 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
118 |
0
|
public String getNullValue() {... |
119 |
0
|
return nullValue; |
120 |
|
} |
121 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
122 |
0
|
public void setNullValue(String nullValue) {... |
123 |
0
|
this.nullValue = nullValue; |
124 |
|
} |
125 |
|
|
126 |
|
} |