Установил порядок инициализации стартеров
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
4c522c01ae
commit
34ae08daaf
@ -14,9 +14,7 @@ import dev.struchkov.godfather.simple.core.service.PersonSettingServiceImpl;
|
|||||||
import dev.struchkov.godfather.simple.core.service.StorylineMailService;
|
import dev.struchkov.godfather.simple.core.service.StorylineMailService;
|
||||||
import dev.struchkov.godfather.simple.core.service.StorylineService;
|
import dev.struchkov.godfather.simple.core.service.StorylineService;
|
||||||
import dev.struchkov.godfather.simple.core.service.UnitPointerServiceImpl;
|
import dev.struchkov.godfather.simple.core.service.UnitPointerServiceImpl;
|
||||||
import dev.struchkov.godfather.telegram.domain.config.TelegramBotConfig;
|
|
||||||
import dev.struchkov.godfather.telegram.main.context.TelegramConnect;
|
import dev.struchkov.godfather.telegram.main.context.TelegramConnect;
|
||||||
import dev.struchkov.godfather.telegram.main.core.TelegramDefaultConnect;
|
|
||||||
import dev.struchkov.godfather.telegram.simple.consumer.EventDistributorService;
|
import dev.struchkov.godfather.telegram.simple.consumer.EventDistributorService;
|
||||||
import dev.struchkov.godfather.telegram.simple.context.repository.SenderRepository;
|
import dev.struchkov.godfather.telegram.simple.context.repository.SenderRepository;
|
||||||
import dev.struchkov.godfather.telegram.simple.context.service.EventDistributor;
|
import dev.struchkov.godfather.telegram.simple.context.service.EventDistributor;
|
||||||
@ -30,11 +28,10 @@ import dev.struchkov.godfather.telegram.starter.UnitConfiguration;
|
|||||||
import dev.struchkov.godfather.telegram.starter.property.TelegramBotAutoresponderProperty;
|
import dev.struchkov.godfather.telegram.starter.property.TelegramBotAutoresponderProperty;
|
||||||
import org.springframework.beans.factory.ObjectProvider;
|
import org.springframework.beans.factory.ObjectProvider;
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
|
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.context.annotation.Primary;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -45,21 +42,9 @@ import static dev.struchkov.godfather.telegram.starter.TelegramBotBeanName.AUTOR
|
|||||||
import static dev.struchkov.haiti.utils.Checker.checkNotNull;
|
import static dev.struchkov.haiti.utils.Checker.checkNotNull;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
|
@AutoConfigureAfter(TelegramBotDataConfiguration.class)
|
||||||
public class TelegramBotAutoconfiguration {
|
public class TelegramBotAutoconfiguration {
|
||||||
|
|
||||||
@Bean
|
|
||||||
@Primary
|
|
||||||
@ConditionalOnProperty(prefix = "telegram.bot", name = "username")
|
|
||||||
public TelegramConnectBot telegramConnectBot(TelegramBotConfig telegramConfig) {
|
|
||||||
return new TelegramConnectBot(telegramConfig);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
@ConditionalOnProperty(prefix = "telegram.bot", name = "token")
|
|
||||||
public TelegramDefaultConnect telegramDefaultConnect(TelegramBotConfig telegramConfig) {
|
|
||||||
return new TelegramDefaultConnect(telegramConfig);
|
|
||||||
}
|
|
||||||
|
|
||||||
@ConditionalOnBean(TelegramConnectBot.class)
|
@ConditionalOnBean(TelegramConnectBot.class)
|
||||||
@Bean(AUTORESPONDER_EXECUTORS_SERVICE)
|
@Bean(AUTORESPONDER_EXECUTORS_SERVICE)
|
||||||
public ExecutorService executorService(
|
public ExecutorService executorService(
|
||||||
@ -75,11 +60,13 @@ public class TelegramBotAutoconfiguration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
@ConditionalOnBean(UnitPointerRepository.class)
|
||||||
public UnitPointerService unitPointerService(UnitPointerRepository unitPointerRepository) {
|
public UnitPointerService unitPointerService(UnitPointerRepository unitPointerRepository) {
|
||||||
return new UnitPointerServiceImpl(unitPointerRepository);
|
return new UnitPointerServiceImpl(unitPointerRepository);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
@ConditionalOnBean(PersonSettingRepository.class)
|
||||||
public PersonSettingService personSettingService(PersonSettingRepository personSettingRepository) {
|
public PersonSettingService personSettingService(PersonSettingRepository personSettingRepository) {
|
||||||
return new PersonSettingServiceImpl(personSettingRepository);
|
return new PersonSettingServiceImpl(personSettingRepository);
|
||||||
}
|
}
|
||||||
@ -133,11 +120,13 @@ public class TelegramBotAutoconfiguration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
@ConditionalOnBean(MailAutoresponderTelegram.class)
|
||||||
public StoryLineHandler storyLineHandler(MailAutoresponderTelegram mailAutoresponderTelegram) {
|
public StoryLineHandler storyLineHandler(MailAutoresponderTelegram mailAutoresponderTelegram) {
|
||||||
return new StoryLineHandler(mailAutoresponderTelegram);
|
return new StoryLineHandler(mailAutoresponderTelegram);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
@ConditionalOnBean(TelegramConnectBot.class)
|
||||||
public EventDistributor eventDistributor(
|
public EventDistributor eventDistributor(
|
||||||
TelegramConnectBot telegramConnect, List<EventHandler> eventProviders
|
TelegramConnectBot telegramConnect, List<EventHandler> eventProviders
|
||||||
) {
|
) {
|
||||||
@ -145,6 +134,7 @@ public class TelegramBotAutoconfiguration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
@ConditionalOnBean(value = {UnitPointerService.class, StorylineRepository.class})
|
||||||
public StorylineService<Mail> storylineService(
|
public StorylineService<Mail> storylineService(
|
||||||
UnitPointerService unitPointerService,
|
UnitPointerService unitPointerService,
|
||||||
StorylineRepository storylineRepository,
|
StorylineRepository storylineRepository,
|
||||||
|
@ -9,27 +9,34 @@ import dev.struchkov.godfather.simple.data.repository.impl.PersonSettingLocalRep
|
|||||||
import dev.struchkov.godfather.simple.data.repository.impl.StorylineMapRepository;
|
import dev.struchkov.godfather.simple.data.repository.impl.StorylineMapRepository;
|
||||||
import dev.struchkov.godfather.simple.data.repository.impl.UnitPointLocalRepository;
|
import dev.struchkov.godfather.simple.data.repository.impl.UnitPointLocalRepository;
|
||||||
import dev.struchkov.godfather.telegram.simple.context.repository.SenderRepository;
|
import dev.struchkov.godfather.telegram.simple.context.repository.SenderRepository;
|
||||||
|
import dev.struchkov.godfather.telegram.simple.core.TelegramConnectBot;
|
||||||
import dev.struchkov.godfather.telegram.simple.core.service.SenderMapRepository;
|
import dev.struchkov.godfather.telegram.simple.core.service.SenderMapRepository;
|
||||||
|
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
|
@AutoConfigureAfter(TelegramBotPropertyConfiguration.class)
|
||||||
public class TelegramBotDataConfiguration {
|
public class TelegramBotDataConfiguration {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
@ConditionalOnBean(TelegramConnectBot.class)
|
||||||
@ConditionalOnMissingBean(UnitPointerRepository.class)
|
@ConditionalOnMissingBean(UnitPointerRepository.class)
|
||||||
public UnitPointerRepository unitPointerRepository() {
|
public UnitPointerRepository unitPointerRepository() {
|
||||||
return new UnitPointLocalRepository();
|
return new UnitPointLocalRepository();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
@ConditionalOnBean(TelegramConnectBot.class)
|
||||||
@ConditionalOnMissingBean(PersonSettingRepository.class)
|
@ConditionalOnMissingBean(PersonSettingRepository.class)
|
||||||
public PersonSettingRepository personSettingRepository() {
|
public PersonSettingRepository personSettingRepository() {
|
||||||
return new PersonSettingLocalRepository();
|
return new PersonSettingLocalRepository();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
@ConditionalOnBean(TelegramConnectBot.class)
|
||||||
@ConditionalOnMissingBean(StorylineRepository.class)
|
@ConditionalOnMissingBean(StorylineRepository.class)
|
||||||
public StorylineRepository storylineRepository() {
|
public StorylineRepository storylineRepository() {
|
||||||
return new StorylineMapRepository();
|
return new StorylineMapRepository();
|
||||||
@ -42,6 +49,7 @@ public class TelegramBotDataConfiguration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
@ConditionalOnBean(TelegramConnectBot.class)
|
||||||
public StorylineContext storylineContext() {
|
public StorylineContext storylineContext() {
|
||||||
return new StorylineContextMapImpl();
|
return new StorylineContextMapImpl();
|
||||||
}
|
}
|
||||||
|
@ -2,12 +2,15 @@ package dev.struchkov.godfather.telegram.starter.config;
|
|||||||
|
|
||||||
import dev.struchkov.godfather.telegram.domain.config.ProxyConfig;
|
import dev.struchkov.godfather.telegram.domain.config.ProxyConfig;
|
||||||
import dev.struchkov.godfather.telegram.domain.config.TelegramBotConfig;
|
import dev.struchkov.godfather.telegram.domain.config.TelegramBotConfig;
|
||||||
|
import dev.struchkov.godfather.telegram.main.core.TelegramDefaultConnect;
|
||||||
|
import dev.struchkov.godfather.telegram.simple.core.TelegramConnectBot;
|
||||||
import dev.struchkov.godfather.telegram.starter.property.TelegramBotAutoresponderProperty;
|
import dev.struchkov.godfather.telegram.starter.property.TelegramBotAutoresponderProperty;
|
||||||
import org.springframework.beans.factory.ObjectProvider;
|
import org.springframework.beans.factory.ObjectProvider;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.context.annotation.Primary;
|
||||||
|
|
||||||
import static dev.struchkov.haiti.utils.Checker.checkNotNull;
|
import static dev.struchkov.haiti.utils.Checker.checkNotNull;
|
||||||
|
|
||||||
@ -43,4 +46,17 @@ public class TelegramBotPropertyConfiguration {
|
|||||||
return new TelegramBotAutoresponderProperty();
|
return new TelegramBotAutoresponderProperty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
@Primary
|
||||||
|
@ConditionalOnProperty(prefix = "telegram.bot", name = "username")
|
||||||
|
public TelegramConnectBot telegramConnectBot(TelegramBotConfig telegramConfig) {
|
||||||
|
return new TelegramConnectBot(telegramConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
@ConditionalOnProperty(prefix = "telegram.bot", name = "token")
|
||||||
|
public TelegramDefaultConnect telegramDefaultConnect(TelegramBotConfig telegramConfig) {
|
||||||
|
return new TelegramDefaultConnect(telegramConfig);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user