当前位置: 首页>>代码示例>>Java>>正文


Java WebApplicationContextUtils类代码示例

本文整理汇总了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");
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:27,代码来源:TwoFactorAuthenticationAction.java

示例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);
    }
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:25,代码来源:SpringCreator.java

示例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;
	}
}
 
开发者ID:Hevelian,项目名称:hevelian-activemq,代码行数:23,代码来源:WebXBeanBrokerFactory.java

示例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);
}
 
开发者ID:warlock-china,项目名称:azeroth,代码行数:10,代码来源:ContextLoaderListener.java

示例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;
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:9,代码来源:EmailUserAction.java

示例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;
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:9,代码来源:PortraitBatchUploadAction.java

示例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;
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:9,代码来源:AuthoringAction.java

示例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");
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:10,代码来源:PublicApiWebScriptServlet.java

示例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;
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:9,代码来源:HomeAction.java

示例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;
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:9,代码来源:AuthoringAction.java

示例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;
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:LessonConditionsAction.java

示例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());
}
 
开发者ID:mintster,项目名称:nixmash-blog,代码行数:8,代码来源:SecurityRequestPostProcessors.java

示例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;
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:9,代码来源:HomeAction.java

示例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);
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:14,代码来源:LearningAction.java

示例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);
}
 
开发者ID:yuweijun,项目名称:cas-server-4.2.1,代码行数:10,代码来源:CasEnvironmentContextListener.java


注:本文中的org.springframework.web.context.support.WebApplicationContextUtils类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。