Search in sources :

Example 1 with IFeatureAwareVersion

use of de.flapdoodle.embed.mongo.distribution.IFeatureAwareVersion in project spring-boot by spring-projects.

the class EmbeddedMongoAutoConfiguration method embeddedMongoConfiguration.

@Bean
@ConditionalOnMissingBean
public IMongodConfig embeddedMongoConfiguration() throws IOException {
    IFeatureAwareVersion featureAwareVersion = new ToStringFriendlyFeatureAwareVersion(this.embeddedProperties.getVersion(), this.embeddedProperties.getFeatures());
    MongodConfigBuilder builder = new MongodConfigBuilder().version(featureAwareVersion);
    if (this.embeddedProperties.getStorage() != null) {
        builder.replication(new Storage(this.embeddedProperties.getStorage().getDatabaseDir(), this.embeddedProperties.getStorage().getReplSetName(), this.embeddedProperties.getStorage().getOplogSize() != null ? this.embeddedProperties.getStorage().getOplogSize() : 0));
    }
    Integer configuredPort = this.properties.getPort();
    if (configuredPort != null && configuredPort > 0) {
        builder.net(new Net(getHost().getHostAddress(), configuredPort, Network.localhostIsIPv6()));
    } else {
        builder.net(new Net(getHost().getHostAddress(), Network.getFreeServerPort(getHost()), Network.localhostIsIPv6()));
    }
    return builder.build();
}
Also used : Storage(de.flapdoodle.embed.mongo.config.Storage) Net(de.flapdoodle.embed.mongo.config.Net) MongodConfigBuilder(de.flapdoodle.embed.mongo.config.MongodConfigBuilder) IFeatureAwareVersion(de.flapdoodle.embed.mongo.distribution.IFeatureAwareVersion) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ReactiveMongoClientFactoryBean(org.springframework.data.mongodb.core.ReactiveMongoClientFactoryBean) MongoClientFactoryBean(org.springframework.data.mongodb.core.MongoClientFactoryBean) Bean(org.springframework.context.annotation.Bean)

Aggregations

MongodConfigBuilder (de.flapdoodle.embed.mongo.config.MongodConfigBuilder)1 Net (de.flapdoodle.embed.mongo.config.Net)1 Storage (de.flapdoodle.embed.mongo.config.Storage)1 IFeatureAwareVersion (de.flapdoodle.embed.mongo.distribution.IFeatureAwareVersion)1 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)1 Bean (org.springframework.context.annotation.Bean)1 MongoClientFactoryBean (org.springframework.data.mongodb.core.MongoClientFactoryBean)1 ReactiveMongoClientFactoryBean (org.springframework.data.mongodb.core.ReactiveMongoClientFactoryBean)1