博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
SpringContext
阅读量:6572 次
发布时间:2019-06-24

本文共 2584 字,大约阅读时间需要 8 分钟。

hot3.png

import java.util.Locale;import org.springframework.beans.BeansException;import org.springframework.beans.factory.NoSuchBeanDefinitionException;import org.springframework.context.ApplicationContext;import org.springframework.context.ApplicationContextAware;import org.springframework.context.MessageSourceResolvable;import org.springframework.context.NoSuchMessageException;import cn.mysteel.core.ServiceException;public class SpringContext implements ApplicationContextAware{	private static ApplicationContext applicationContext;	public static ApplicationContext getApplicationContext()	{		return applicationContext;	}	@SuppressWarnings("static-access")	public void setApplicationContext(ApplicationContext applicationContext) throws BeansException	{		this.applicationContext = applicationContext;	}	public static Object getBean(String name) throws BeansException	{		return applicationContext.getBean(name);	}	public static 
T getBean(Class
requiredType) throws BeansException { return applicationContext.getBean(requiredType); } public static
T getBean(String name, Class
requiredType) throws BeansException { return applicationContext.getBean(name, requiredType); } public static boolean containsBean(String name) { return applicationContext.containsBean(name); } public static boolean isSingleton(String name) throws NoSuchBeanDefinitionException { return applicationContext.isSingleton(name); } public static Class
getType(String name) throws NoSuchBeanDefinitionException { return applicationContext.getType(name); } public static String[] getAliases(String name) throws NoSuchBeanDefinitionException { return applicationContext.getAliases(name); } public static String getMessage(String code, Object[] args, String defaultMessage, Locale locale) { return applicationContext.getMessage(code, args, defaultMessage, locale); } public static String getMessage(String code, Object[] args, Locale locale) throws NoSuchMessageException { return applicationContext.getMessage(code, args, locale); } public static String getMessage(MessageSourceResolvable resolvable, Locale locale) throws NoSuchMessageException { return applicationContext.getMessage(resolvable, locale); } public static String getMessage(ServiceException serviceException) { return getMessage(String.valueOf(serviceException.getMessageCode()), serviceException.getMessageParams(), "No such message code [" + serviceException.getMessageCode() + "]", Locale.getDefault()); }}

 

转载于:https://my.oschina.net/u/2253438/blog/1553416

你可能感兴趣的文章
存储过程和SQL语句比较及存储过程在C#中调用方法
查看>>
hihocoder 1014 Trie树
查看>>
ADO.NET笔记——使用DataSet返回数据
查看>>
【机器学习】--关联规则算法从初识到应用
查看>>
windows 下nginx php安装
查看>>
MOTO XT702添加开机音乐
查看>>
Codeforces Round #565 (Div. 3) C. Lose it!
查看>>
Python脚本日志系统
查看>>
Spring异常——BeanNotOfRequiredTypeException
查看>>
B0BO TFS 安装指南(转载)
查看>>
gulp常用命令
查看>>
TCP(Socket基础编程)
查看>>
RowSet的使用
查看>>
表单提交中的input、button、submit的区别
查看>>
每日一记--cookie
查看>>
约瑟夫环
查看>>
S5:桥接模式 Bridge
查看>>
线程池-Executors
查看>>
WPF and Silverlight 学习笔记(十二):WPF Panel内容模型、Decorator内容模型及其他...
查看>>
FLUSH TABLES WITH READ LOCK 和 LOCK TABLES比较
查看>>