package com.horizon.boot;

import com.horizon.utils.ServletContextUtil;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration;
import org.springframework.boot.autoconfigure.web.MultipartAutoConfiguration;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.boot.web.servlet.ServletContextInitializer;
import org.springframework.context.annotation.ImportResource;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;

/**
 * 引擎启动入口
 *
 * @author malei
 */
@SpringBootApplication(exclude = {
        DataSourceAutoConfiguration.class,
        DataSourceTransactionManagerAutoConfiguration.class,
        MultipartAutoConfiguration.class

})
@ServletComponentScan
@ImportResource(locations = {
        "classpath:workflow-conf/workflow-context.xml",
        "classpath:workflow-conf/workflow-web.xml"
})
public class HorizonWorkflowBootApplication implements ServletContextInitializer {

    public static void main(String[] args) {
        SpringApplication.run(HorizonWorkflowBootApplication.class, args);
    }

    @Override
    public void onStartup(ServletContext servletContext) throws ServletException {
        ServletContextUtil.setServletContext(servletContext);
    }
}
