com.xlrit.gears.plugin.mongo.MongoExportTargetFactory Maven / Gradle / Ivy
package com.xlrit.gears.plugin.mongo;
import java.util.Objects;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.xlrit.gears.engine.export.ExportTarget;
import com.xlrit.gears.engine.export.ExportTargetFactory;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
@Component
@RequiredArgsConstructor
public class MongoExportTargetFactory implements ExportTargetFactory {
private final ObjectMapper objectMapper;
private final MongoExportProperties properties;
@Override
public String getType() {
return "mongo";
}
@Override
public ExportTarget create() {
String connectionString = Objects.requireNonNull(properties.getConnectionString(), "connectionString must be configured");
String database = Objects.requireNonNull(properties.getDatabase(), "database must be configured");
MongoConfig config = new MongoConfig(connectionString, database);
return new MongoExportTarget(config, objectMapper);
}
}