⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 springbeanfactory.java

📁 本文论述了一个前台笔记本销售系统的开发过程
💻 JAVA
字号:
package com.set.appframe.business;

import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.set.appframe.exception.SystemException;

public class SpringBeanFactory {
	protected static AbstractApplicationContext ctx = null;

	private static SpringBeanFactory instance = null;

	private SpringBeanFactory() {
		init();
	}

	private void init() {
		if (null == ctx) {
			String paths[] = { "classpath*:applicationContext-*.xml" };

			ctx = new ClassPathXmlApplicationContext(paths);
		}
	}

	public static SpringBeanFactory getInstance() {
		if (null == instance) {
			instance = new SpringBeanFactory();
		}
		return instance;
	}

	public Object getBean(String name) throws SystemException {
		Object bean = null;
		try {
			bean = ctx.getBean(name);
		} catch (Exception ex) {
			throw new SystemException("error.springconfig");
		}
		return bean;

	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -