package com.njzscloud.common.localizer.config;

import com.njzscloud.common.localizer.mqtt.MqttMsgHandlers;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableConfigurationProperties({LocalizerProperties.class})
@ConditionalOnProperty(prefix = "localizer", name = "enabled", havingValue = "true")
public class LocalizerAutoConfiguration {

    @Bean(initMethod = "init", destroyMethod = "destroy")
    public LocalizerInitializer localizerInitializer(LocalizerProperties properties) {
        return new LocalizerInitializer(properties);
    }

    @Bean
    public MqttMsgHandlers mqttMsgHandlers() {
        return new MqttMsgHandlers();
    }
}
