|
39 | 39 | import de.flapdoodle.embed.mongo.distribution.Versions;
|
40 | 40 | import de.flapdoodle.embed.process.config.IRuntimeConfig;
|
41 | 41 | import de.flapdoodle.embed.process.config.io.ProcessOutput;
|
| 42 | +import de.flapdoodle.embed.process.config.store.IDownloadConfig; |
42 | 43 | import de.flapdoodle.embed.process.distribution.GenericVersion;
|
43 | 44 | import de.flapdoodle.embed.process.io.Processors;
|
44 | 45 | import de.flapdoodle.embed.process.io.Slf4jLevel;
|
@@ -202,24 +203,48 @@ private Map<String, Object> getMongoPorts(MutablePropertySources sources) {
|
202 | 203 | @ConditionalOnMissingBean(IRuntimeConfig.class)
|
203 | 204 | static class RuntimeConfigConfiguration {
|
204 | 205 |
|
| 206 | + private static final Logger EMBEDDED_MONGO_LOGGER = LoggerFactory |
| 207 | + .getLogger(RuntimeConfigConfiguration.class.getPackage().getName() |
| 208 | + + ".EmbeddedMongo"); |
| 209 | + |
205 | 210 | @Bean
|
206 |
| - public IRuntimeConfig embeddedMongoRuntimeConfig() { |
207 |
| - Logger logger = LoggerFactory |
208 |
| - .getLogger(getClass().getPackage().getName() + ".EmbeddedMongo"); |
| 211 | + public IRuntimeConfig embeddedMongoRuntimeConfig( |
| 212 | + IDownloadConfig embeddedMongoDownloadConfig) { |
209 | 213 | ProcessOutput processOutput = new ProcessOutput(
|
210 |
| - Processors.logTo(logger, Slf4jLevel.INFO), |
211 |
| - Processors.logTo(logger, Slf4jLevel.ERROR), Processors.named( |
212 |
| - "[console>]", Processors.logTo(logger, Slf4jLevel.DEBUG))); |
213 |
| - return new RuntimeConfigBuilder().defaultsWithLogger(Command.MongoD, logger) |
214 |
| - .processOutput(processOutput).artifactStore(getArtifactStore(logger)) |
215 |
| - .build(); |
| 214 | + Processors.logTo(EMBEDDED_MONGO_LOGGER, Slf4jLevel.INFO), |
| 215 | + Processors.logTo(EMBEDDED_MONGO_LOGGER, Slf4jLevel.ERROR), |
| 216 | + Processors.named("[console>]", |
| 217 | + Processors.logTo(EMBEDDED_MONGO_LOGGER, Slf4jLevel.DEBUG))); |
| 218 | + return new RuntimeConfigBuilder() |
| 219 | + .defaultsWithLogger(Command.MongoD, EMBEDDED_MONGO_LOGGER) |
| 220 | + .processOutput(processOutput) |
| 221 | + .artifactStore(getArtifactStore(embeddedMongoDownloadConfig)).build(); |
| 222 | + } |
| 223 | + |
| 224 | + @Bean |
| 225 | + @ConditionalOnMissingBean |
| 226 | + public IDownloadConfig embeddedMongoDownloadConfig( |
| 227 | + EmbeddedMongoProperties embeddedProperties) { |
| 228 | + de.flapdoodle.embed.process.config.store.DownloadConfigBuilder downloadConfigBuilder = new DownloadConfigBuilder() |
| 229 | + .defaultsForCommand(Command.MongoD) |
| 230 | + .progressListener(new Slf4jProgressListener(EMBEDDED_MONGO_LOGGER)); |
| 231 | + |
| 232 | + if (embeddedProperties.getDownload().getPath() != null) { |
| 233 | + downloadConfigBuilder |
| 234 | + .downloadPath(embeddedProperties.getDownload().getPath()); |
| 235 | + } |
| 236 | + |
| 237 | + if (embeddedProperties.getDownload().getUserAgent() != null) { |
| 238 | + downloadConfigBuilder |
| 239 | + .userAgent(embeddedProperties.getDownload().getUserAgent()); |
| 240 | + } |
| 241 | + |
| 242 | + return downloadConfigBuilder.build(); |
216 | 243 | }
|
217 | 244 |
|
218 |
| - private ArtifactStoreBuilder getArtifactStore(Logger logger) { |
| 245 | + private ArtifactStoreBuilder getArtifactStore(IDownloadConfig downloadConfig) { |
219 | 246 | return new ExtractedArtifactStoreBuilder().defaults(Command.MongoD)
|
220 |
| - .download(new DownloadConfigBuilder() |
221 |
| - .defaultsForCommand(Command.MongoD) |
222 |
| - .progressListener(new Slf4jProgressListener(logger)).build()); |
| 247 | + .download(downloadConfig); |
223 | 248 | }
|
224 | 249 |
|
225 | 250 | }
|
|
0 commit comments