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

com.iteaj.izone.IzoneConfiguration Maven / Gradle / Ivy

There is a newer version: 1.2.1
Show newest version
package com.iteaj.izone;

import com.iteaj.izone.spi.event.AsyncGuavaEventBus;
import com.iteaj.izone.spi.event.EventPublisher;
import com.iteaj.izone.spi.event.Listener;
import com.iteaj.izone.spi.event.VoidEventPublisher;
import org.springframework.beans.factory.ObjectFactory;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.core.task.TaskExecutor;

import java.util.List;

/**
 * create time: 2020/4/21
 *
 * @author iteaj
 * @since 1.0
 */
@Configuration
public class IzoneConfiguration {

    @Bean
    @Primary
    @ConditionalOnBean({TaskExecutor.class})
    @ConditionalOnMissingBean(EventPublisher.class)
    public EventPublisher eventPublisher(TaskExecutor executor, List listeners) {
//        List listeners = factory.getIfAvailable();
        return new AsyncGuavaEventBus(listeners, executor);
    }

    @Bean
    @ConditionalOnMissingBean(EventPublisher.class)
    public EventPublisher eventPublisher() {
        return new VoidEventPublisher();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy