package com.inspect.metadata;

import com.inspect.common.security.annotation.EnableCustomConfig;
import com.inspect.common.security.annotation.EnableRyFeignClients;
import com.inspect.base.swagger.annotation.EnableCustomSwagger2;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.BeanNameGenerator;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.scheduling.annotation.EnableAsync;

@EnableCustomConfig
@EnableCustomSwagger2
@EnableRyFeignClients
@SpringBootApplication(
        exclude = {DataSourceAutoConfiguration.class}
)
@ComponentScan({"com.inspect.*"})
@EnableAsync
public class InspectMetadataApplication {
    private final static Logger log = LoggerFactory.getLogger(InspectMetadataApplication.class);

    public static class CustomGenerator implements BeanNameGenerator {
        @Override
        public String generateBeanName(BeanDefinition definition, BeanDefinitionRegistry registry) {
            return definition.getBeanClassName();
        }
    }

    public static void main(String[] args) {
        SpringApplication.run(InspectMetadataApplication.class, args);
//        SpringApplicationBuilder builder = new SpringApplicationBuilder(InspectMetadataApplication.class)
//                .beanNameGenerator(new CustomGenerator());
//        builder.run(args);
        log.info("\n<===☆  METADATA MODULE ☆ ===>  \n .-------.       ____     __        \n |  _ _   \\      \\   \\   /  /    \n | ( ' )  |       \\  _. /  '       \n |(_ o _) /        _( )_ .'         \n | (_,_).' __  ___(_ o _)'          \n |  |\\ \\  |  ||   |(_,_)'         \n |  | \\ `'   /|   `-'  /           \n |  |  \\    /  \\      /           \n ''-'   `'-'    `-..-'              ");
    }
}
