package com.dashitech;

import org.atmosphere.cpr.AtmosphereServlet;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ImportResource;
import org.springframework.context.annotation.PropertySource;
import org.springframework.core.Ordered;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;

import java.text.SimpleDateFormat;
import java.util.Date;

//import org.mybatis.spring.annotation.MapperScan;


@SpringBootApplication
@EnableAsync
@EnableScheduling
@PropertySource({"classpath:application-custom.properties", "application.properties"})
@ImportResource(locations = "classpath*:/application-context.xml")
//@Import({DynamicDataSourceRegister.class}) // 注册动态多数据源
//@MapperScan("com.dashitech.dao.mysqldb1")//将项目中对应的mapper类的路径加进来就可以了
public class Application {

    @Bean
    public ServletRegistrationBean camelWebSocketServlet() {
        ServletRegistrationBean bean = new ServletRegistrationBean(new AtmosphereServlet(), "/webSocket/*");
        bean.setName("phoneWebSocket");
        bean.setLoadOnStartup(0);
        bean.setOrder(Ordered.HIGHEST_PRECEDENCE);
        return bean;
    }

    public static void main(String[] args) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        System.out.println("hsmsV1-CallSocket>>>>>>>>>>>>>>>>>>startData"+sdf.format(new Date()));
        SpringApplication.run(Application.class, args);
    }

}
