|  | 
| 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; | 
|  | 
| 48 | 49 | import org.slf4j.Logger; | 
| 49 | 50 | import org.slf4j.LoggerFactory; | 
| 50 | 51 | 
 | 
|  | 52 | +import org.springframework.beans.factory.ObjectProvider; | 
| 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; | 
| @@ -202,24 +204,43 @@ private Map<String, Object> getMongoPorts(MutablePropertySources sources) { | 
| 202 | 204 | 	@ConditionalOnMissingBean(IRuntimeConfig.class) | 
| 203 | 205 | 	static class RuntimeConfigConfiguration { | 
| 204 | 206 | 
 | 
|  | 207 | +		private static Logger EMBEDDED_MONGO_LOGGER = LoggerFactory | 
|  | 208 | +				.getLogger(RuntimeConfigConfiguration.class.getPackage().getName() | 
|  | 209 | +						+ ".EmbeddedMongo"); | 
|  | 210 | + | 
| 205 | 211 | 		@Bean | 
| 206 |  | -		public IRuntimeConfig embeddedMongoRuntimeConfig() { | 
| 207 |  | -			Logger logger = LoggerFactory | 
| 208 |  | -					.getLogger(getClass().getPackage().getName() + ".EmbeddedMongo"); | 
|  | 212 | +		public IRuntimeConfig embeddedMongoRuntimeConfig( | 
|  | 213 | +				IDownloadConfig embeddedMongoDownloadConfig) { | 
| 209 | 214 | 			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(); | 
|  | 215 | +					Processors.logTo(EMBEDDED_MONGO_LOGGER, Slf4jLevel.INFO), | 
|  | 216 | +					Processors.logTo(EMBEDDED_MONGO_LOGGER, Slf4jLevel.ERROR), | 
|  | 217 | +					Processors.named("[console>]", | 
|  | 218 | +							Processors.logTo(EMBEDDED_MONGO_LOGGER, Slf4jLevel.DEBUG))); | 
|  | 219 | +			return new RuntimeConfigBuilder() | 
|  | 220 | +					.defaultsWithLogger(Command.MongoD, EMBEDDED_MONGO_LOGGER) | 
|  | 221 | +					.processOutput(processOutput) | 
|  | 222 | +					.artifactStore(getArtifactStore(embeddedMongoDownloadConfig)).build(); | 
|  | 223 | +		} | 
|  | 224 | + | 
|  | 225 | +		@Bean | 
|  | 226 | +		@ConditionalOnMissingBean | 
|  | 227 | +		public IDownloadConfig embeddedMongoDownloadConfig( | 
|  | 228 | +				ObjectProvider<EmbeddedMongoDownloadConfigBuilderCustomizer> downloadConfigBuilderCustomizer) { | 
|  | 229 | +			DownloadConfigBuilder downloadConfigBuilder = new DownloadConfigBuilder() | 
|  | 230 | +					.defaultsForCommand(Command.MongoD); | 
|  | 231 | + | 
|  | 232 | +			downloadConfigBuilder | 
|  | 233 | +					.progressListener(new Slf4jProgressListener(EMBEDDED_MONGO_LOGGER)); | 
|  | 234 | + | 
|  | 235 | +			downloadConfigBuilderCustomizer.stream() | 
|  | 236 | +					.forEach((c) -> c.customize(downloadConfigBuilder)); | 
|  | 237 | + | 
|  | 238 | +			return downloadConfigBuilder.build(); | 
| 216 | 239 | 		} | 
| 217 | 240 | 
 | 
| 218 |  | -		private ArtifactStoreBuilder getArtifactStore(Logger logger) { | 
|  | 241 | +		private ArtifactStoreBuilder getArtifactStore(IDownloadConfig downloadConfig) { | 
| 219 | 242 | 			return new ExtractedArtifactStoreBuilder().defaults(Command.MongoD) | 
| 220 |  | -					.download(new DownloadConfigBuilder() | 
| 221 |  | -							.defaultsForCommand(Command.MongoD) | 
| 222 |  | -							.progressListener(new Slf4jProgressListener(logger)).build()); | 
|  | 243 | +					.download(downloadConfig); | 
| 223 | 244 | 		} | 
| 224 | 245 | 
 | 
| 225 | 246 | 	} | 
|  | 
0 commit comments