📄 applicationlistener.java
字号:
package net.java.workeffort.webapp.support;import javax.servlet.ServletContext;import javax.servlet.ServletContextEvent;import javax.servlet.ServletContextListener;import net.java.workeffort.service.IListOfValuesService;import net.java.workeffort.webapp.security.RoleManager;import org.apache.commons.logging.Log;import org.apache.commons.logging.LogFactory;import org.springframework.web.context.ContextLoaderListener;import org.springframework.web.context.WebApplicationContext;import org.springframework.web.context.support.WebApplicationContextUtils;/** * The application Listener. This is configured in the web.xml file. It * initializes the spring context, initializes the security roles for the * application and primes the list of values data. * @author Antony Joseph */public class ApplicationListener extends ContextLoaderListener implements ServletContextListener { private static final Log logger = LogFactory.getLog(ApplicationListener.class); public void contextInitialized(ServletContextEvent sce) { if (logger.isInfoEnabled()) { logger.info("Initializing context"); } // initialize the spring context super.contextInitialized(sce); // initialize the application. initializeApplication(sce.getServletContext()); } public void initializeApplication(ServletContext servletContext) { WebApplicationContext wac = WebApplicationContextUtils .getRequiredWebApplicationContext(servletContext); // load all roles and corresponding permissions RoleManager roleManager = (RoleManager) wac.getBean("roleManager"); roleManager.initialize(); // Store the list of values service in application scope. IListOfValuesService lovService = (IListOfValuesService) wac .getBean("listOfValuesService"); primeListOfValues(lovService); logger.info("Application initialization successful."); } /** * Even if we don't prime the list of values, the system will work because * the caching scheme will cache the lovs as they are accessed. * @param lovService The lov service */ private void primeListOfValues(IListOfValuesService lovService) { lovService.getCachedRequirementTypeLov(); lovService.getCachedWorkTypeLov(); lovService.getCachedWorkStatusLov(); lovService.getCachedWorkPurposeTypeLov(); lovService.getCachedWorkAssociationTypeLov(); lovService.getCachedWorkRoleLov(); lovService.getCachedWorkFxdastAsgnStatusLov(); lovService.getCachedPartTypeLov(); lovService.getCachedFixedAssetTypeLov(); lovService.getCachedSkillTypeLov(); lovService.getCachedDeliverableTypeLov(); lovService.getCachedPartStatusLov(); lovService.getCachedPartyTypeLov(); lovService.getCachedFacilityTypeLov(); lovService.getCachedTargetTypeLov(); lovService.getCachedRateTypeLov(); lovService.getCachedCurrencyLov(); lovService.getCachedYesNoLov(); lovService.getCachedTimesheetApprovalLov(); lovService.getCachedDeliverableLov(); lovService.getCachedFixedAssetLov(); lovService.getCachedProductLov(); lovService.getCachedFacilityLov(); lovService.getCachedSkillLov(); lovService.getCachedRoleLov(); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -