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

io.nemesis.platform.module.recommendation.config.RecommendationModuleAutoConfiguration Maven / Gradle / Ivy

The newest version!
/*
 * nemesis Platform - NExt-generation Multichannel E-commerce SYStem
 *
 * Copyright (c) 2010 - 2020 nemesis
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of nemesis
 * ("Confidential Information"). You shall not disclose such Confidential
 * Information and shall use it only in accordance with the terms of the
 * license agreement you entered into with nemesis.
 */
package io.nemesis.platform.module.recommendation.config;

import io.nemesis.platform.core.service.conversion.PlatformFormattingConversionService;
import io.nemesis.platform.module.recommendation.core.repository.jpa.RecommendationProductRepository;
import io.nemesis.platform.module.recommendation.core.service.RecommendationService;
import io.nemesis.platform.module.recommendation.core.service.impl.RecommendationServiceImpl;
import io.nemesis.platform.module.recommendation.facade.RecommendationFacade;
import io.nemesis.platform.module.recommendation.facade.convention.RecommendationProductMapperFactoryConfigurer;
import io.nemesis.platform.module.recommendation.facade.impl.RecommendationFacadeImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;

/**
 * Spring configuration for the recommendation module.
 *
 * @author Vladimir Pechev
 * @since 2.2.2
 */
@Configuration
public class RecommendationModuleAutoConfiguration {

    protected final Logger LOG = LoggerFactory.getLogger(getClass());

    @PostConstruct
    public void init() {
        LOG.info("Initializing [recommendation] module ...");
    }

    @Bean(name = RecommendationService.NAME)
    @ConditionalOnMissingBean(name = RecommendationService.NAME)
    public RecommendationService defaultRecommendationServiceImpl(
                    @Qualifier(RecommendationProductRepository.NAME) final RecommendationProductRepository recommendationProductRepository) {
        return new RecommendationServiceImpl(recommendationProductRepository);
    }

    /* facade */
    @Bean(name = RecommendationProductMapperFactoryConfigurer.NAME)
    @ConditionalOnMissingBean(name = RecommendationProductMapperFactoryConfigurer.NAME)
    public RecommendationProductMapperFactoryConfigurer defaultRecommendationProductMapperFactoryConfigurer() {
        return new RecommendationProductMapperFactoryConfigurer();
    }

    @Bean(name = { RecommendationFacadeImpl.NAME, RecommendationFacade.NAME })
    @ConditionalOnMissingBean(name = RecommendationFacade.NAME)
    public RecommendationFacade defaultRecommendationFacade(@Qualifier(RecommendationService.NAME) RecommendationService recommendationService,
                                                            @Qualifier(PlatformFormattingConversionService.NAME) PlatformFormattingConversionService conversionService) {
        return new RecommendationFacadeImpl(recommendationService, conversionService);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy