package cn.estsh.i3plus.core.apiservice.thread;

import cn.estsh.i3plus.core.api.iservice.busi.IPersonnelService;
import cn.estsh.i3plus.core.api.iservice.busi.ISysMessageService;
import cn.estsh.i3plus.icloud.core.sdk.ICorePersonnelCloud;
import cn.estsh.i3plus.platform.common.util.CommonConstWords;
import cn.estsh.impp.framework.boot.thread.BaseThread;
import cn.estsh.impp.framework.boot.thread.ImppThreadPool;
import cn.estsh.impp.framework.boot.util.ServletContextUtil;
import cn.estsh.impp.framework.boot.util.SpringContextsUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

/**
 * @Description : 多线程执行案例
 * @Reference :
 * @Author : alwaysfrin
 * @CreateDate : 2019-01-14 15:26
 * @Modify:
 **/
public class CoreDemoThread extends BaseThread {

    private static final Logger LOGGER = LoggerFactory.getLogger(CoreDemoThread.class);

    private String param;

    public CoreDemoThread(String param){
        this.param = param;
        IPersonnelService personnelService = (IPersonnelService) SpringContextsUtil.getBean(IPersonnelService.class);
        LOGGER.info("spring容器获取服务：{}" + personnelService);

        WebApplicationContext webAppContext = WebApplicationContextUtils.getWebApplicationContext(ServletContextUtil.getServletContext());
        ISysMessageService sysMessageService = webAppContext.getBean(ISysMessageService.class);
        LOGGER.info("servlet容器获取服务：{}" + sysMessageService);
    }

    @Override
    public boolean doRun() {
        //处理业务逻辑
        System.out.println("线程执行：获取参数" + param);
        return true;
    }

    //使用方式
    public static void main(String[] args){
        ImppThreadPool.getThreadExcutorService().execute(new CoreDemoThread("thread param"));
    }
}
