List of usage examples for org.springframework.web.context.support AnnotationConfigWebApplicationContext setParent
@Override public void setParent(@Nullable ApplicationContext parent)
From source file:com.graphaware.server.foundation.context.BaseWebContextCreator.java
@Override public WebApplicationContext createWebContext(ApplicationContext rootContext, ServletContextHandler handler, Config config) {/* www.java 2s.c om*/ AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext(); context.setParent(rootContext); context.setServletContext(handler.getServletContext()); registerConfigClasses(context, config); context.refresh(); return context; }
From source file:com.example.m1.M1ServletConfig.java
public DispatcherServlet dispatcherServlet() { AnnotationConfigWebApplicationContext webContext = new AnnotationConfigWebApplicationContext(); webContext.setParent(applicationContext); webContext.register(M1Config.class); //webContext.register(ThymeleafAutoConfiguration.class); webContext.scan("com.example.m1"); DispatcherServlet dispatcherServlet = new DispatcherServlet(webContext); return dispatcherServlet; }
From source file:com.googlecode.jeeunit.example.spring.web.LibraryWebApplicationInitializer.java
@Override public void onStartup(ServletContext sc) throws ServletException { AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext(); rootContext.getEnvironment().addActiveProfile("web"); rootContext.register(WebSpringConfig.class); sc.addListener(new ContextLoaderListener(rootContext)); // Create the dispatcher servlet's Spring application context AnnotationConfigWebApplicationContext dispatcherContext = new AnnotationConfigWebApplicationContext(); dispatcherContext.setParent(rootContext); // Register and map the dispatcher servlet ServletRegistration.Dynamic dispatcher = sc.addServlet("dispatcher", new DispatcherServlet(dispatcherContext)); dispatcher.setLoadOnStartup(2);/*from w w w. j a v a2 s . c o m*/ dispatcher.addMapping("*.html"); dispatcher.addMapping("*.form"); dispatcher.addMapping("*.ajax"); }
From source file:org.jbr.taskmgr.config.WebInitializer.java
@Override public void onStartup(ServletContext servletContext) throws ServletException { // Create the dispatcher servlet's Spring application context AnnotationConfigWebApplicationContext dispatcherContext = new AnnotationConfigWebApplicationContext(); dispatcherContext.setParent(containerContext); dispatcherContext.register(WebMvcConfig.class); dispatcherContext.registerShutdownHook(); // Register and map the dispatcher servlet ServletRegistration.Dynamic dispatcher = servletContext.addServlet("dispatcher", new DispatcherServlet(dispatcherContext)); dispatcher.setLoadOnStartup(1);/*from w w w . ja v a2 s .c om*/ dispatcher.addMapping("/"); }
From source file:com.graphaware.server.web.WebAppInitializer.java
@Override protected WebApplicationContext createServletApplicationContext() { GenericApplicationContext parent = new GenericApplicationContext(); parent.getBeanFactory().registerSingleton("database", database.getGraph()); GraphAwareRuntime runtime = RuntimeRegistry.getRuntime(database.getGraph()); if (runtime != null) { runtime.waitUntilStarted();//from w w w. j a v a 2s. c o m parent.getBeanFactory().registerSingleton("databaseWriter", runtime.getDatabaseWriter()); } parent.refresh(); AnnotationConfigWebApplicationContext appContext = new AnnotationConfigWebApplicationContext(); appContext.setParent(parent); appContext.scan("com.**.graphaware.**", "org.**.graphaware.**", "net.**.graphaware.**"); return appContext; }
From source file:eu.enhan.timelord.web.init.TimelordWebInit.java
/** * @see org.springframework.web.WebApplicationInitializer#onStartup(javax.servlet.ServletContext) */// ww w.jav a 2 s . c o m @Override public void onStartup(ServletContext servletContext) throws ServletException { AnnotationConfigWebApplicationContext rootCtx = new AnnotationConfigWebApplicationContext(); rootCtx.register(AppConfig.class); servletContext.addListener(new ContextLoaderListener(rootCtx)); AnnotationConfigWebApplicationContext webAppCtx = new AnnotationConfigWebApplicationContext(); webAppCtx.setParent(rootCtx); webAppCtx.register(WebConfig.class); XmlWebApplicationContext securityCtx = new XmlWebApplicationContext(); securityCtx.setServletContext(servletContext); securityCtx.setParent(rootCtx); securityCtx.setConfigLocation("classpath:/spring/security.xml"); ServletRegistration.Dynamic dispatcher = servletContext.addServlet("dispatcher", new DispatcherServlet(webAppCtx)); dispatcher.setLoadOnStartup(1); dispatcher.addMapping("/"); FilterRegistration.Dynamic securityFilter = servletContext.addFilter("springSecurityFilterChain", new DelegatingFilterProxy("springSecurityFilterChain", securityCtx)); // securityFilter.addMappingForUrlPatterns(null, false, "/**"); securityFilter.addMappingForServletNames(null, false, "dispatcher"); }
From source file:br.eti.danielcamargo.backend.common.config.WebAppInitializer.java
private void configureWebServlets(ServletContext servletContext, WebApplicationContext rootContext) { AnnotationConfigWebApplicationContext mvcContext = new AnnotationConfigWebApplicationContext(); mvcContext.register(WebConfig.class); mvcContext.setParent(rootContext); DispatcherServlet restDispatcherServlet = new DispatcherServlet(mvcContext); String restDispatcherName = "Rest Servlet"; ServletRegistration.Dynamic restServletRegistration = servletContext.addServlet(restDispatcherName, restDispatcherServlet);/* w ww .ja v a2 s . c o m*/ restServletRegistration.setLoadOnStartup(1); restServletRegistration.addMapping("/rest/*"); }
From source file:config.JettyConfiguration.java
@Bean public ServletContextHandler servletContext() throws IOException { ServletContextHandler handler = new ServletContextHandler(ServletContextHandler.SESSIONS); AnnotationConfigWebApplicationContext webApplicationContext = new AnnotationConfigWebApplicationContext(); webApplicationContext.setParent(applicationContext); webApplicationContext.refresh();//from w ww .j av a2 s . com handler.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, webApplicationContext); handler.setContextPath("/"); handler.setResourceBase(new ClassPathResource("webapp").getURI().toString()); handler.addServlet(AdminServlet.class, "/metrics/*"); handler.addServlet(dispatcherServlet(), "/"); handler.addFilter(new FilterHolder(new DelegatingFilterProxy("springSecurityFilterChain")), "/*", null); return handler; }
From source file:net.orpiske.tcs.service.config.WebAppInitializer.java
private void configureSpringMvc(ServletContext servletContext, WebApplicationContext rootContext) { AnnotationConfigWebApplicationContext mvcContext = new AnnotationConfigWebApplicationContext(); mvcContext.register(MVCConfig.class); mvcContext.setParent(rootContext); ServletRegistration.Dynamic appServlet = servletContext.addServlet("webservice", new DispatcherServlet(mvcContext)); appServlet.setLoadOnStartup(1);//from w w w .ja va2 s .c o m Set<String> mappingConflicts = appServlet.addMapping("/"); if (!mappingConflicts.isEmpty()) { for (String s : mappingConflicts) { logger.error("Mapping conflict: " + s); } throw new IllegalStateException("'webservice' cannot be mapped to '/'"); } }
From source file:gt.dakaik.config.AppConfig.java
@Override public void onStartup(ServletContext servletContext) throws ServletException { ConfiguracionLogs.agregarLlave();/* ww w . j a v a 2 s.c o m*/ AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext(); rootContext.register(RootContext.class); AnnotationConfigWebApplicationContext dispatcherContext = new AnnotationConfigWebApplicationContext(); dispatcherContext.setServletContext(servletContext); dispatcherContext.setParent(rootContext); dispatcherContext.register(WebContext.class); ServletRegistration.Dynamic dispatcher = servletContext.addServlet(DISPATCHER_SERVLET_NAME, new DispatcherServlet(dispatcherContext)); dispatcher.setLoadOnStartup(1); dispatcher.addMapping(DISPATCHER_SERVLET_MAPPING); FilterRegistration.Dynamic FiltroLogs = servletContext.addFilter(FILTER_LOGGING, new FiltroLogs()); FiltroLogs.addMappingForUrlPatterns(null, true, FILTER_LOGGING_MAPPING); servletContext.addListener(new ContextLoaderListener(rootContext)); }