[Spring MVC]ApplicationContextAwareインタフェースを実現するコード

Javaコード
public class SpringContextUtil implements ApplicationContextAware {
private static ApplicationContext applicationContext;
/**
* ApplicationContextAwareの実現
*
* @param applicationContext
*/
public void setApplicationContext(ApplicationContext applicationContext) {
SpringContextUtil.applicationContext = applicationContext;
}
/**
* @return ApplicationContext
*/
public static ApplicationContext getApplicationContext() {
return applicationContext;
}
/**
* オブジェクト取得
*
* @param name
* @return Object
* @throws BeansException
*/
public static Object getBean(String name) throws BeansException {
return applicationContext.getBean(name);
}
}

Java

Posted by arkgame