package kr.xit.core.spring.util;

import kr.xit.biz.ens.service.IEnsBatchExtractService;
import kr.xit.core.biz.batch.service.IBatchCmmService;
import kr.xit.core.spring.config.support.ApplicationContextProvider;
import kr.xit.core.support.slack.SlackWebhookPush;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.springframework.context.ApplicationContext;

/**
 * <pre>
 * description : Get Bean Object
 *               Filter / Interceptor 등에서 Bean 사용시 필요
 *               (Bean으로 등록되는 클래스 내에서만 @Autowired / @Resource 등이 동작)
 * packageName : kr.xit.core.spring.util
 * fileName    : BatchSpringUtils
 * author      : julim
 * date        : 2023-04-28
 * ======================================================================
 * 변경일         변경자        변경 내용
 * ----------------------------------------------------------------------
 * 2023-04-28    julim       최초 생성
 *
 * </pre>
 * @see ApplicationContextProvider
 */
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class BatchSpringUtils {

	public static ApplicationContext getApplicationContext() {
		return ApplicationContextProvider.getApplicationContext();
	}
	
	public static boolean containsBean(String beanName) {
		return getApplicationContext().containsBean(beanName);
	}
	
	public static Object getBean(String beanName) {
		return getApplicationContext().getBean(beanName);
	}
	
	public static Object getBean(Class<?> clazz) {
		return getApplicationContext().getBean(clazz);
	}

	public static IBatchCmmService getBatchCmmService(){
		return (IBatchCmmService)getBean(IBatchCmmService.class);
	}

	public static IEnsBatchExtractService getEnsBatchExtractService(){
		return (IEnsBatchExtractService)getBean(IEnsBatchExtractService.class);
	}

	public static SlackWebhookPush getSlackWebhookPush(){
		return (SlackWebhookPush)getBean(SlackWebhookPush.class);
	}
}
