|
48 | 48 | import org.slf4j.Logger;
|
49 | 49 | import org.slf4j.LoggerFactory;
|
50 | 50 |
|
| 51 | +import org.springframework.beans.factory.BeanFactoryUtils; |
| 52 | +import org.springframework.beans.factory.ListableBeanFactory; |
51 | 53 | import org.springframework.boot.autoconfigure.AutoConfigureBefore;
|
52 | 54 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
53 | 55 | import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
|
74 | 76 | * @author Andy Wilkinson
|
75 | 77 | * @author Yogesh Lonkar
|
76 | 78 | * @author Mark Paluch
|
| 79 | + * @author Issam El-atif |
77 | 80 | * @since 1.3.0
|
78 | 81 | */
|
79 | 82 | @Configuration
|
@@ -210,30 +213,37 @@ private ArtifactStoreBuilder getArtifactStore(Logger logger) {
|
210 | 213 | }
|
211 | 214 |
|
212 | 215 | /**
|
213 |
| - * Additional configuration to ensure that {@link MongoClient} beans depend on the |
214 |
| - * {@code embeddedMongoServer} bean. |
| 216 | + * Additional configuration to ensure that {@link MongoClient} beans depend on any |
| 217 | + * {@link MongodExecutable} beans. |
215 | 218 | */
|
216 | 219 | @Configuration
|
217 | 220 | @ConditionalOnClass({ MongoClient.class, MongoClientFactoryBean.class })
|
218 |
| - protected static class EmbeddedMongoDependencyConfiguration extends MongoClientDependsOnBeanFactoryPostProcessor { |
| 221 | + protected static class EmbeddedMongoDependencyConfiguration { |
219 | 222 |
|
220 |
| - public EmbeddedMongoDependencyConfiguration() { |
221 |
| - super("embeddedMongoServer"); |
| 223 | + @Bean |
| 224 | + public MongoClientDependsOnBeanFactoryPostProcessor mongoClientDependsOnBeanFactoryPostProcessor( |
| 225 | + ListableBeanFactory listableBeanFactory) { |
| 226 | + String[] mongoExecutableBeanNames = BeanFactoryUtils.beanNamesForTypeIncludingAncestors(listableBeanFactory, |
| 227 | + MongodExecutable.class); |
| 228 | + return new MongoClientDependsOnBeanFactoryPostProcessor(mongoExecutableBeanNames); |
222 | 229 | }
|
223 | 230 |
|
224 | 231 | }
|
225 | 232 |
|
226 | 233 | /**
|
227 |
| - * Additional configuration to ensure that {@link MongoClient} beans depend on the |
228 |
| - * {@code embeddedMongoServer} bean. |
| 234 | + * Additional configuration to ensure that {@link MongoClient} beans depend on any |
| 235 | + * {@link MongodExecutable} beans. |
229 | 236 | */
|
230 | 237 | @Configuration
|
231 | 238 | @ConditionalOnClass({ com.mongodb.reactivestreams.client.MongoClient.class, ReactiveMongoClientFactoryBean.class })
|
232 |
| - protected static class EmbeddedReactiveMongoDependencyConfiguration |
233 |
| - extends ReactiveStreamsMongoClientDependsOnBeanFactoryPostProcessor { |
| 239 | + protected static class EmbeddedReactiveMongoDependencyConfiguration { |
234 | 240 |
|
235 |
| - public EmbeddedReactiveMongoDependencyConfiguration() { |
236 |
| - super("embeddedMongoServer"); |
| 241 | + @Bean |
| 242 | + public ReactiveStreamsMongoClientDependsOnBeanFactoryPostProcessor reactiveStreamsMongoClientDependsOnBeanFactoryPostProcessor( |
| 243 | + ListableBeanFactory listableBeanFactory) { |
| 244 | + String[] mongoExecutableBeanNames = BeanFactoryUtils.beanNamesForTypeIncludingAncestors(listableBeanFactory, |
| 245 | + MongodExecutable.class); |
| 246 | + return new ReactiveStreamsMongoClientDependsOnBeanFactoryPostProcessor(mongoExecutableBeanNames); |
237 | 247 | }
|
238 | 248 |
|
239 | 249 | }
|
|
0 commit comments