Create a static ApplicationContextProvider class to hold the ApplicationContext:
package com.abc;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
public class ApplicationContextProvider implements ApplicationContextAware {
private static ApplicationContext applicationContext = null;
public static ApplicationContext getApplicationContext() {
return applicationContext;
}
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
// Assign the ApplicationContext into a static variable
this.applicationContext = applicationContext;
}
}
Initialize the new bean in applicationContext.xml:
<bean id=”applicationContextProvider” class=”com.abc.ApplicationContextProvider”></bean”>
Get applicationContext:
ApplicationContext ctx = ApplicationContextProvider.getApplicationContext();
this.setDispatchManager((DispatchManager)ctx.getBean("dispatchManager"));
This blogger is recording some code samples,technical skill of java,.Net,javascript, css, html for myself use. All articles are coming from my own experience and my collections which are from internet world. If you find any material have copy right issue please leave a comment to me. I will delete it immediately. These articles are writing in English or Chinese. Hope these information can help other technical guys. Thanks for reading.
Subscribe to:
Post Comments (Atom)
-
1. Change the tile of web.xml from <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "ht...
-
1.创建文件夹 //using System.IO; Directory.CreateDirectory(%%1); 2.创建文件 //using System.IO; File.Create(%%1); 3.删除文件 //using System.IO; Fil...
-
There is an JSF 2.1 bug which cause Tomcat 7 problem. You will get below error if you are using JSF 2.1 under Tocmcat 7. java.lang.Insta...
No comments:
Post a Comment