
package com.tmerclub.cloud.im;

import com.tmerclub.cloud.im.socket.app.UserOnlineWebSocketServer;
import com.tmerclub.cloud.im.socket.app.UserWebSocketServer;
import com.tmerclub.cloud.im.socket.multishop.ShopOnlineWebSocketServer;
import com.tmerclub.cloud.im.socket.multishop.ShopWebSocketServer;
import com.tmerclub.cloud.im.socket.platform.SysOnlineWebSocketServer;
import com.tmerclub.cloud.im.socket.platform.SysWebSocketServer;
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.security.servlet.UserDetailsServiceAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.ConfigurableApplicationContext;

/**
 * @author tmerclub
 * @date 2020/6/24
 */
@SpringBootApplication(scanBasePackages = "com.tmerclub.cloud", exclude = UserDetailsServiceAutoConfiguration.class)
@EnableDubbo(scanBasePackages = "com.tmerclub.cloud.**.feign")
public class ImApplication extends SpringBootServletInitializer {

    public static void main(String[] args) {
        ConfigurableApplicationContext applicationContext = SpringApplication.run(ImApplication.class, args);
        UserWebSocketServer.setApplicationContext(applicationContext);
        ShopWebSocketServer.setApplicationContext(applicationContext);
        SysWebSocketServer.setApplicationContext(applicationContext);
        UserOnlineWebSocketServer.setApplicationContext(applicationContext);
        ShopOnlineWebSocketServer.setApplicationContext(applicationContext);
        SysOnlineWebSocketServer.setApplicationContext(applicationContext);
        SysOnlineWebSocketServer.setApplicationContext(applicationContext);
    }

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        return builder.sources(ImApplication.class);
    }

}
