|
1 | 1 | /*
|
2 |
| - * Copyright 2012-2016 the original author or authors. |
| 2 | + * Copyright 2012-2017 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
17 | 17 | package org.springframework.boot.autoconfigure.integration;
|
18 | 18 |
|
19 | 19 | import javax.management.MBeanServer;
|
| 20 | +import javax.sql.DataSource; |
20 | 21 |
|
21 | 22 | import org.springframework.beans.BeansException;
|
22 | 23 | import org.springframework.beans.factory.BeanFactory;
|
23 | 24 | import org.springframework.beans.factory.BeanFactoryAware;
|
24 | 25 | import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
| 26 | +import org.springframework.boot.autoconfigure.condition.AnyNestedCondition; |
| 27 | +import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; |
25 | 28 | import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
26 | 29 | import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
27 | 30 | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
| 31 | +import org.springframework.boot.autoconfigure.condition.ConditionalOnSingleCandidate; |
28 | 32 | import org.springframework.boot.autoconfigure.condition.SearchStrategy;
|
29 | 33 | import org.springframework.boot.autoconfigure.jmx.JmxAutoConfiguration;
|
30 | 34 | import org.springframework.boot.bind.RelaxedPropertyResolver;
|
| 35 | +import org.springframework.boot.context.properties.EnableConfigurationProperties; |
31 | 36 | import org.springframework.context.EnvironmentAware;
|
32 | 37 | import org.springframework.context.annotation.Bean;
|
| 38 | +import org.springframework.context.annotation.Conditional; |
33 | 39 | import org.springframework.context.annotation.Configuration;
|
34 | 40 | import org.springframework.context.annotation.Import;
|
35 | 41 | import org.springframework.core.env.Environment;
|
| 42 | +import org.springframework.core.io.ResourceLoader; |
36 | 43 | import org.springframework.integration.config.EnableIntegration;
|
37 | 44 | import org.springframework.integration.config.EnableIntegrationManagement;
|
38 | 45 | import org.springframework.integration.gateway.GatewayProxyFactoryBean;
|
| 46 | +import org.springframework.integration.jdbc.lock.DefaultLockRepository; |
| 47 | +import org.springframework.integration.jdbc.store.JdbcChannelMessageStore; |
| 48 | +import org.springframework.integration.jdbc.store.JdbcMessageStore; |
39 | 49 | import org.springframework.integration.jmx.config.EnableIntegrationMBeanExport;
|
40 | 50 | import org.springframework.integration.monitor.IntegrationMBeanExporter;
|
41 | 51 | import org.springframework.integration.support.management.IntegrationManagementConfigurer;
|
|
48 | 58 | * @author Artem Bilan
|
49 | 59 | * @author Dave Syer
|
50 | 60 | * @author Stephane Nicoll
|
| 61 | + * @author Vedran Pavic |
51 | 62 | * @since 1.1.0
|
52 | 63 | */
|
53 | 64 | @Configuration
|
54 | 65 | @ConditionalOnClass(EnableIntegration.class)
|
| 66 | +@EnableConfigurationProperties(IntegrationProperties.class) |
55 | 67 | @AutoConfigureAfter(JmxAutoConfiguration.class)
|
56 | 68 | public class IntegrationAutoConfiguration {
|
57 | 69 |
|
@@ -131,4 +143,47 @@ protected static class IntegrationComponentScanAutoConfiguration {
|
131 | 143 |
|
132 | 144 | }
|
133 | 145 |
|
| 146 | + /** |
| 147 | + * Integration JDBC configuration. |
| 148 | + */ |
| 149 | + @Configuration |
| 150 | + @ConditionalOnClass(JdbcMessageStore.class) |
| 151 | + @ConditionalOnSingleCandidate(DataSource.class) |
| 152 | + protected static class IntegrationJdbcConfiguration { |
| 153 | + |
| 154 | + @Bean |
| 155 | + @ConditionalOnMissingBean |
| 156 | + @Conditional(IntegrationSchemaCondition.class) |
| 157 | + public IntegrationDatabaseInitializer integrationDatabaseInitializer( |
| 158 | + DataSource dataSource, ResourceLoader resourceLoader, |
| 159 | + IntegrationProperties properties) { |
| 160 | + return new IntegrationDatabaseInitializer(dataSource, resourceLoader, |
| 161 | + properties); |
| 162 | + } |
| 163 | + |
| 164 | + } |
| 165 | + |
| 166 | + static class IntegrationSchemaCondition extends AnyNestedCondition { |
| 167 | + |
| 168 | + IntegrationSchemaCondition() { |
| 169 | + super(ConfigurationPhase.REGISTER_BEAN); |
| 170 | + } |
| 171 | + |
| 172 | + @ConditionalOnBean(JdbcMessageStore.class) |
| 173 | + static class JdbcMessageStoreUsed { |
| 174 | + |
| 175 | + } |
| 176 | + |
| 177 | + @ConditionalOnBean(JdbcChannelMessageStore.class) |
| 178 | + static class JdbcChannelMessageStoreUsed { |
| 179 | + |
| 180 | + } |
| 181 | + |
| 182 | + @ConditionalOnBean(DefaultLockRepository.class) |
| 183 | + static class DefaultLockRepositoryUsed { |
| 184 | + |
| 185 | + } |
| 186 | + |
| 187 | + } |
| 188 | + |
134 | 189 | }
|
0 commit comments