package com.cim.idm.utils;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class SpringBeanFactoryUtils implements ApplicationContextAware {

	 private static ApplicationContext applicationContext;    
	 
	 static {
		 applicationContext = new ClassPathXmlApplicationContext(
		 new String[] { "META-INF/spring/WebServiceERPImpl.service.xml"});
		     }
	 
	    /**  
	     * 此方法可以把ApplicationContext对象inject到当前类中作为一个静态成员变量。  
	     * @param applicationContext ApplicationContext 对象.  
	     * @throws BeansException  
	     * @author wangdf 
	     */    

	       
	    /** 
	     * 获取ApplicationContext 
	     * @return 
	     * @author wangdf 
	     */  
	    public static ApplicationContext getApplicationContext(){  
	        return applicationContext;  
	    }  
	       
	    /**  
	     * 这是一个便利的方法，帮助我们快速得到一个BEAN  
	     * @param beanName bean的名字  
	     * @return 返回一个bean对象  
	     * @author wangdf 
	     */    
	    public static Object getBean( String beanName ) {    
	        return applicationContext.getBean( beanName );    
	    }

		
		public void setApplicationContext(ApplicationContext arg0)
				throws BeansException {			
		}    

}
