Java Code Examples for org.springframework.web.context.WebApplicationContext

The following are top voted examples for showing how to use org.springframework.web.context.WebApplicationContext. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: dss-demonstrations   File: AppInitializer.java   View source code 6 votes vote down vote up
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
	WebApplicationContext context = getContext();
	servletContext.addListener(new ContextLoaderListener(context));
	servletContext.addFilter("characterEncodingFilter", new CharacterEncodingFilter("UTF-8"));

	DispatcherServlet dispatcherServlet = new DispatcherServlet(context);
	dispatcherServlet.setThrowExceptionIfNoHandlerFound(true);

	ServletRegistration.Dynamic dispatcher = servletContext.addServlet("Dispatcher", dispatcherServlet);
	dispatcher.setLoadOnStartup(1);
	dispatcher.addMapping("/*");

	CXFServlet cxf = new CXFServlet();
	BusFactory.setDefaultBus(cxf.getBus());
	ServletRegistration.Dynamic cxfServlet = servletContext.addServlet("CXFServlet", cxf);
	cxfServlet.setLoadOnStartup(1);
	cxfServlet.addMapping("/services/*");

	servletContext.addFilter("springSecurityFilterChain", new DelegatingFilterProxy("springSecurityFilterChain")).addMappingForUrlPatterns(null, false,
			"/*");

	servletContext.getSessionCookieConfig().setSecure(cookieSecure);
}
 
Example 2
Project: e-identification-tupas-idp-public   File: ShibbolethExtAuthnHandler.java   View source code 6 votes vote down vote up
public void init(ServletConfig config) throws ServletException {
    try {
        WebApplicationContext springContext = WebApplicationContextUtils.getRequiredWebApplicationContext(config.getServletContext());
        final AutowireCapableBeanFactory beanFactory = springContext.getAutowireCapableBeanFactory();
        beanFactory.autowireBean(this);
    }
    catch (Exception e) {
        logger.error("Error initializing ShibbolethExtAuthnHandler", e);
    }
}
 
Example 3
Project: lams   File: SpringBeanAutowiringSupport.java   View source code 6 votes vote down vote up
/**
 * Process {@code @Autowired} injection for the given target object,
 * based on the current web application context.
 * <p>Intended for use as a delegate.
 * @param target the target object to process
 * @see org.springframework.web.context.ContextLoader#getCurrentWebApplicationContext()
 */
public static void processInjectionBasedOnCurrentContext(Object target) {
	Assert.notNull(target, "Target object must not be null");
	WebApplicationContext cc = ContextLoader.getCurrentWebApplicationContext();
	if (cc != null) {
		AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor();
		bpp.setBeanFactory(cc.getAutowireCapableBeanFactory());
		bpp.processInjection(target);
	}
	else {
		if (logger.isDebugEnabled()) {
			logger.debug("Current WebApplicationContext is not available for processing of " +
					ClassUtils.getShortName(target.getClass()) + ": " +
					"Make sure this class gets constructed in a Spring web application. Proceeding without injection.");
		}
	}
}
 
Example 4
Project: lams   File: EventNotificationService.java   View source code 6 votes vote down vote up
/**
    * See {@link IEventNotificationService#trigger(String, String, Long, String, String)
    */
   private void trigger(Event event, String subject, String message) {
final String subjectToSend = subject == null ? event.getSubject() : subject;
final String messageToSend = message == null ? event.getMessage() : message;

// create a new thread to send the messages as it can take some time
new Thread(() -> {
    try {
	HibernateSessionManager.openSession();
	// use proxy bean instead of concrete implementation of service
	// otherwise there is no transaction for the new session
	WebApplicationContext ctx = WebApplicationContextUtils
		.getWebApplicationContext(SessionManager.getServletContext());
	IEventNotificationService eventNotificationService = (IEventNotificationService) ctx
		.getBean("eventNotificationService");
	eventNotificationService.triggerInternal(event, subjectToSend, messageToSend);
    } finally {
	HibernateSessionManager.closeSession();
    }
}).start();
   }
 
Example 5
Project: lams   File: DelegatingFilterProxy.java   View source code 6 votes vote down vote up
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain)
		throws ServletException, IOException {

	// Lazily initialize the delegate if necessary.
	Filter delegateToUse = this.delegate;
	if (delegateToUse == null) {
		synchronized (this.delegateMonitor) {
			if (this.delegate == null) {
				WebApplicationContext wac = findWebApplicationContext();
				if (wac == null) {
					throw new IllegalStateException("No WebApplicationContext found: no ContextLoaderListener registered?");
				}
				this.delegate = initDelegate(wac);
			}
			delegateToUse = this.delegate;
		}
	}

	// Let the delegate perform the actual doFilter operation.
	invokeDelegate(delegateToUse, request, response, filterChain);
}
 
Example 6
Project: spring-cloud-skipper   File: LocalSkipperResource.java   View source code 5 votes vote down vote up
@Override
protected void before() throws Throwable {

	final SpringApplicationBuilder builder = new SpringApplicationBuilder(LocalTestSkipperServer.class);

	if (this.configLocations  != null && this.configLocations.length > 0) {
		builder.properties(
			String.format("spring.config.location:%s", StringUtils.arrayToCommaDelimitedString(this.configLocations))
		);
	}

	if (this.configNames  != null && this.configNames.length > 0) {
		builder.properties(
			String.format("spring.config.name:%s", StringUtils.arrayToCommaDelimitedString(this.configNames))
		);
	}

	this.app = builder.build();



	configurableApplicationContext = app.run(
		new String[] { "--server.port=0" });

	Collection<Filter> filters = configurableApplicationContext.getBeansOfType(Filter.class).values();
	mockMvc = MockMvcBuilders.webAppContextSetup((WebApplicationContext) configurableApplicationContext)
			.addFilters(filters.toArray(new Filter[filters.size()])).build();
	skipperPort = configurableApplicationContext.getEnvironment().resolvePlaceholders("${server.port}");
}
 
Example 7
Project: lams   File: AuthoringAction.java   View source code 5 votes vote down vote up
private IForumService getForumManager() {
if (forumService == null) {
    WebApplicationContext wac = WebApplicationContextUtils
	    .getRequiredWebApplicationContext(getServlet().getServletContext());
    forumService = (IForumService) wac.getBean(ForumConstants.FORUM_SERVICE);
}
return forumService;
   }
 
Example 8
Project: lams   File: OrganisationGroupAction.java   View source code 5 votes vote down vote up
private ILessonService getLessonService() {
if (OrganisationGroupAction.lessonService == null) {
    WebApplicationContext ctx = WebApplicationContextUtils
	    .getRequiredWebApplicationContext(getServlet().getServletContext());
    OrganisationGroupAction.lessonService = (ILessonService) ctx.getBean("lessonService");
}
return OrganisationGroupAction.lessonService;
   }
 
Example 9
Project: lams   File: LearningAction.java   View source code 5 votes vote down vote up
@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);
   }
 
Example 10
Project: lams   File: HomeAction.java   View source code 5 votes vote down vote up
private IUserManagementService getUserManagementService() {
if (HomeAction.userManagementService == null) {
    WebApplicationContext ctx = WebApplicationContextUtils
	    .getRequiredWebApplicationContext(getServlet().getServletContext());
    HomeAction.userManagementService = (IUserManagementService) ctx.getBean("userManagementService");
}
return HomeAction.userManagementService;
   }
 
Example 11
Project: lams   File: HomeAction.java   View source code 5 votes vote down vote up
private ILearningDesignService getLearningDesignService() {
if (HomeAction.learningDesignService == null) {
    WebApplicationContext ctx = WebApplicationContextUtils
	    .getRequiredWebApplicationContext(getServlet().getServletContext());
    HomeAction.learningDesignService = (ILearningDesignService) ctx.getBean("learningDesignService");
}
return HomeAction.learningDesignService;
   }
 
Example 12
Project: lams   File: AuthoringAction.java   View source code 5 votes vote down vote up
private IUserManagementService getUserManagementService() {
if (AuthoringAction.userManagementService == null) {
    WebApplicationContext wac = WebApplicationContextUtils
	    .getRequiredWebApplicationContext(getServlet().getServletContext());
    AuthoringAction.userManagementService = (IUserManagementService) wac
	    .getBean(CentralConstants.USER_MANAGEMENT_SERVICE_BEAN_NAME);
}
return AuthoringAction.userManagementService;
   }
 
Example 13
Project: parabuild-ci   File: JettySpringLauncher.java   View source code 5 votes vote down vote up
/**
 * Sets up and runs server.
 * @param args
 */
public static void main(String[] args)
{
    final Server server = new Server();

    SelectChannelConnector connector = new SelectChannelConnector();
    connector.setPort(8080);
    server.addConnector(connector);

    Context htmlContext = new Context(server, "/", Context.SESSIONS);

    ResourceHandler htmlHandler = new ResourceHandler();
    htmlHandler.setResourceBase("web");
    htmlContext.setHandler(htmlHandler);

    Context servletContext = new Context(server, "/", Context.SESSIONS);

    GenericWebApplicationContext springContext = new GenericWebApplicationContext();
    springContext.setParent(new ClassPathXmlApplicationContext("org/getahead/dwrdemo/cli/spring.xml"));
    servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, springContext);

    ServletHolder holder = new ServletHolder(new DwrSpringServlet());
    holder.setInitParameter("pollAndCometEnabled", "true");
    holder.setInitParameter("debug", "true");
    servletContext.addServlet(holder, "/dwr/*");

    try
    {
        JettyShutdown.addShutdownHook(server);
        server.start();
        server.join();
    }
    catch (Exception ex)
    {
        ex.printStackTrace();
    }
}
 
Example 14
Project: lams   File: LearningWebUtil.java   View source code 5 votes vote down vote up
/**
    * Finds activity position within Learning Design and stores it as request attribute.
    */
   public static ActivityPositionDTO putActivityPositionInRequestByToolSessionId(Long toolSessionId,
    HttpServletRequest request, ServletContext context) {
WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(context);
ILearnerService learnerService = (ILearnerService) wac.getBean("learnerService");
if (learnerService == null) {
    LearningWebUtil.log.warn("Can not set activity position, no Learner service in servlet context.");
    return null;
}
ActivityPositionDTO positionDTO = learnerService.getActivityPositionByToolSessionId(toolSessionId);
if (positionDTO != null) {
    request.setAttribute(AttributeNames.ATTR_ACTIVITY_POSITION, positionDTO);
}
return positionDTO;
   }
 
Example 15
Project: lams   File: OpenSessionInViewFilter.java   View source code 5 votes vote down vote up
/**
 * 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);
}
 
Example 16
Project: holon-vaadin7   File: AbstractVaadinSpringTest.java   View source code 5 votes vote down vote up
public TestSpringVaadinServletService(VaadinServlet servlet, WebApplicationContext applicationContext)
		throws ServiceException {
	super(servlet, new DefaultDeploymentConfiguration(TestSpringVaadinServletService.class, new Properties()),
			"");
	this.appContext = applicationContext;
	init();
}
 
Example 17
Project: brkr   File: EmbeddedJetty.java   View source code 5 votes vote down vote up
private void startJetty(int port) throws Exception {
    Server server = new Server(port);
    WebApplicationContext webApplicationContext = createWebApplicationContext();
    ServletContextHandler handler = createHandlerWith(webApplicationContext);
    server.setHandler(handler);
    server.start();
    server.join();
}
 
Example 18
Project: brkr   File: EmbeddedJetty.java   View source code 5 votes vote down vote up
private ServletContextHandler createHandlerWith(WebApplicationContext webApplicationContext) {
    ServletContextHandler servletContextHandler = new ServletContextHandler();
    servletContextHandler.setContextPath(CONTEXT_PATH_RESPOND_TO_ALL_REQUESTS);
    ServletHolder dispatcherServletHolder = new ServletHolder(new DispatcherServlet(webApplicationContext));
    servletContextHandler.addServlet(dispatcherServletHolder, CONTEXT_PATH_RESPOND_TO_ALL_REQUESTS);
    return servletContextHandler;
}
 
Example 19
Project: xproject   File: ApplicationInitializeListener.java   View source code 5 votes vote down vote up
public void afterPropertiesSet() throws Exception {
	String mode = applicationContext instanceof WebApplicationContext ? "Java Servlet Mode" : "Java Application Mode";
       logger.info(String.format("application initializing start in %s", mode));
       logger.info("application initializing begin ...");
       if (!CollectionUtils.isEmpty(applicationInitializers)) {
           for (ApplicationInitializer applicationInitializer : applicationInitializers) {
           	applicationInitializer.initialize(applicationContext);
           }
       }
       logger.info("application initializing end ...");
}
 
Example 20
Project: lams   File: FindUserLessonsAction.java   View source code 5 votes vote down vote up
private IUserManagementService getUserManagementService() {
if (FindUserLessonsAction.userManagementService == null) {
    WebApplicationContext wac = WebApplicationContextUtils
	    .getRequiredWebApplicationContext(getServlet().getServletContext());
    FindUserLessonsAction.userManagementService = (IUserManagementService) wac
	    .getBean(CentralConstants.USER_MANAGEMENT_SERVICE_BEAN_NAME);
}
return FindUserLessonsAction.userManagementService;
   }
 
Example 21
Project: lams   File: LoginAsAction.java   View source code 5 votes vote down vote up
@Override
   public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
    HttpServletResponse response) throws Exception {

WebApplicationContext ctx = WebApplicationContextUtils
	.getRequiredWebApplicationContext(getServlet().getServletContext());
IUserManagementService service = (IUserManagementService) ctx.getBean("userManagementService");
MessageService messageService = (MessageService) ctx.getBean("centralMessageService");
String login = WebUtil.readStrParam(request, "login", false);

if (service.isUserSysAdmin()) {
    if ((login != null) && (login.trim().length() > 0)) {
	User user = service.getUserByLogin(login);
	if (user != null) {
	    // audit log when loginas
	    UserDTO sysadmin = (UserDTO) SessionManager.getSession().getAttribute(AttributeNames.USER);
	    IAuditService auditService = (IAuditService) ctx.getBean("auditService");
	    String[] args = new String[] { sysadmin.getLogin() + "(" + sysadmin.getUserID() + ")", login };
	    String message = messageService.getMessage("audit.admin.loginas", args);
	    auditService.log(CentralConstants.MODULE_NAME, message);

	    // login.jsp knows what to do with these
	    request.setAttribute("login", login);
	    String token = "#LAMS" + RandomPasswordGenerator.nextPassword(10);
	    request.setAttribute("password", token);
	    // notify the login module that the user has been authenticated correctly
	    UniversalLoginModule.setAuthenticationToken(token);
	    // redirect to login page
	    return (new ActionForward("/login.jsp?redirectURL=/lams/index.jsp"));
	}
    }
} else {
    request.setAttribute("errorName", "LoginAsAction");
    request.setAttribute("errorMessage", messageService.getMessage("error.authorisation"));
    return mapping.findForward("error");
}

return mapping.findForward("usersearch");
   }
 
Example 22
Project: keti   File: TestUtils.java   View source code 5 votes vote down vote up
public MockMvcContext createWACWithCustomGETRequestBuilder(final WebApplicationContext wac, final String subdomain,
        final String resourceURI) throws URISyntaxException {
    MockMvcContext result = new MockMvcContext();
    result.setBuilder(MockMvcRequestBuilders.get(new URI("http://" + subdomain + ".localhost/" + resourceURI))
            .accept(MediaType.APPLICATION_JSON));
    result.setMockMvc(MockMvcBuilders.webAppContextSetup(wac).defaultRequest(result.getBuilder()).build());
    return result;
}
 
Example 23
Project: JSiter   File: HTTPBasicAuthorizeAttribute.java   View source code 5 votes vote down vote up
@Override
public void init(FilterConfig fConfig) throws ServletException {
    ServletContext sc = fConfig.getServletContext();
    WebApplicationContext cxt = WebApplicationContextUtils.getWebApplicationContext(sc);

    if (cxt != null) {
        cookieUtil = cxt.getBean(CookieUtil.class);
        sessionUtil = cxt.getBean(SessionUtil.class);
    }
    System.out.println("init finished");

}
 
Example 24
Project: lams   File: EditLessonIntroAction.java   View source code 5 votes vote down vote up
private ILessonService getLessonService() {
if (lessonService == null) {
    WebApplicationContext ctx = WebApplicationContextUtils
	    .getRequiredWebApplicationContext(getServlet().getServletContext());
    lessonService = (ILessonService) ctx.getBean("lessonService");
}
return lessonService;
   }
 
Example 25
Project: lams   File: EmailUserAction.java   View source code 5 votes vote down vote up
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;
   }
 
Example 26
Project: lams   File: RepopulateProgressMarksServlet.java   View source code 5 votes vote down vote up
@Override
   public void init() throws ServletException {
WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(getServletContext());
RepopulateProgressMarksServlet.auditService = (IAuditService) ctx.getBean("auditService");
RepopulateProgressMarksServlet.lessonService = (ILessonService) ctx.getBean("lessonService");
RepopulateProgressMarksServlet.learnerService = (ICoreLearnerService) ctx.getBean("learnerService");
   }
 
Example 27
Project: lams   File: PedagogicalPlannerAction.java   View source code 5 votes vote down vote up
private IUserManagementService getUserManagementService() {
if (userManagementService == null) {
    WebApplicationContext ctx = WebApplicationContextUtils
	    .getRequiredWebApplicationContext(getServlet().getServletContext());
    userManagementService = (IUserManagementService) ctx
	    .getBean(CentralConstants.USER_MANAGEMENT_SERVICE_BEAN_NAME);
}
return userManagementService;
   }
 
Example 28
Project: lams   File: LanguageUtil.java   View source code 5 votes vote down vote up
private static IUserManagementService getService() {
if (LanguageUtil.service == null) {
    WebApplicationContext ctx = WebApplicationContextUtils
	    .getWebApplicationContext(SessionManager.getServletContext());
    LanguageUtil.service = (IUserManagementService) ctx.getBean("userManagementService");
}
return LanguageUtil.service;
   }
 
Example 29
Project: lams   File: RecalculateTotalMarksForLessonServlet.java   View source code 5 votes vote down vote up
@Override
   public void init() throws ServletException {
WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(getServletContext());
auditService = (IAuditService) ctx.getBean("auditService");
lessonService = (ILessonService) ctx.getBean("lessonService");
gradebookService = (IGradebookService) ctx.getBean("gradebookService");
   }
 
Example 30
Project: lams   File: GradebookLearningAction.java   View source code 5 votes vote down vote up
private IUserManagementService getUserService() {
if (GradebookLearningAction.userService == null) {
    WebApplicationContext ctx = WebApplicationContextUtils
	    .getRequiredWebApplicationContext(getServlet().getServletContext());
    GradebookLearningAction.userService = (IUserManagementService) ctx.getBean("userManagementService");
}
return GradebookLearningAction.userService;
   }
 
Example 31
Project: lams   File: GradebookLearningAction.java   View source code 5 votes vote down vote up
private ISecurityService getSecurityService() {
if (GradebookLearningAction.securityService == null) {
    WebApplicationContext ctx = WebApplicationContextUtils
	    .getRequiredWebApplicationContext(getServlet().getServletContext());
    GradebookLearningAction.securityService = (ISecurityService) ctx.getBean("securityService");
}
return GradebookLearningAction.securityService;
   }
 
Example 32
Project: lams   File: HomeAction.java   View source code 5 votes vote down vote up
private ILessonService getLessonService() {
if (HomeAction.lessonService == null) {
    WebApplicationContext ctx = WebApplicationContextUtils
	    .getRequiredWebApplicationContext(getServlet().getServletContext());
    HomeAction.lessonService = (ILessonService) ctx.getBean("lessonService");
}
return HomeAction.lessonService;
   }
 
Example 33
Project: lams   File: PedagogicalPlannerAction.java   View source code 5 votes vote down vote up
private IMonitoringService getMonitoringService() {
if (monitoringService == null) {
    WebApplicationContext ctx = WebApplicationContextUtils
	    .getRequiredWebApplicationContext(getServlet().getServletContext());
    monitoringService = (IMonitoringService) ctx.getBean(CentralConstants.MONITORING_SERVICE_BEAN_NAME);
}
return monitoringService;
   }
 
Example 34
Project: JSiter   File: InitialFilter.java   View source code 5 votes vote down vote up
@Override
public void init(FilterConfig fConfig) throws ServletException {
    ServletContext sc = fConfig.getServletContext();
    WebApplicationContext cxt = WebApplicationContextUtils.getWebApplicationContext(sc);
    if (cxt != null) {

    }
    System.out.println("init finished");
}
 
Example 35
Project: lams   File: GradebookAction.java   View source code 5 votes vote down vote up
private ILessonService getLessonService() {
if (GradebookAction.lessonService == null) {
    WebApplicationContext ctx = WebApplicationContextUtils
	    .getRequiredWebApplicationContext(getServlet().getServletContext());
    GradebookAction.lessonService = (ILessonService) ctx.getBean("lessonService");
}
return GradebookAction.lessonService;
   }
 
Example 36
Project: lams   File: RestServlet.java   View source code 5 votes vote down vote up
protected IToolDAO getToolDAO() {
if (RestServlet.toolDAO == null) {
    WebApplicationContext ctx = WebApplicationContextUtils
	    .getRequiredWebApplicationContext(getServletContext());
    RestServlet.toolDAO = (IToolDAO) ctx.getBean("toolDAO");
}
return RestServlet.toolDAO;
   }
 
Example 37
Project: lams   File: OrganisationGroupAction.java   View source code 5 votes vote down vote up
private IUserManagementService getUserManagementService() {
if (OrganisationGroupAction.userManagementService == null) {
    WebApplicationContext ctx = WebApplicationContextUtils
	    .getRequiredWebApplicationContext(getServlet().getServletContext());
    OrganisationGroupAction.userManagementService = (IUserManagementService) ctx
	    .getBean("userManagementService");
}
return OrganisationGroupAction.userManagementService;
   }
 
Example 38
Project: lams   File: ContextExposingHttpServletRequest.java   View source code 5 votes vote down vote up
/**
 * Create a new ContextExposingHttpServletRequest for the given request.
 * @param originalRequest the original HttpServletRequest
 * @param context the WebApplicationContext that this request runs in
 * @param exposedContextBeanNames the names of beans in the context which
 * are supposed to be exposed (if this is non-null, only the beans in this
 * Set are eligible for exposure as attributes)
 */
public ContextExposingHttpServletRequest(
		HttpServletRequest originalRequest, WebApplicationContext context, Set<String> exposedContextBeanNames) {

	super(originalRequest);
	Assert.notNull(context, "WebApplicationContext must not be null");
	this.webApplicationContext = context;
	this.exposedContextBeanNames = exposedContextBeanNames;
}
 
Example 39
Project: Spring-web-shop-project   File: SessionActionsListener.java   View source code 5 votes vote down vote up
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
    if (ApplicationProperties.FALSE_WHILE_RUNNING_DB_TESTS) {
        if (applicationContext instanceof WebApplicationContext)
            ((WebApplicationContext) applicationContext).getServletContext().addListener(this);
        else
            throw new RuntimeException("Must be inside a web application context");
    }
}
 
Example 40
Project: backbone   File: ApplicationInitializer.java   View source code 5 votes vote down vote up
@Override
protected WebApplicationContext createServletApplicationContext() {
    AnnotationConfigWebApplicationContext applicationContext = (AnnotationConfigWebApplicationContext) super.createServletApplicationContext();
    if (applicationContext != null)
        applicationContext.setDisplayName("DispatcherServlet WebMvcApplicationConfig");
    return applicationContext;
}