spring 注入bean,bean里有个方法,在启动tomcat时不清楚为什么被执行了
spring的xml是这样配置的<beanclass="com.jbfs.base.aware.ResourceRegister"/>bean的java类代码为:publ...
spring的xml是这样配置的<bean class="com.jbfs.base.aware.ResourceRegister" />
bean的java类代码为:
public class ResourceRegister implements ApplicationContextAware
{
@Resource
private ServletContext servletContext;
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException
{
ResourceService resService = applicationContext.getBean("resService", ResourceService.class);
//初始化Globals中的servletContext
Globals.getInstance().WEB_SERVLET_CONTEXT = servletContext;
//加载码表
resService.loadCodeTable(servletContext);
//加载权限配置信息
resService.loadPrivilegeUrls(servletContext);
//加载sql配置信息
resService.loadSqlConfig(servletContext);
}
setApplicationContext这个方法在容器初期花被调用了,是因为继承ApplicationContextAware的原因吗 展开
bean的java类代码为:
public class ResourceRegister implements ApplicationContextAware
{
@Resource
private ServletContext servletContext;
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException
{
ResourceService resService = applicationContext.getBean("resService", ResourceService.class);
//初始化Globals中的servletContext
Globals.getInstance().WEB_SERVLET_CONTEXT = servletContext;
//加载码表
resService.loadCodeTable(servletContext);
//加载权限配置信息
resService.loadPrivilegeUrls(servletContext);
//加载sql配置信息
resService.loadSqlConfig(servletContext);
}
setApplicationContext这个方法在容器初期花被调用了,是因为继承ApplicationContextAware的原因吗 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询