sp启动后获取ApplicationContext 对象的方法

 


import java.util.Locale;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Service;

@Service
public class SpringUtil implements ApplicationContextAware {
public static ApplicationContext appContext;
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
appContext = applicationContext;
}
public static String getMessage(String key, Object... params) {
return getMessage(key, params, Locale.ENGLISH);
}
public static String getMessage(String key,Object[] params,Locale locale) {
return appContext.getMessage(key, params, locale);
}

http://bbs.22cg.com/forum-113-1.html
http://bbs.22cg.com/forum-111-1.html
tcc55.com
70ky.com
http://flash.22cg.com/baoshijieyulecheng/
http://flash.22cg.com/yingfengguojiyulecheng/


public static Object getBean(String serviceName){
Object obj = new Object();
try {
obj = SpringUtil.appContext.getBean(serviceName);
} catch (BeansException e) {
e.printStackTrace();
return null;
}
return obj;
}
}

sp启动后获取ApplicationContext 对象的方法,布布扣,bubuko.com

sp启动后获取ApplicationContext 对象的方法

上一篇:[公告][重要]Senparc.Weixin v4.9.0 & Senparc.Weixin.MP v14.3.104更新说明


下一篇:解决Android中AsyncTask的多线程阻塞问题