|
|
@ -1,5 +1,5 @@
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* Copyright 2012-2018 the original author or authors.
|
|
|
|
* Copyright 2012-2019 the original author or authors.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
@ -21,6 +21,7 @@ import java.net.InetAddress;
|
|
|
|
import java.net.UnknownHostException;
|
|
|
|
import java.net.UnknownHostException;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
import java.util.stream.Stream;
|
|
|
|
|
|
|
|
|
|
|
|
import com.mongodb.MongoClient;
|
|
|
|
import com.mongodb.MongoClient;
|
|
|
|
import de.flapdoodle.embed.mongo.Command;
|
|
|
|
import de.flapdoodle.embed.mongo.Command;
|
|
|
@ -204,41 +205,29 @@ public class EmbeddedMongoAutoConfiguration {
|
|
|
|
@ConditionalOnMissingBean(IRuntimeConfig.class)
|
|
|
|
@ConditionalOnMissingBean(IRuntimeConfig.class)
|
|
|
|
static class RuntimeConfigConfiguration {
|
|
|
|
static class RuntimeConfigConfiguration {
|
|
|
|
|
|
|
|
|
|
|
|
private static Logger EMBEDDED_MONGO_LOGGER = LoggerFactory
|
|
|
|
|
|
|
|
.getLogger(RuntimeConfigConfiguration.class.getPackage().getName()
|
|
|
|
|
|
|
|
+ ".EmbeddedMongo");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Bean
|
|
|
|
@Bean
|
|
|
|
public IRuntimeConfig embeddedMongoRuntimeConfig(
|
|
|
|
public IRuntimeConfig embeddedMongoRuntimeConfig(
|
|
|
|
IDownloadConfig embeddedMongoDownloadConfig) {
|
|
|
|
ObjectProvider<DownloadConfigBuilderCustomizer> downloadConfigBuilderCustomizers) {
|
|
|
|
|
|
|
|
Logger logger = LoggerFactory
|
|
|
|
|
|
|
|
.getLogger(getClass().getPackage().getName() + ".EmbeddedMongo");
|
|
|
|
ProcessOutput processOutput = new ProcessOutput(
|
|
|
|
ProcessOutput processOutput = new ProcessOutput(
|
|
|
|
Processors.logTo(EMBEDDED_MONGO_LOGGER, Slf4jLevel.INFO),
|
|
|
|
Processors.logTo(logger, Slf4jLevel.INFO),
|
|
|
|
Processors.logTo(EMBEDDED_MONGO_LOGGER, Slf4jLevel.ERROR),
|
|
|
|
Processors.logTo(logger, Slf4jLevel.ERROR), Processors.named(
|
|
|
|
Processors.named("[console>]",
|
|
|
|
"[console>]", Processors.logTo(logger, Slf4jLevel.DEBUG)));
|
|
|
|
Processors.logTo(EMBEDDED_MONGO_LOGGER, Slf4jLevel.DEBUG)));
|
|
|
|
return new RuntimeConfigBuilder().defaultsWithLogger(Command.MongoD, logger)
|
|
|
|
return new RuntimeConfigBuilder()
|
|
|
|
.processOutput(processOutput).artifactStore(getArtifactStore(logger,
|
|
|
|
.defaultsWithLogger(Command.MongoD, EMBEDDED_MONGO_LOGGER)
|
|
|
|
downloadConfigBuilderCustomizers.orderedStream()))
|
|
|
|
.processOutput(processOutput)
|
|
|
|
.build();
|
|
|
|
.artifactStore(getArtifactStore(embeddedMongoDownloadConfig)).build();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Bean
|
|
|
|
private ArtifactStoreBuilder getArtifactStore(Logger logger,
|
|
|
|
@ConditionalOnMissingBean
|
|
|
|
Stream<DownloadConfigBuilderCustomizer> downloadConfigBuilderCustomizers) {
|
|
|
|
public IDownloadConfig embeddedMongoDownloadConfig(
|
|
|
|
|
|
|
|
ObjectProvider<EmbeddedMongoDownloadConfigBuilderCustomizer> downloadConfigBuilderCustomizer) {
|
|
|
|
|
|
|
|
DownloadConfigBuilder downloadConfigBuilder = new DownloadConfigBuilder()
|
|
|
|
DownloadConfigBuilder downloadConfigBuilder = new DownloadConfigBuilder()
|
|
|
|
.defaultsForCommand(Command.MongoD);
|
|
|
|
.defaultsForCommand(Command.MongoD);
|
|
|
|
|
|
|
|
downloadConfigBuilder.progressListener(new Slf4jProgressListener(logger));
|
|
|
|
downloadConfigBuilder
|
|
|
|
downloadConfigBuilderCustomizers
|
|
|
|
.progressListener(new Slf4jProgressListener(EMBEDDED_MONGO_LOGGER));
|
|
|
|
.forEach((customizer) -> customizer.customize(downloadConfigBuilder));
|
|
|
|
|
|
|
|
IDownloadConfig downloadConfig = downloadConfigBuilder.build();
|
|
|
|
downloadConfigBuilderCustomizer.stream()
|
|
|
|
|
|
|
|
.forEach((c) -> c.customize(downloadConfigBuilder));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return downloadConfigBuilder.build();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private ArtifactStoreBuilder getArtifactStore(IDownloadConfig downloadConfig) {
|
|
|
|
|
|
|
|
return new ExtractedArtifactStoreBuilder().defaults(Command.MongoD)
|
|
|
|
return new ExtractedArtifactStoreBuilder().defaults(Command.MongoD)
|
|
|
|
.download(downloadConfig);
|
|
|
|
.download(downloadConfig);
|
|
|
|
}
|
|
|
|
}
|
|
|
|