Example usage for org.springframework.web.context.support WebApplicationContextUtils getWebApplicationContext

List of usage examples for org.springframework.web.context.support WebApplicationContextUtils getWebApplicationContext

Introduction

In this page you can find the example usage for org.springframework.web.context.support WebApplicationContextUtils getWebApplicationContext.

Prototype

@Nullable
public static WebApplicationContext getWebApplicationContext(ServletContext sc) 

Source Link

Document

Find the root WebApplicationContext for this web app, typically loaded via org.springframework.web.context.ContextLoaderListener .

Usage

From source file:tds.tdsadmin.session.TdsAdminSessionListener.java

public void sessionCreated(HttpSessionEvent event) {
    PropertiesBean props = WebApplicationContextUtils
            .getWebApplicationContext(event.getSession().getServletContext()).getBean(PropertiesBean.class);
    int tdsadminTimeout = props.getTdsadminTimeout();
    event.getSession().setMaxInactiveInterval(tdsadminTimeout * 60);
    _logger.info(String.format("TDS Admin session timeout set as %s minutes.", tdsadminTimeout));
}

From source file:com.arcbees.project.server.util.SpringServiceLocator.java

public Object getInstance(Class<?> clazz) {
    ApplicationContext context = WebApplicationContextUtils
            .getWebApplicationContext(RequestFactoryServlet.getThreadLocalServletContext());
    return context.getBean(clazz);
}

From source file:cs544.wamp_blog_engine.filters.MyFilter.java

@Override
public void init(FilterConfig filterConfig) throws ServletException {
    WebApplicationContext context = WebApplicationContextUtils
            .getWebApplicationContext(filterConfig.getServletContext());
    userService = context.getBean("userService", IUserService.class);
}

From source file:com.ovalsearch.listener.OvalsearchContextListener.java

@Override
public void contextInitialized(ServletContextEvent sce) {
    LOG.info("Context Initialization event called");
    WebApplicationContext context = WebApplicationContextUtils
            .getWebApplicationContext(sce.getServletContext());
    final IStartupService startupService = context.getBean(IStartupService.class);
    try {//from  w ww  .  j a v a  2s.c  om
        LOG.info("Loading Application Context");
        startupService.loadContext();
    } catch (Exception e) {
        LOG.error("Error while initializing application:", e);
    }
}

From source file:com.ewcms.web.pubsub.ProgressSender.java

private WebPublishFacable getPublishFac(ServletContext context) {

    ApplicationContext applicationContext = WebApplicationContextUtils.getWebApplicationContext(context);
    Assert.notNull(applicationContext, "Can not get spring's context");

    WebPublishFacable fac = applicationContext.getBean("webPublishFac", WebPublishFacable.class);
    Assert.notNull(fac, "Can not get webPublishFacBean");

    return fac;/*from   w w  w . j  av a 2 s  .c o m*/
}

From source file:com.xhsoft.framework.common.listener.ApplicationContextListener.java

public void contextInitialized(ServletContextEvent event) {
    try {/* www . j ava 2s. co  m*/
        ApplicationContext applicationContext = WebApplicationContextUtils
                .getWebApplicationContext(event.getServletContext());
        ServletContext sc = event.getServletContext();
        String appName = sc.getServletContextName();
        logger.info("[" + appName + "] init context ...");
        AppServiceHelper.setApplicationContext(applicationContext);
        logger.info(" - Put Spring Context to AppServiceHelper");
        String facility = sc.getInitParameter("facility");
        AppContext.addParam(AppContext.FACILITY, facility);
        logger.info(" - Put FACILITY[" + facility + "] to AppContext");
        logger.info("[" + appName + "] init context[done]");
    } catch (Exception e) {
        logger.error("error detail:", e);
    }
}

From source file:org.jmesa.web.JspPageSpringWebContext.java

@Override
public ApplicationContext getApplicationContext() {

    return WebApplicationContextUtils.getWebApplicationContext(getPageContext().getServletContext());
}

From source file:org.teavm.flavour.example.server.JerseyInitializer.java

public JerseyInitializer() {
    WebApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(servletContext);
    register(context.getBean(ProductFacade.class));
}

From source file:com.oak_yoga_studio.filters.MyFilter.java

@Override
public void init(FilterConfig filterConfig) throws ServletException {
    WebApplicationContext context = WebApplicationContextUtils
            .getWebApplicationContext(filterConfig.getServletContext());
    userService = context.getBean("customerService", ICustomerService.class);
}

From source file:org.LexGrid.LexBIG.caCore.web.util.LexEVSJSPUtils.java

public LexEVSJSPUtils(ServletContext context) {
    super(context);
    WebApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(context);
    dbConnector = (DBConnector) ctx.getBean("DBConnector");

}