分类:
2008-09-09 17:11:33
功能: 方便获取Spring IoC容器中的Bean,调用方法:
getBean(String name)
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;
public class SpringtUtil {
private static SpringtUtil instance = new SpringtUtil();
private static ApplicationContext context;
public static final String spring_context_configfile = "spring.context.configfile";
public static Object getBean(String name) {
return getContext().getBean(name);
}
public static ApplicationContext getContext() {
return SpringtUtil.getInstance().context;
}
public static SpringtUtil getInstance()
{
return instance;
}
private SpringtUtil()
{
try
{
[1]