package com.cim.idm.mwmsextend.transport;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

import com.cim.idm.framework.util.service.ServiceUtil;
import com.cim.idm.mwmsextend.transport.management.TransportCommandDetailService;
import com.cim.idm.mwmsextend.transport.management.TransportCommandService;
import com.cim.idm.mwmsextend.transport.management.impl.TransportCommandDetailServiceImpl;
import com.cim.idm.mwmsextend.transport.management.impl.TransportCommandServiceImpl;
@Component
public class TransportServiceProxy implements ApplicationContextAware{
	
	private Log log = LogFactory.getLog(this.getClass());
	private static ApplicationContext ac;
	
	@Override
	public void setApplicationContext(ApplicationContext context)
			throws BeansException {
		ac = context;
		log.debug(this.getClass().getSimpleName() +" Success Get ApplicationContext");
	}
	
	public static TransportCommandService getTransportCommandService()
	{
		try
		{
			return (TransportCommandService) ac.getBean(ServiceUtil.formatSimpleClassName(TransportCommandService.class));
		}
		catch(Exception e)
		{
			return ac.getBean(TransportCommandServiceImpl.class);
		}
	}
	
	public static TransportCommandDetailService getTransportCommandDetailService()
	{
		try
		{
			return (TransportCommandDetailService)  ac.getBean(ServiceUtil.formatSimpleClassName(TransportCommandDetailService.class));
		}
		catch(Exception e)
		{
			return  ac.getBean(TransportCommandDetailServiceImpl.class);
		}
	}
}
