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.ArrayList;
19 import java.util.List;
20 import java.util.Properties;
21
22 import org.kuali.common.util.MavenUtils;
23 import org.kuali.common.util.property.Constants;
24 import org.kuali.common.util.property.ProjectProperties;
25 import org.springframework.beans.factory.annotation.Autowired;
26 import org.springframework.beans.factory.annotation.Qualifier;
27 import org.springframework.context.annotation.Bean;
28 import org.springframework.context.annotation.Configuration;
29 import org.springframework.core.env.Environment;
30 import org.springframework.core.env.PropertySource;
31 import org.springframework.util.Assert;
32
33
34
35
36
37 @Configuration
38 public class MavenPropertySourceConfig {
39
40 public static final String SPRING_PROPERTY_SOURCE = "springPropertySource";
41
42 @Autowired
43 Environment env;
44
45 @Autowired
46 @Qualifier(Constants.DEFAULT_MAVEN_PROPERTIES_BEAN_NAME)
47 Properties mavenProperties;
48
49 @Bean
50 public ProjectProperties mavenProjectProperties() {
51
52 Assert.notNull(mavenProperties, "mavenProperties are null");
53
54
55 MavenUtils.augmentProjectProperties(mavenProperties);
56
57
58 return MavenUtils.getMavenProjectProperties(env, mavenProperties);
59 }
60
61
62
63
64 protected List<ProjectProperties> getProjectPropertiesList() {
65 return new ArrayList<ProjectProperties>();
66 }
67
68 @Bean
69 public PropertySource<?> springPropertySource() {
70 ProjectProperties mpp = mavenProjectProperties();
71
72
73 List<ProjectProperties> pps = new ArrayList<ProjectProperties>();
74
75 pps.add(mpp);
76
77 pps.addAll(getProjectPropertiesList());
78
79 pps.add(mpp);
80
81
82 return SpringUtils.getGlobalPropertySource(SPRING_PROPERTY_SOURCE, pps);
83 }
84
85 }