|
19 | 19 | import javax.sql.DataSource;
|
20 | 20 | import javax.sql.XADataSource;
|
21 | 21 |
|
22 |
| -import org.apache.commons.logging.Log; |
23 |
| -import org.apache.commons.logging.LogFactory; |
24 |
| - |
25 | 22 | import org.springframework.beans.factory.BeanFactoryUtils;
|
26 |
| -import org.springframework.beans.factory.NoSuchBeanDefinitionException; |
27 |
| -import org.springframework.beans.factory.config.BeanDefinition; |
28 |
| -import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; |
29 | 23 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
30 | 24 | import org.springframework.boot.autoconfigure.condition.AnyNestedCondition;
|
31 | 25 | import org.springframework.boot.autoconfigure.condition.ConditionMessage;
|
|
63 | 57 | @Import({ Registrar.class, DataSourcePoolMetadataProvidersConfiguration.class })
|
64 | 58 | public class DataSourceAutoConfiguration {
|
65 | 59 |
|
66 |
| - private static final Log logger = LogFactory |
67 |
| - .getLog(DataSourceAutoConfiguration.class); |
68 |
| - |
69 | 60 | @Bean
|
70 | 61 | @ConditionalOnMissingBean
|
71 | 62 | public DataSourceInitializer dataSourceInitializer(DataSourceProperties properties,
|
72 | 63 | ApplicationContext applicationContext) {
|
73 | 64 | return new DataSourceInitializer(properties, applicationContext);
|
74 | 65 | }
|
75 | 66 |
|
76 |
| - /** |
77 |
| - * Determines if the {@code dataSource} being used by Spring was created from |
78 |
| - * {@link EmbeddedDataSourceConfiguration}. |
79 |
| - * @param beanFactory the bean factory |
80 |
| - * @return true if the data source was auto-configured. |
81 |
| - */ |
82 |
| - public static boolean containsAutoConfiguredDataSource( |
83 |
| - ConfigurableListableBeanFactory beanFactory) { |
84 |
| - try { |
85 |
| - BeanDefinition beanDefinition = beanFactory.getBeanDefinition("dataSource"); |
86 |
| - return EmbeddedDataSourceConfiguration.class.getName() |
87 |
| - .equals(beanDefinition.getFactoryBeanName()); |
88 |
| - } |
89 |
| - catch (NoSuchBeanDefinitionException ex) { |
90 |
| - return false; |
91 |
| - } |
92 |
| - } |
93 |
| - |
94 | 67 | @Configuration
|
95 | 68 | @Conditional(EmbeddedDatabaseCondition.class)
|
96 | 69 | @ConditionalOnMissingBean({ DataSource.class, XADataSource.class })
|
|
0 commit comments