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

📄 servicemanager.java

📁 struts+spring+hibernate自创框架
💻 JAVA
字号:
package com.pegasus.framework.service;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.context.ApplicationContext;

import com.pegasus.framework.web.ApplicationContextFactory;

/**
 * The Class ServiceManager.
 */
public class ServiceManager {

	/** The Constant logger. */
	protected static final Log logger = LogFactory.getLog(ServiceManager.class);

	private static ApplicationContext applicationContext;

	/**
	 * .
	 */
	private ServiceManager() {
	}

	/**
	 * @param key
	 *            service key
	 * @return Service interface
	 */
	public static Object getService(String key) {
		logger.info("getAttribute service with name[" + key + "]");
		init();
		return applicationContext.getBean(key);
	}

	/**
	 * 
	 */
	private static void init() {
		if (applicationContext == null)
			applicationContext = ApplicationContextFactory.getApplicationContext();
	}

	/**
	 * @param key
	 *            service key
	 * @return Service interface
	 */
	public static boolean containsService(String key) {
		init();
		return applicationContext.containsBean(key);
	}

}

⌨️ 快捷键说明

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