package com.hsit.common.spring;
import org.springframework.beans.factory.access.BeanFactoryReference;
import org.springframework.beans.factory.access.SingletonBeanFactoryLocator;
import org.springframework.beans.factory.access.BeanFactoryLocator;
import org.apache.commons.logging.LogFactory;
import org.apache.commons.logging.Log;
public class AppContextManager {
private AppContextManager() {
}
private static AppBeanFactory m_appBeanFactory = null;
/**
* 根据BeanName获得对应的类工厂[不通过PlugIn方法实现] 更新日志:<br>
* 日期 作者 内容<br>
* =================================================================<br>
* 2004-08-26 黄建德<br>
* ①创建WEB-INF/classes/下beanRefFactory.xml<br>
* ②beanRefFactory.xml配置相关Context文件 <bean id="beanFactory" class=...><br>
* ③web.xml配置路径为WEB-INF/classes/... <br>
* ④struts-config.xml文件去掉[注释]相关PlugIn<br>
* <plug-in className=" com.hsit.common.spring.InitAppContext "/>
* =================================================================<br>
*
* @param beanName
* String Bean配置体系的ID名如<bean id="beanCompany" ...>
* @return Object 根据BeanName获得对应的类工厂
*/
public static Object getBean(String beanName) {
BeanFactoryLocator bfLocator = SingletonBeanFactoryLocator.getInstance();
BeanFactoryReference bf = bfLocator.useBeanFactory("beanFactory");
return bf.getFactory().getBean(beanName);
}
public static void setBeanFactory(AppBeanFactory appBeanFactory) {
m_appBeanFactory = appBeanFactory;
}
public static AppBeanFactory getBeanFactory() {
return m_appBeanFactory;
}
}
posted on 2006-04-22 20:24
LORD BLOG 阅读(383)
评论(0) 编辑 收藏 所属分类:
J2EE