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

com.zyy.common.config.HandleConfig Maven / Gradle / Ivy

package com.zyy.common.config;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.zyy.common.aspect.HandleAspect;
import com.zyy.common.factory.HandleFactory;
import com.zyy.common.mapper.HandleMapper;
import com.zyy.common.mapper.TemplateMapper;
import com.zyy.common.producer.BaseSendProducer;
import com.zyy.common.service.HandleService;
import com.zyy.common.service.TemplateService;
import com.zyy.common.service.impl.HttpHandle;
import com.zyy.common.service.impl.JudgeHandle;
import com.zyy.common.service.impl.RabbitHandle;
import com.zyy.common.service.impl.TemplateServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;
import java.util.concurrent.Executor;

@Slf4j
@Configuration
@ConditionalOnProperty(prefix = "dlg.handle", value = "enable")
public class HandleConfig {

    @Resource
    private ObjectMapper objectMapper;
    @Resource
    private ApplicationContext applicationContext;
    @Resource
    private HandleMapper handleMapper;
    @Resource
    private TemplateMapper templateMapper;
    @Resource
    private RabbitTemplate rabbitTemplate;
    @Resource
    private Executor asyncServiceExecutor;

    @Bean
    public HandleService rabbitmq() {
        return new RabbitHandle(baseSendProducer(), objectMapper);
    }

    @Bean
    public HandleService http() {
        return new HttpHandle(objectMapper);
    }

    @Bean
    public HandleService judge() {
        return new JudgeHandle(objectMapper);
    }

    @Bean
    public HandleFactory handleFactory() {
        return new HandleFactory(applicationContext);
    }

    @Bean
    public BaseSendProducer baseSendProducer() {
        return new BaseSendProducer(rabbitTemplate);
    }

    @Bean
    public HandleAspect handleAspect() {
        return new HandleAspect(handleMapper, asyncServiceExecutor, templateMapper);
    }

    @Bean
    public TemplateService templateServiceImpl() {
        return new TemplateServiceImpl(templateMapper);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy