?? servicelocatorbean.java
字號(hào):
package login.view.bean;
import javax.servlet.ServletContext;
import login.model.service.UserService;
import login.view.servicelocator.ServiceLocator;
import login.view.util.FacesUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
public class ServiceLocatorBean implements ServiceLocator {
// the logger for this class
private static final Log log = LogFactory.getLog(ServiceLocatorBean.class);
// the user service bean name
private static final String USER_SERVICE_BEAN_NAME = "userService";
// the Spring application context
private ApplicationContext appContext;
// the cached user service
private UserService userService;
public ServiceLocatorBean() {
ServletContext context = FacesUtils.getServletContext();
this.appContext = WebApplicationContextUtils.getRequiredWebApplicationContext(context);
this.userService = (UserService) this
.lookupService(USER_SERVICE_BEAN_NAME);
this.log.info("Service locator bean is initialized");
}
public UserService getUserService() {
return this.userService;
}
public Object lookupService(String serviceBeanName) {
return appContext.getBean(serviceBeanName);
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -