1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.common.util.spring.profile;
17
18 import org.kuali.common.util.maven.spring.Maven;
19 import org.kuali.common.util.spring.profile.annotation.MySql;
20 import org.kuali.common.util.spring.profile.annotation.Oracle;
21 import org.springframework.beans.factory.annotation.Autowired;
22 import org.springframework.beans.factory.annotation.Qualifier;
23 import org.springframework.context.annotation.Bean;
24 import org.springframework.context.annotation.Configuration;
25
26 @Configuration
27 public class DatabaseConfig {
28
29 private static final String VENDOR_BEAN = DatabaseConstants.VENDOR_BEAN_NAME;
30
31 @Autowired
32 @Qualifier(VENDOR_BEAN)
33 String vendor;
34
35 @Bean
36 public Database databaseConfigDatabase() {
37 DefaultDatabase dd = new DefaultDatabase();
38 dd.setVendor(vendor);
39 return dd;
40 }
41
42 @Configuration
43 @MySql
44 static class a {
45
46 @Autowired
47 @Qualifier("foo")
48 String bar;
49
50 @Bean(name = VENDOR_BEAN)
51 public String aa() {
52 return "mysql";
53 }
54 }
55
56 @Configuration
57 @Oracle
58 static class b {
59
60 @Autowired
61 @Qualifier("foo")
62 String bar;
63
64 @Bean(name = VENDOR_BEAN)
65 public String aa() {
66 return "oracle";
67 }
68 }
69
70 @Configuration
71 @Maven
72 static class c {
73 @Bean(name = VENDOR_BEAN)
74 public String aa() {
75 return "h2";
76 }
77 }
78
79 }