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:org.callistasoftware.netcare.video.web.util.WebUtil.java

public static final WebApplicationContext getWebRequest(final ServletContext sc) {
    return WebApplicationContextUtils.getWebApplicationContext(sc);
}

From source file:com.baidu.stqa.signet.web.common.spring.SpringInit.java

public void contextInitialized(ServletContextEvent event) {
    context = WebApplicationContextUtils.getWebApplicationContext(event.getServletContext());
}

From source file:com.baidu.terminator.manager.common.SpringInit.java

public void contextInitialized(ServletContextEvent event) {
    context = WebApplicationContextUtils.getWebApplicationContext(event.getServletContext());

    LinkControlService linkControlService = (LinkControlService) context.getBean("linkControlService");
    linkControlService.recoveryLink();/*w  w w.  j a v  a 2 s. c  o  m*/
}

From source file:com.laxser.blitz.web.var.PrivateVar.java

/**
 * ??WebSpring./*from   w  w w .  j  av  a  2  s . co m*/
 * <p>
 * Spring??module.
 * 
 * @return
 */
public static WebApplicationContext getRootWebApplicationContext(ServletContext servletContext) {
    return WebApplicationContextUtils.getWebApplicationContext(servletContext);
}

From source file:com.moreopen.monitor.console.SpringContextLoaderListener.java

@Override
public void contextInitialized(ServletContextEvent event) {
    super.contextInitialized(event);
    BeanLocator.setApplicationContext(//from w ww.j  av  a  2s.c o m
            WebApplicationContextUtils.getWebApplicationContext(event.getServletContext()));
    logger.info("Initialize application context, done.");
}

From source file:com.moreopen.websocket.demo.server.SpringContextLoaderListener.java

@Override
public void contextInitialized(ServletContextEvent event) {
    super.contextInitialized(event);
    WebApplicationContext applicationContext = WebApplicationContextUtils
            .getWebApplicationContext(event.getServletContext());
    com.moreopen.websocket.demo.BeanLocator.setApplicationContext(applicationContext);
    logger.info("============ Initialize application context, done. " + applicationContext);
}

From source file:com.ocs.dynamo.ui.ServiceLocator.java

/**
 * Lazily loads the context/*w  w w .j a  v  a  2 s .c  o m*/
 */
private static synchronized void loadCtx() {
    if (ctx == null) {
        if (SpringVaadinServlet.getCurrent() != null) {
            ServletContext sc = SpringVaadinServlet.getCurrent().getServletContext();
            ctx = WebApplicationContextUtils.getWebApplicationContext(sc);
        } else {
            ctx = new ClassPathXmlApplicationContext("classpath:META-INF/testApplicationContext.xml");
        }
    }
}

From source file:com.lyh.licenseworkflow.web.listener.StartupListener.java

public void contextInitialized(ServletContextEvent servletContextEvent) {
    WebApplicationContext ctx = WebApplicationContextUtils
            .getWebApplicationContext(servletContextEvent.getServletContext());
    ServerBeanFactory.setAppContext(ctx);
    ServerBeanFactory.setServletContext(servletContextEvent.getServletContext());
    //??//from  w w w.  j av  a  2 s  . com
    ServerBeanFactory.initModules();
    logger.info("LICENSEWORKFLOW Server [" + Version.getInstance().getSvnTag() + ".GA (build: SVNTag="
            + Version.getInstance().getSvnTag() + " date=" + Version.getInstance().getBuildDate()
            + ")] has started...");
}

From source file:com.brick.base.listener.ContextAndDataAccessorLoaderListener.java

@Override
public void contextInitialized(ServletContextEvent event) {
    super.contextInitialized(event);
    SqlMapClient sqlMapClient = null;/*from  ww w  . j av  a2 s  .c o  m*/
    BasicDataSource dataSource_JNDI = null;
    org.apache.commons.dbcp.BasicDataSource dataSource_JDBC = null;
    WebApplicationContext appContext = WebApplicationContextUtils
            .getWebApplicationContext(event.getServletContext());
    if (appContext != null) {
        Object sqlMapClientObj = appContext.getBean("tacSqlMapClient");
        if (sqlMapClientObj instanceof SqlMapClient) {
            sqlMapClient = (SqlMapClient) sqlMapClientObj;
            if (DataAccessor.getSession() == null) {
                //System.out.println("setSqlMapper(" + sqlMapClient +")");
                DataAccessor.setSqlMapper(sqlMapClient);
            }
        }
        Object dataSourceObj = appContext.getBean("dataSource");
        if (dataSourceObj instanceof BasicDataSource) {
            dataSource_JNDI = (BasicDataSource) dataSourceObj;
            if (DataAccessor.JdbcUrl == null) {
                //System.out.println("setJdbcUrl(" +dataSource_JNDI.getUrl() + ")");
                DataAccessor.setJdbcUrl(dataSource_JNDI.getUrl());
            }
        } else if (dataSourceObj instanceof org.apache.commons.dbcp.BasicDataSource) {
            dataSource_JDBC = (org.apache.commons.dbcp.BasicDataSource) dataSourceObj;
            if (DataAccessor.JdbcUrl == null) {
                //System.out.println("setJdbcUrl(" +dataSource_JDBC.getUrl() + ")");
                DataAccessor.setJdbcUrl(dataSource_JDBC.getUrl());
            }
        }
    }
    Chart.setLicenseCode("SXZVFNRN9MZ9L8LGA0E2B1BB");
}

From source file:cn.com.sgcc.servlet.LicenseServlet.java

@Override
public void init(ServletConfig servletConfig) throws ServletException {
    ServletContext servletContext = servletConfig.getServletContext();
    WebApplicationContext webApplicationContext = WebApplicationContextUtils
            .getWebApplicationContext(servletContext);
    accessControl = (AccessControl) webApplicationContext.getBean("AccessControlBean");
}