List of usage examples for org.springframework.web.context.support GenericWebApplicationContext setParent
@Override public void setParent(@Nullable ApplicationContext parent)
From source file:grgr.test.cxf.UndertowCxfTest.java
@Test public void testUndertowServlet() throws Exception { ServletContainer servletContainer = Servlets.newContainer(); // parent, webcontext-wide Spring context ClassPathXmlApplicationContext parent = new ClassPathXmlApplicationContext("/UndertowCxfTest-context.xml"); // represents a servlet deployment - representing everything we can find in web.xml DeploymentInfo di = Servlets.deployment().setClassLoader(UndertowCxfTest.class.getClassLoader()) .setContextPath("/").setDeploymentName("ROOT.war").setDisplayName("Default Application") .setUrlEncoding("UTF-8").addServlets( Servlets.servlet("cxf", CXFServlet.class, new ImmediateInstanceFactory<>(new CXFServlet())) .addMapping("/*")); DeploymentManager dm = servletContainer.addDeployment(di); dm.deploy();/*from www. j av a 2 s. c o m*/ HttpHandler handler = dm.start(); // parent, webcontext-wide Spring web context GenericWebApplicationContext wac = new GenericWebApplicationContext(); wac.setParent(parent); wac.setServletContext(dm.getDeployment().getServletContext()); wac.getServletContext().setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac); wac.refresh(); PathHandler path = Handlers.path().addPrefixPath(di.getContextPath(), Handlers.requestDump(handler)); createAndStartServlet(8000, path); }
From source file:org.motechproject.server.osgi.OsgiFrameworkServiceTest.java
private WebApplicationContext getWebApplicationContext() { GenericWebApplicationContext wac = BeanUtils.instantiateClass(GenericWebApplicationContext.class); wac.setParent(applicationContext); wac.setServletContext(new MockServletContext()); return wac;//from w w w . j a va 2s. co m }
From source file:org.helios.ember.web.spring.ServletContextAttributes.java
/** * {@inheritDoc}/* w ww . ja v a 2s .co m*/ * @see org.springframework.context.ApplicationContextAware#setApplicationContext(org.springframework.context.ApplicationContext) */ @Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { this.applicationContext = applicationContext; GenericWebApplicationContext gwa = new GenericWebApplicationContext(); gwa.setParent(applicationContext); attrs.put(WebApplicationContext.class.getName() + ".ROOT", gwa); }
From source file:de.fau.amos4.test.BaseWebApplicationContextTests.java
@Before public void initDispatcherServlet() throws Exception { servlet = new DispatcherServlet() { private static final long serialVersionUID = 1L; @Override//from w w w. j a va2 s.com protected WebApplicationContext createWebApplicationContext(WebApplicationContext parent) throws BeansException { GenericWebApplicationContext gwac = new GenericWebApplicationContext(); gwac.setParent(applicationContext); gwac.refresh(); return gwac; } }; request = new MockHttpServletRequest(); response = new MockHttpServletResponse(); MockServletContext servletContext = new MockServletContext("src/main/java/amos4/model", new FileSystemResourceLoader()); servlet.init(new MockServletConfig(servletContext)); }
From source file:ca.unx.template.config.JettyConfiguration.java
@Bean public WebAppContext jettyWebAppContext() throws IOException { WebAppContext ctx = new WebAppContext(); ctx.setContextPath("/*"); ctx.setWar(new ClassPathResource("webapp").getURI().toString()); /* Disable directory listings if no index.html is found. */ ctx.setInitParameter("org.eclipse.jetty.servlet.Default.dirAllowed", "true"); /* Create the root web application context and set it as a servlet * attribute so the dispatcher servlet can find it. */ GenericWebApplicationContext webApplicationContext = new GenericWebApplicationContext(); webApplicationContext.setParent(applicationContext); webApplicationContext.refresh();/*from w w w . j av a 2 s.c o m*/ ctx.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, webApplicationContext); /* * Set the attributes that the Metrics servlets require. The Metrics * servlet is added in the WebAppInitializer. */ ctx.setAttribute(MetricsServlet.METRICS_REGISTRY, metricRegistry); ctx.setAttribute(HealthCheckServlet.HEALTH_CHECK_REGISTRY, healthCheckRegistry); ctx.addEventListener(new WebAppInitializer()); return ctx; }
From source file:org.spo.ifs.config.JettyConfiguration.java
@Bean public WebAppContext webAppContext() throws IOException { WebAppContext ctx = new WebAppContext(); ctx.setContextPath("/"); ctx.setWar(new ClassPathResource("webapp").getURI().toString()); /* Disable directory listings if no index.html is found. */ ctx.setInitParameter("org.eclipse.jetty.servlet.Default.dirAllowed", "false"); /* Create the root web application context and set it as a servlet * attribute so the dispatcher servlet can find it. */ GenericWebApplicationContext webApplicationContext = new GenericWebApplicationContext(); webApplicationContext.setParent(applicationContext); webApplicationContext.refresh();/* ww w .j a v a 2 s .c om*/ ctx.setParentLoaderPriority(true); ctx.addEventListener(new ContextLoaderListener(webApplicationContext)); ctx.addEventListener(new WebAppInitializerLoader(new WebApplicationInitializer[] { new SpringWebAppInitializer(), new SpringSecurityWebAppInitializer() })); return ctx; }
From source file:com.tcloud.bee.key.server.jetty.config.JettyConfiguration.java
@Bean public WebAppContext webAppContext() throws IOException { WebAppContext ctx = new WebAppContext(); ctx.setContextPath(contextPath);/* w ww . j a v a 2 s . co m*/ String warPath = new ClassPathResource("webapp").getURI().toString(); logger.info("warPath:{}", warPath); ctx.setWar(warPath); // http://www.eclipse.org/jetty/documentation/current/configuring-jsp.html /* Disable directory listings if no index.html is found. */ ctx.setInitParameter("org.eclipse.jetty.servlet.Default.dirAllowed", "false"); ctx.setInitParameter("development", "true"); ctx.setInitParameter("checkInterval", "10"); ctx.setInitParameter("compilerTargetVM", "1.7"); ctx.setInitParameter("compilerSourceVM", "1.7"); /* * Create the root web application context and set * it as a servlet * attribute so the dispatcher servlet can find it. */ GenericWebApplicationContext webApplicationContext = new GenericWebApplicationContext(); webApplicationContext.setParent(applicationContext); webApplicationContext.refresh(); ctx.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, webApplicationContext); ctx.addEventListener(new WebAppInitializer()); return ctx; }
From source file:com.centeractive.ws.server.core.SoapServer.java
private void configureWebContext() { ServletContext servletContext = getServletContext(); GenericWebApplicationContext webContext = new GenericWebApplicationContext(); webContext.setServletContext(servletContext); webContext.setParent(context); webContext.refresh();/*from w ww .j a va 2 s. c o m*/ servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, webContext); if (webContext != null) { endpoint = webContext.getBean(ENDPOINT_BEAN_NAME, GenericContextDomEndpoint.class); } }
From source file:org.reficio.ws.server.core.SoapServer.java
private void configureWebContext() { ServletContext servletContext = getServletContext(); GenericWebApplicationContext webContext = new GenericWebApplicationContext(); webContext.setServletContext(servletContext); webContext.setParent(context); webContext.refresh();//w w w. j a va 2 s .c o m servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, webContext); if (webContext != null) { endpoint = webContext.getBean(SoapServerConstants.ENDPOINT_BEAN_NAME, GenericContextDomEndpoint.class); } }