View Javadoc

1   /**
2    * Copyright 2010-2013 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
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  }