📄 startuplistener.java
字号:
package org.appfuse.webapp.listener;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.web.context.ContextLoaderListener;
import org.springframework.web.context.support.WebApplicationContextUtils;
import org.appfuse.Constants;
import org.appfuse.util.ServiceFactory;
//import com.aspire.demo.service.TestService;
/**
* StartupListener class used to initialize Spring bean config.
*
*
*/
public class StartupListener extends ContextLoaderListener
implements ServletContextListener {
private static final Log log = LogFactory.getLog(StartupListener.class);
public void contextInitialized(ServletContextEvent event) {
if (log.isDebugEnabled()) {
log.debug("initializing context...");
}
// call Spring's context ContextLoaderListener to initialize
// all the context files specified in web.xml
super.contextInitialized(event);
ServletContext context = event.getServletContext();
// Orion starts Servlets before Listeners, so check if the config
// object already exists
// Map config = (HashMap) context.getAttribute(Constants.CONFIG);
//
// if (config == null) {
// config = new HashMap();
// }
// context.setAttribute(Constants.CONFIG, config);
//
setupContext(context);
}
public static void setupContext(ServletContext context) {
ApplicationContext ctx =
WebApplicationContextUtils.getRequiredWebApplicationContext(context);
// Initial ServiceFactory
ServiceFactory.init(ctx);
// TestService service = (TestService) ctx.getBean("testService");
if (log.isDebugEnabled()) {
log.debug("drop-down initialization complete [OK]");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -