Java 类org.springframework.web.context.support.WebApplicationContextUtils 实例源码

项目:lams    文件:TwoFactorAuthenticationAction.java   
@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");
   }
项目:parabuild-ci    文件:SpringCreator.java   
/**
 * @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);
    }
}
项目:hevelian-activemq    文件:WebXBeanBrokerFactory.java   
@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;
    }
}
项目:azeroth    文件:ContextLoaderListener.java   
@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);
}
项目:lams    文件:EmailUserAction.java   
private IUserManagementService getUserManagementService() {
if (EmailUserAction.userManagementService == null) {
    WebApplicationContext ctx = WebApplicationContextUtils
        .getRequiredWebApplicationContext(getServlet().getServletContext());
    EmailUserAction.userManagementService = (IUserManagementService) ctx.getBean("userManagementService");
}
return EmailUserAction.userManagementService;
   }
项目:lams    文件:PortraitBatchUploadAction.java   
private IUserManagementService getUserManagementService() {
if (userManagementService == null) {
    WebApplicationContext ctx = WebApplicationContextUtils
        .getRequiredWebApplicationContext(getServlet().getServletContext());
    userManagementService = (IUserManagementService) ctx.getBean("userManagementService");
}
return userManagementService;
   }
项目:lams    文件:AuthoringAction.java   
private IMonitoringService getMonitoringService() {
if (AuthoringAction.monitoringService == null) {
    WebApplicationContext ctx = WebApplicationContextUtils
        .getRequiredWebApplicationContext(getServlet().getServletContext());
    AuthoringAction.monitoringService = (IMonitoringService) ctx.getBean("monitoringService");
}
return AuthoringAction.monitoringService;
   }
项目:alfresco-remote-api    文件:PublicApiWebScriptServlet.java   
@Override
public void init() throws ServletException
{
    super.init();

    ApplicationContext context = WebApplicationContextUtils.getRequiredWebApplicationContext(getServletContext());
    container = (RuntimeContainer)context.getBean("publicapi.container");
    apiAssistant = (ApiAssistant) context.getBean("apiAssistant");
}
项目:lams    文件:HomeAction.java   
private IGroupUserDAO getGroupUserDAO() {
if (HomeAction.groupUserDAO == null) {
    WebApplicationContext ctx = WebApplicationContextUtils
        .getRequiredWebApplicationContext(getServlet().getServletContext());
    HomeAction.groupUserDAO = (IGroupUserDAO) ctx.getBean("groupUserDAO");
}
return HomeAction.groupUserDAO;
   }
项目:lams    文件:AuthoringAction.java   
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;
   }
项目:lams    文件:LessonConditionsAction.java   
private ISecurityService getSecurityService() {
if (LessonConditionsAction.securityService == null) {
    WebApplicationContext webContext = WebApplicationContextUtils
        .getRequiredWebApplicationContext(getServlet().getServletContext());
    LessonConditionsAction.securityService = (ISecurityService) webContext.getBean("securityService");
}

return LessonConditionsAction.securityService;
   }
项目:nixmash-blog    文件:SecurityRequestPostProcessors.java   
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());
}
项目:lams    文件:HomeAction.java   
private ILearningDesignService getLearningDesignService() {
if (HomeAction.learningDesignService == null) {
    WebApplicationContext ctx = WebApplicationContextUtils
        .getRequiredWebApplicationContext(getServlet().getServletContext());
    HomeAction.learningDesignService = (ILearningDesignService) ctx.getBean("learningDesignService");
}
return HomeAction.learningDesignService;
   }
项目:lams    文件:LearningAction.java   
@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);
   }
项目:cas-server-4.2.1    文件:CasEnvironmentContextListener.java   
@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);
}
项目:sdudoc    文件:AutoLoginFilter.java   
@Override
public void init(FilterConfig filterConfig) throws ServletException {
    log.info("AutoLoginFilter Init");
    //使用以下方式来完成userService的注入
    ServletContext context = filterConfig.getServletContext();
    ApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(context);
    userService = (UserService) ctx.getBean("userService");
}
项目:lams    文件:CleanupPreviewLessonsAction.java   
private IMonitoringService getMonitoringService() {
if (monitoringService == null) {
    WebApplicationContext ctx = WebApplicationContextUtils
        .getRequiredWebApplicationContext(getServlet().getServletContext());
    monitoringService = (IMonitoringService) ctx.getBean("monitoringService");
}
return monitoringService;
   }
项目:lams    文件:GradebookServlet.java   
private IntegrationService getIntegrationService() {
if (integrationService == null) {
    integrationService = (IntegrationService) WebApplicationContextUtils
        .getRequiredWebApplicationContext(getServletContext()).getBean("integrationService");
}
return integrationService;
   }
项目:lams    文件:EmailUserAction.java   
private MessageService getMessageService() {
if (EmailUserAction.messageService == null) {
    WebApplicationContext ctx = WebApplicationContextUtils
        .getRequiredWebApplicationContext(getServlet().getServletContext());
    EmailUserAction.messageService = (MessageService) ctx
        .getBean(CentralConstants.CENTRAL_MESSAGE_SERVICE_BEAN_NAME);

}
return EmailUserAction.messageService;
   }
项目:lams    文件:TutorialAction.java   
private IUserManagementService getService() {
if (TutorialAction.service == null) {
    WebApplicationContext ctx = WebApplicationContextUtils
        .getRequiredWebApplicationContext(getServlet().getServletContext());
    TutorialAction.service = (IUserManagementService) ctx.getBean("userManagementService");
}
return TutorialAction.service;
   }
项目:lams    文件:GradebookLearningAction.java   
private ISecurityService getSecurityService() {
if (GradebookLearningAction.securityService == null) {
    WebApplicationContext ctx = WebApplicationContextUtils
        .getRequiredWebApplicationContext(getServlet().getServletContext());
    GradebookLearningAction.securityService = (ISecurityService) ctx.getBean("securityService");
}
return GradebookLearningAction.securityService;
   }
项目:lams    文件:GradebookMonitoringAction.java   
private IUserManagementService getUserService() {
if (GradebookMonitoringAction.userService == null) {
    WebApplicationContext ctx = WebApplicationContextUtils
        .getRequiredWebApplicationContext(getServlet().getServletContext());
    GradebookMonitoringAction.userService = (IUserManagementService) ctx.getBean("userManagementService");
}
return GradebookMonitoringAction.userService;
   }
项目:lams    文件:HomeAction.java   
private ILessonService getLessonService() {
if (HomeAction.lessonService == null) {
    WebApplicationContext ctx = WebApplicationContextUtils
        .getRequiredWebApplicationContext(getServlet().getServletContext());
    HomeAction.lessonService = (ILessonService) ctx.getBean("lessonService");
}
return HomeAction.lessonService;
   }
项目:lams    文件:GradebookMonitoringAction.java   
private ISecurityService getSecurityService() {
if (GradebookMonitoringAction.securityService == null) {
    WebApplicationContext ctx = WebApplicationContextUtils
        .getRequiredWebApplicationContext(getServlet().getServletContext());
    GradebookMonitoringAction.securityService = (ISecurityService) ctx.getBean("securityService");
}
return GradebookMonitoringAction.securityService;
   }
项目:lams    文件:GradebookAction.java   
private IUserManagementService getUserService() {
if (GradebookAction.userService == null) {
    WebApplicationContext ctx = WebApplicationContextUtils
        .getRequiredWebApplicationContext(getServlet().getServletContext());
    GradebookAction.userService = (IUserManagementService) ctx.getBean("userManagementService");
}
return GradebookAction.userService;
   }
项目:lams    文件:GradebookAction.java   
private ILessonService getLessonService() {
if (GradebookAction.lessonService == null) {
    WebApplicationContext ctx = WebApplicationContextUtils
        .getRequiredWebApplicationContext(getServlet().getServletContext());
    GradebookAction.lessonService = (ILessonService) ctx.getBean("lessonService");
}
return GradebookAction.lessonService;
   }
项目:lams    文件:LDAPAuthenticator.java   
public LDAPAuthenticator(IUserManagementService userManagementService) {
if (LDAPAuthenticator.userManagementService == null) {
    LDAPAuthenticator.userManagementService = userManagementService;
}
if (LDAPAuthenticator.ldapService == null) {
    WebApplicationContext ctx = WebApplicationContextUtils
        .getWebApplicationContext(SessionManager.getServletContext());
    LDAPAuthenticator.ldapService = (ILdapService) ctx.getBean("ldapService");
}
   }
项目:lams    文件:CompleteActivityAction.java   
private IntegrationService getIntegrationService() {
if (CompleteActivityAction.integrationService == null) {
    CompleteActivityAction.integrationService = (IntegrationService) WebApplicationContextUtils
        .getRequiredWebApplicationContext(getServlet().getServletContext()).getBean("integrationService");
}
return CompleteActivityAction.integrationService;
   }
项目:lams    文件:LamsAuthoringFinishAction.java   
/**
    * Get AuditService bean
    */
   private IAuditService getAuditService() {
if (auditService == null) {
    WebApplicationContext ctx = WebApplicationContextUtils
        .getRequiredWebApplicationContext(getServlet().getServletContext());
    auditService = (IAuditService) ctx.getBean("auditService");
}
return auditService;
   }
项目:lams    文件:LessonManagerServlet.java   
/**
    * Initialization of the servlet. <br>
    *
    * @throws ServletException
    *             if an error occured
    */
   @Override
   public void init() throws ServletException {

integrationService = (IntegrationService) WebApplicationContextUtils
    .getRequiredWebApplicationContext(getServletContext()).getBean("integrationService");

monitoringService = (IMonitoringService) WebApplicationContextUtils
    .getRequiredWebApplicationContext(getServletContext()).getBean("monitoringService");

lessonService = (ILessonService) WebApplicationContextUtils
    .getRequiredWebApplicationContext(getServletContext()).getBean("lessonService");

exportService = (IExportToolContentService) WebApplicationContextUtils
    .getRequiredWebApplicationContext(getServletContext()).getBean("exportToolContentService");

toolService = (ILamsCoreToolService) WebApplicationContextUtils
    .getRequiredWebApplicationContext(getServletContext()).getBean("lamsCoreToolService");

gradebookService = (IGradebookService) WebApplicationContextUtils
    .getRequiredWebApplicationContext(getServletContext()).getBean("gradebookService");

userManagementService = (IUserManagementService) WebApplicationContextUtils
    .getRequiredWebApplicationContext(getServletContext()).getBean("userManagementService");

securityService = (ISecurityService) WebApplicationContextUtils
    .getRequiredWebApplicationContext(getServletContext()).getBean("securityService");
   }
项目:lams    文件:EditLessonIntroAction.java   
private ILessonService getLessonService() {
if (lessonService == null) {
    WebApplicationContext ctx = WebApplicationContextUtils
        .getRequiredWebApplicationContext(getServlet().getServletContext());
    lessonService = (ILessonService) ctx.getBean("lessonService");
}
return lessonService;
   }
项目:lams    文件:EmailNotificationsAction.java   
private IEventNotificationService getEventNotificationService() {
if (eventNotificationService == null) {
    WebApplicationContext ctx = WebApplicationContextUtils
        .getRequiredWebApplicationContext(getServlet().getServletContext());
    eventNotificationService = (IEventNotificationService) ctx.getBean("eventNotificationService");
}
return eventNotificationService;
   }
项目:lams    文件:EmailNotificationsAction.java   
private IUserManagementService getUserManagementService() {
if (userManagementService == null) {
    WebApplicationContext ctx = WebApplicationContextUtils
        .getRequiredWebApplicationContext(getServlet().getServletContext());
    userManagementService = (IUserManagementService) ctx.getBean("userManagementService");
}
return userManagementService;
   }
项目:lams    文件:EmailNotificationsAction.java   
private IAuditService getAuditService() {
if (auditService == null) {
    WebApplicationContext ctx = WebApplicationContextUtils
        .getRequiredWebApplicationContext(getServlet().getServletContext());
    auditService = (IAuditService) ctx.getBean("auditService");
}
return auditService;
   }
项目:lams    文件:OrganisationGroupAction.java   
private IUserManagementService getUserManagementService() {
if (OrganisationGroupAction.userManagementService == null) {
    WebApplicationContext ctx = WebApplicationContextUtils
        .getRequiredWebApplicationContext(getServlet().getServletContext());
    OrganisationGroupAction.userManagementService = (IUserManagementService) ctx
        .getBean("userManagementService");
}
return OrganisationGroupAction.userManagementService;
   }
项目:lams    文件:OpenSessionInViewFilter.java   
/**
 * Look up the SessionFactory that this filter should use.
 * <p>The default implementation looks for a bean with the specified name
 * in Spring's root application context.
 * @return the SessionFactory to use
 * @see #getSessionFactoryBeanName
 */
protected SessionFactory lookupSessionFactory() {
    if (logger.isDebugEnabled()) {
        logger.debug("Using SessionFactory '" + getSessionFactoryBeanName() + "' for OpenSessionInViewFilter");
    }
    WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(getServletContext());
    return wac.getBean(getSessionFactoryBeanName(), SessionFactory.class);
}
项目:lams    文件:UserManagementService.java   
private IAuditService getAuditService() {
if (UserManagementService.auditService == null) {
    WebApplicationContext ctx = WebApplicationContextUtils
        .getWebApplicationContext(SessionManager.getServletContext());
    UserManagementService.auditService = (IAuditService) ctx.getBean("auditService");
}
return UserManagementService.auditService;
   }
项目:lams    文件:MonitoringAction.java   
private ILessonService getLessonService() {
if (MonitoringAction.lessonService == null) {
    WebApplicationContext ctx = WebApplicationContextUtils
        .getRequiredWebApplicationContext(getServlet().getServletContext());
    MonitoringAction.lessonService = (ILessonService) ctx.getBean("lessonService");
}
return MonitoringAction.lessonService;
   }
项目:lams    文件:PresenceWebsocketServer.java   
private static IPresenceChatService getPresenceChatService() {
if (PresenceWebsocketServer.presenceChatService == null) {
    WebApplicationContext ctx = WebApplicationContextUtils
        .getWebApplicationContext(SessionManager.getServletContext());
    PresenceWebsocketServer.presenceChatService = (IPresenceChatService) ctx.getBean("presenceChatService");
}
return PresenceWebsocketServer.presenceChatService;
   }
项目:lams    文件:ToolContentListAction.java   
private DataSource getDataSource() {
if (ToolContentListAction.dataSource == null) {
    WebApplicationContext ctx = WebApplicationContextUtils
        .getRequiredWebApplicationContext(getServlet().getServletContext());
    ToolContentListAction.dataSource = (DataSource) ctx.getBean("dataSource");
}
return ToolContentListAction.dataSource;
   }