List of usage examples for org.springframework.web.context WebApplicationContext ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE
String ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE
To view the source code for org.springframework.web.context WebApplicationContext ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE.
Click Source Link
From source file:net.sourceforge.vulcan.web.VulcanContextListenerTest.java
@TrainingMethod("trainNoCalls") public void testInitNoWac() { servletContext.removeAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE); try {/* w w w.j av a 2 s. com*/ l.contextInitialized(event); fail("expected exception"); } catch (IllegalStateException e) { } }
From source file:jetx.ext.springmvc.SpringMvcFunctions.java
/** * ?Spring ROOT /*ww w. j a v a 2s . co m*/ */ public static WebApplicationContext getWebApplicationContext(JetPageContext ctx) { return WebApplicationContextUtils.getWebApplicationContext(ExtendUtils.getServletContext(ctx), WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE); }
From source file:ecatering.AbstractWebIntegrationTests.java
@Before public void setUp() { context.getServletContext().setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, context);//from ww w .jav a 2s.c o m mvc = MockMvcBuilders.webAppContextSetup(context).// addFilters(securityFilterChain).// build(); }
From source file:com.xinlv.test.MockContextLoader.java
@Override public ConfigurableApplicationContext loadContext(String... locations) throws Exception { ConfigurableWebApplicationContext context = new XmlWebApplicationContext(); MockServletContext servletContext = new MockServletContext("") { @Override/* w w w . ja v a 2s .c o m*/ public String getRealPath(String arg0) { return System.getProperty("java.io.tmpdir"); } }; servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, context); context.setServletContext(servletContext); String configLocation = "/xinlv-test-context.xml"; context.setConfigLocation(configLocation); /*String[] configLocations = PortalContextLoaderListener.locateConfigLocations(locations); context.setConfigLocations(configLocations);*/ context.refresh(); context.registerShutdownHook(); return context; }
From source file:com.betfair.tornjak.monitor.overlay.AuthUtils.java
private static synchronized RolePerms getOrCreateRolePerms(ServletContext servletContext) throws IOException { RolePerms rolePerms;/* w ww .j av a2 s.c o m*/ rolePerms = (RolePerms) servletContext.getAttribute(CONTEXT_ATTR_NAME); if (rolePerms != null) { return rolePerms; } ApplicationContext context = (ApplicationContext) servletContext .getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE); if (context == null) { throw new ApplicationContextException("Unable to find application context"); } String authFileLocation = servletContext.getInitParameter(CONTEXT_INIT_PARAM_NAME); if (StringUtils.isBlank(authFileLocation)) { throw new ApplicationContextException(String .format("Parameter '%s' not defined, unable to load jmx auth file", CONTEXT_INIT_PARAM_NAME)); } rolePerms = AuthFileReader.load(context.getResource(authFileLocation)); servletContext.setAttribute(CONTEXT_ATTR_NAME, rolePerms); return rolePerms; }
From source file:org.excalibur.service.deployment.server.context.ApplicationServletContextListener.java
@Override public void contextDestroyed(ServletContextEvent sce) { ApplicationContext applicationContext = (ApplicationContext) sce.getServletContext() .getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE); try {//from w w w .ja va 2s. co m applicationContext.getBean(Overlay.class).leave(); } catch (BeansException | OverlayException e) { LOG.error("Error on leaving the overlay [{}]", e.getMessage(), e); } }
From source file:net.sourceforge.vulcan.web.PreferencesFilterTest.java
@Override protected void setUp() throws Exception { super.setUp(); prefStore = control.createMock(PreferencesStore.class); wac.getBeanFactory().registerSingleton("preferencesStore", prefStore); context.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac); filter.init(filterConfig);/*from w w w. ja v a 2 s .c om*/ }
From source file:com.athena.sqs.MessageReceiveListener.java
public void contextInitialized(ServletContextEvent sce) { ServletContext servletContext = sce.getServletContext(); listenQueueName = servletContext.getInitParameter("listenQueueName"); if (listenQueueName == null) { listenQueueName = "your_listen_queue_name"; }//from ww w . j av a2s . co m ApplicationContext applicationContext = (ApplicationContext) servletContext .getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE); receiver = applicationContext.getBean(MessageReceiver.class); // If you want to run multiple receivers, create tasks or change doReceive method to async. /* * List<BizQueue> list = dao.getBizQueueList(); * for(BizQueue queue : list) { * BizQueueTask task = new BiaQueueTask(sqsContext, queue); * task.run(); // thread start. * } */ try { logger.debug("***********************************************"); logger.debug("SQS Message Receiver is starting"); logger.debug("***********************************************"); // Queue names are loaded from sqsContext.xml List<String> queueList = (List<String>) applicationContext.getBean("initialQueueList"); for (String queueName : queueList) { receiver.doReceive(queueName); Thread.sleep(2000); } // Default listen queue start receiver.doReceive(listenQueueName); } catch (Exception e) { e.printStackTrace(); } }
From source file:org.red5.server.winstone.WinstoneApplicationContext.java
public void stop() { log.debug("stop"); try {//from w ww. j a v a 2 s .co m Object o = context.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE); if (o != null) { log.debug("Spring context for {} was found", context.getContextName()); ConfigurableWebApplicationContext appCtx = (ConfigurableWebApplicationContext) o; //close the red5 app if (appCtx.isRunning()) { log.debug("Context was running, attempting to stop"); appCtx.stop(); } if (appCtx.isActive()) { log.debug("Context is active, attempting to close"); appCtx.close(); } } else { log.warn("Spring context for {} was not found", context.getContextName()); } } catch (Exception e) { log.error("Could not stop spring context", e); } context.destroy(); }
From source file:test.pl.chilldev.facelets.taglib.spring.social.NotConnectedTagTest.java
@Test public void apply() throws IOException, FacesException { String provider = "facebook"; Map<String, Object> config = new HashMap<>(); config.put(NotConnectedTag.ATTRIBUTE_PROVIDER, provider); NotConnectedTag tag = new NotConnectedTag(MockTagConfig.factory(config, this.nextHandler)); // set up context FaceletContext context = new MockFaceletContext(); context.getFacesContext().getExternalContext().getApplicationMap() .put(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, this.applicationContext); List<Connection<?>> connections = new ArrayList<>(); connections.add(this.connection); when(this.applicationContext.getBean(ConnectionRepository.class)).thenReturn(this.connectionRepository); when(this.connectionRepository.findConnections(provider)).thenReturn(connections); // run the tag tag.apply(context, this.parent); verifyZeroInteractions(this.nextHandler); }