All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.breuninger.boot.mongo.configuration.MongoJobsConfiguration Maven / Gradle / Ivy

There is a newer version: 2.0.5.RELEASE
Show newest version
package com.breuninger.boot.mongo.configuration;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.breuninger.boot.jobs.repository.JobMetaRepository;
import com.breuninger.boot.jobs.repository.JobRepository;
import com.breuninger.boot.mongo.jobs.MongoJobMetaRepository;
import com.breuninger.boot.mongo.jobs.MongoJobRepository;
import com.mongodb.client.MongoDatabase;

import lombok.extern.slf4j.Slf4j;

@Slf4j
@Configuration
@ConditionalOnClass(name = "com.breuninger.boot.jobs.configuration.JobsConfiguration")
@EnableConfigurationProperties(MongoProperties.class)
public class MongoJobsConfiguration {

  @Bean
  public JobRepository jobRepository(final MongoDatabase mongoDatabase,
                                     @Value("${breuninger.jobs.collection.jobinfo:jobinfo}") final String collectionName,
                                     final MongoProperties mongoProperties) {
    LOG.info("===============================");
    LOG.info("Using MongoJobRepository with {} MongoDatabase impl.", mongoDatabase.getClass().getSimpleName());
    LOG.info("===============================");
    return new MongoJobRepository(mongoDatabase, collectionName, mongoProperties);
  }

  @Bean
  public JobMetaRepository jobMetaRepository(final MongoDatabase mongoDatabase,
                                             @Value("${breuninger.jobs.collection.jobmeta:jobmeta}") final String collectionName,
                                             final MongoProperties mongoProperties) {
    LOG.info("===============================");
    LOG.info("Using MongoJobMetaRepository with {} MongoDatabase impl.", mongoDatabase.getClass().getSimpleName());
    LOG.info("===============================");
    return new MongoJobMetaRepository(mongoDatabase, collectionName, mongoProperties);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy