當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。