本文整理汇总了Java中org.springframework.web.context.support.WebApplicationContextUtils类的典型用法代码示例。如果您正苦于以下问题:Java WebApplicationContextUtils类的具体用法?Java WebApplicationContextUtils怎么用?Java WebApplicationContextUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WebApplicationContextUtils类属于org.springframework.web.context.support包,在下文中一共展示了WebApplicationContextUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import org.springframework.web.context.support.WebApplicationContextUtils; //导入依赖的package包/类
@Override
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws Exception {
WebApplicationContext ctx = WebApplicationContextUtils
.getWebApplicationContext(getServlet().getServletContext());
UserManagementService userManagementService = (UserManagementService) ctx.getBean("userManagementService");
// check if user needs to get his shared two-factor authorization secret
User loggedInUser = userManagementService.getUserByLogin(request.getRemoteUser());
if (loggedInUser.isTwoFactorAuthenticationEnabled() && loggedInUser.getTwoFactorAuthenticationSecret() == null) {
GoogleAuthenticator gAuth = new GoogleAuthenticator();
final GoogleAuthenticatorKey key = gAuth.createCredentials();
String sharedSecret = key.getKey();
loggedInUser.setTwoFactorAuthenticationSecret(sharedSecret);
userManagementService.saveUser(loggedInUser);
request.setAttribute("sharedSecret", sharedSecret);
String QRCode = GoogleAuthenticatorQRGenerator.getOtpAuthURL(null, "LAMS account: " + loggedInUser.getLogin(), key);
request.setAttribute("QRCode", QRCode);
}
return mapping.findForward("secret");
}
示例2: getBeanFactory
import org.springframework.web.context.support.WebApplicationContextUtils; //导入依赖的package包/类
/**
* @return A found BeanFactory configuration
*/
private BeanFactory getBeanFactory()
{
// If someone has set a resource name then we need to load that.
if (configLocation != null && configLocation.length > 0)
{
log.info("Spring BeanFactory via ClassPathXmlApplicationContext using " + configLocation.length + "configLocations.");
return new ClassPathXmlApplicationContext(configLocation);
}
ServletContext srvCtx = WebContextFactory.get().getServletContext();
HttpServletRequest request = WebContextFactory.get().getHttpServletRequest();
if (request != null)
{
return RequestContextUtils.getWebApplicationContext(request, srvCtx);
}
else
{
return WebApplicationContextUtils.getWebApplicationContext(srvCtx);
}
}
示例3: createApplicationContext
import org.springframework.web.context.support.WebApplicationContextUtils; //导入依赖的package包/类
@Override
protected ApplicationContext createApplicationContext(String uri) throws MalformedURLException {
Resource resource = Utils.resourceFromString(uri);
LOG.debug("Using " + resource + " from " + uri);
try {
return new ResourceXmlApplicationContext(resource) {
@Override
protected ConfigurableEnvironment createEnvironment() {
return new ReversePropertySourcesStandardServletEnvironment();
}
@Override
protected void initPropertySources() {
WebApplicationContextUtils.initServletPropertySources(getEnvironment().getPropertySources(),
ServletContextHolder.getServletContext());
}
};
} catch (FatalBeanException errorToLog) {
LOG.error("Failed to load: " + resource + ", reason: " + errorToLog.getLocalizedMessage(), errorToLog);
throw errorToLog;
}
}
示例4: contextInitialized
import org.springframework.web.context.support.WebApplicationContextUtils; //导入依赖的package包/类
@Override
public void contextInitialized(ServletContextEvent event) {
String serviceName = event.getServletContext().getInitParameter("appName");
System.setProperty("serviceName", serviceName == null ? "undefined" : serviceName);
super.contextInitialized(event);
WebApplicationContext applicationContext = WebApplicationContextUtils.getRequiredWebApplicationContext(event.getServletContext());
SpringInstanceProvider provider = new SpringInstanceProvider(applicationContext);
InstanceFactory.setInstanceProvider(provider);
}
示例5: getUserManagementService
import org.springframework.web.context.support.WebApplicationContextUtils; //导入依赖的package包/类
private IUserManagementService getUserManagementService() {
if (EmailUserAction.userManagementService == null) {
WebApplicationContext ctx = WebApplicationContextUtils
.getRequiredWebApplicationContext(getServlet().getServletContext());
EmailUserAction.userManagementService = (IUserManagementService) ctx.getBean("userManagementService");
}
return EmailUserAction.userManagementService;
}
示例6: getUserManagementService
import org.springframework.web.context.support.WebApplicationContextUtils; //导入依赖的package包/类
private IUserManagementService getUserManagementService() {
if (userManagementService == null) {
WebApplicationContext ctx = WebApplicationContextUtils
.getRequiredWebApplicationContext(getServlet().getServletContext());
userManagementService = (IUserManagementService) ctx.getBean("userManagementService");
}
return userManagementService;
}
示例7: getMonitoringService
import org.springframework.web.context.support.WebApplicationContextUtils; //导入依赖的package包/类
private IMonitoringService getMonitoringService() {
if (AuthoringAction.monitoringService == null) {
WebApplicationContext ctx = WebApplicationContextUtils
.getRequiredWebApplicationContext(getServlet().getServletContext());
AuthoringAction.monitoringService = (IMonitoringService) ctx.getBean("monitoringService");
}
return AuthoringAction.monitoringService;
}
示例8: init
import org.springframework.web.context.support.WebApplicationContextUtils; //导入依赖的package包/类
@Override
public void init() throws ServletException
{
super.init();
ApplicationContext context = WebApplicationContextUtils.getRequiredWebApplicationContext(getServletContext());
container = (RuntimeContainer)context.getBean("publicapi.container");
apiAssistant = (ApiAssistant) context.getBean("apiAssistant");
}
示例9: getGroupUserDAO
import org.springframework.web.context.support.WebApplicationContextUtils; //导入依赖的package包/类
private IGroupUserDAO getGroupUserDAO() {
if (HomeAction.groupUserDAO == null) {
WebApplicationContext ctx = WebApplicationContextUtils
.getRequiredWebApplicationContext(getServlet().getServletContext());
HomeAction.groupUserDAO = (IGroupUserDAO) ctx.getBean("groupUserDAO");
}
return HomeAction.groupUserDAO;
}
示例10: getToolService
import org.springframework.web.context.support.WebApplicationContextUtils; //导入依赖的package包/类
public ILamsToolService getToolService() {
if (AuthoringAction.toolService == null) {
WebApplicationContext wac = WebApplicationContextUtils
.getRequiredWebApplicationContext(getServlet().getServletContext());
AuthoringAction.toolService = (ILamsToolService) wac.getBean(AuthoringConstants.TOOL_SERVICE_BEAN_NAME);
}
return AuthoringAction.toolService;
}
示例11: getSecurityService
import org.springframework.web.context.support.WebApplicationContextUtils; //导入依赖的package包/类
private ISecurityService getSecurityService() {
if (LessonConditionsAction.securityService == null) {
WebApplicationContext webContext = WebApplicationContextUtils
.getRequiredWebApplicationContext(getServlet().getServletContext());
LessonConditionsAction.securityService = (ISecurityService) webContext.getBean("securityService");
}
return LessonConditionsAction.securityService;
}
示例12: authentication
import org.springframework.web.context.support.WebApplicationContextUtils; //导入依赖的package包/类
private UsernamePasswordAuthenticationToken authentication(ServletContext servletContext) {
ApplicationContext context = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
UserDetailsService userDetailsService = userDetailsService(context);
UserDetails userDetails = userDetailsService.loadUserByUsername(this.username);
return new UsernamePasswordAuthenticationToken(
userDetails, userDetails.getPassword(), userDetails.getAuthorities());
}
示例13: getLearningDesignService
import org.springframework.web.context.support.WebApplicationContextUtils; //导入依赖的package包/类
private ILearningDesignService getLearningDesignService() {
if (HomeAction.learningDesignService == null) {
WebApplicationContext ctx = WebApplicationContextUtils
.getRequiredWebApplicationContext(getServlet().getServletContext());
HomeAction.learningDesignService = (ILearningDesignService) ctx.getBean("learningDesignService");
}
return HomeAction.learningDesignService;
}
示例14: unspecified
import org.springframework.web.context.support.WebApplicationContextUtils; //导入依赖的package包/类
@Override
public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws Exception {
HttpSession ss = SessionManager.getSession();
UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER);
long toolSessionId = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_SESSION_ID);
WebApplicationContext wac = WebApplicationContextUtils
.getRequiredWebApplicationContext(getServlet().getServletContext());
ILearnerService learnerService = (ILearnerService) wac.getBean("learnerService");
String finishURL = learnerService.completeToolSession(toolSessionId, user.getUserID().longValue());
return new RedirectingActionForward(finishURL);
}
示例15: contextInitialized
import org.springframework.web.context.support.WebApplicationContextUtils; //导入依赖的package包/类
@Override
public void contextInitialized(final ServletContextEvent event) {
final ServletContext servletContext = event.getServletContext();
final ApplicationContext ctx =
WebApplicationContextUtils.getWebApplicationContext(servletContext);
LOGGER.info("[{}] has loaded the CAS servlet application context: {}",
servletContext.getServerInfo(), ctx);
}