List of usage examples for org.springframework.web.context.support WebApplicationContextUtils getRequiredWebApplicationContext
public static WebApplicationContext getRequiredWebApplicationContext(ServletContext sc) throws IllegalStateException
From source file:nl.tue.gale.ae.LoginServlet.java
private ApplicationContext getApplicationContext() { if (context == null) { context = WebApplicationContextUtils.getRequiredWebApplicationContext(getServletContext()); }/*from w w w . jav a 2 s.c om*/ return context; }
From source file:edu.txstate.dmlab.clusteringwiki.web.AppContextListener.java
public void contextInitialized(ServletContextEvent event) { super.contextInitialized(event); webAppCtx = WebApplicationContextUtils.getRequiredWebApplicationContext(event.getServletContext()); }
From source file:org.openxdata.server.servlet.BirtImagesServlet.java
@Override public void init() throws ServletException { ServletContext sctx = this.getServletContext(); WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(sctx); settingService = (SettingService) ctx.getBean("settingService"); }
From source file:com.baidu.jprotobuf.rpc.server.HttpRequestHandlerServlet.java
protected Map<String, ServiceExporter> getServiceExporters() { WebApplicationContext wac = WebApplicationContextUtils .getRequiredWebApplicationContext(getServletContext()); Map<String, ServiceExporter> beans = wac.getBeansOfType(ServiceExporter.class); return beans; }
From source file:org.hdiv.context.jsf1.RedirectExternalContext.java
/** * Default constructor// w w w .j a v a2s. c o m * * @param wrapped * original ExternalContext */ public RedirectExternalContext(ExternalContext wrapped) { super(); this.wrapped = wrapped; ServletContext servletContext = (ServletContext) wrapped.getContext(); this.redirectHelper = (RedirectHelper) WebApplicationContextUtils .getRequiredWebApplicationContext(servletContext).getBean("redirectHelper"); Assert.notNull(this.redirectHelper); }
From source file:grails.util.Holders.java
public static ApplicationContext getApplicationContext() { return WebApplicationContextUtils.getRequiredWebApplicationContext(getServletContext()); }
From source file:com.icanft.common.listener.ProjectInitListener.java
public void contextInitialized(ServletContextEvent event) { System.out.println("==========?=========="); final ServletContext servletContext = event.getServletContext(); ProjectInitListener.servletContext = servletContext; super.contextInitialized(event); setContext(WebApplicationContextUtils.getRequiredWebApplicationContext(event.getServletContext())); ContextUtil.setApplicationContext(ProjectInitListener.context); // ?FBRP?//w ww . j a v a2s. c o m ContextUtil.setApplicationPath(event.getServletContext().getRealPath("/")); LicenseColl licenseList = null; try { licenseList = (LicenseColl) ProjectInitListener.getContext().getBean("fbrp_licenseColl"); } catch (Exception exe) { log.warn("License?"); } if (licenseList != null) { boolean licenseIsValid = ValidateLicense.validateLicense(licenseList, ContextUtil.getApplicationPath()); ContextUtil.put("licenseIsValid", licenseIsValid, ContextUtil.SCOPE_APPLICATION); } else { ContextUtil.put("licenseIsValid", true, ContextUtil.SCOPE_APPLICATION); } }
From source file:fr.openwide.talendalfresco.rest.server.CommandAuthenticationFilter.java
/** * Return the ServiceRegistry helper instance * /*from ww w . j av a 2s . c om*/ * @param sc ServletContext * @return ServiceRegistry */ public static ServiceRegistry getServiceRegistry(ServletContext sc) { WebApplicationContext wc = WebApplicationContextUtils.getRequiredWebApplicationContext(sc); return (ServiceRegistry) wc.getBean(ServiceRegistry.SERVICE_REGISTRY); }
From source file:net.sourceforge.happybank.control.BaseServlet.java
/** * Initialise spring application context and facade. * @param config servlet config/* www . j a v a2 s. co m*/ * @throws ServletException on error */ public void init(ServletConfig config) throws ServletException { super.init(config); // load Spring framework Web context WebApplicationContext wac = WebApplicationContextUtils .getRequiredWebApplicationContext(config.getServletContext()); // set banking facade bank = (BankingFacade) wac.getBean("bankManager"); }
From source file:org.cometd.websocket.SpringFrameworkConfigurationTest.java
@Test public void testXMLSpringConfigurationWithWebSocket() throws Exception { prepareServer(0, null, false);//from w w w . j a v a 2 s . com // Add Spring listener context.addEventListener(new ContextLoaderListener()); String config = WEBSOCKET_JSR_356.equals(wsTransportType) ? "applicationContext-javax-websocket.xml" : "applicationContext-jetty-websocket.xml"; context.getInitParams().put(ContextLoader.CONFIG_LOCATION_PARAM, "classpath:/" + config); startServer(); prepareClient(); startClient(); WebApplicationContext applicationContext = WebApplicationContextUtils .getRequiredWebApplicationContext(context.getServletContext()); Assert.assertNotNull(applicationContext); BayeuxServerImpl bayeuxServer = (BayeuxServerImpl) applicationContext.getBean("bayeux"); Assert.assertNotNull(bayeuxServer); Assert.assertTrue(bayeuxServer.isStarted()); Assert.assertSame(bayeuxServer, bayeux); ServerTransport transport = bayeuxServer.getTransport("websocket"); Assert.assertNotNull(transport); final BayeuxClient client = newBayeuxClient(); client.handshake(); Assert.assertTrue(client.waitFor(5000, BayeuxClient.State.CONNECTED)); // Wait for connect to establish Thread.sleep(1000); ClientTransport clientTransport = client.getTransport(); Assert.assertEquals("websocket", clientTransport.getName()); disconnectBayeuxClient(client); }