List of usage examples for javax.servlet ServletContext addServlet
public ServletRegistration.Dynamic addServlet(String servletName, Class<? extends Servlet> servletClass);
From source file:com.aalto.config.WebInitializer.java
@Override public void onStartup(ServletContext servletContext) throws ServletException { Logger.getLogger("config").log(Level.INFO, "log: Webinitializer onStartup method!!"); AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext(); ctx.register(Config.class); ctx.setServletContext(servletContext); Dynamic servlet = servletContext.addServlet("dispatcher", new DispatcherServlet(ctx)); servlet.addMapping("/"); servlet.setLoadOnStartup(1);/*from w ww.ja v a 2s . co m*/ }
From source file:com.miko.s4netty.config.WebInitializer.java
@Override public void onStartup(ServletContext servletContext) throws ServletException { logger.debug("WebInitializer onStartup"); XmlWebApplicationContext ctx = new XmlWebApplicationContext(); ctx.setConfigLocation("WEB-INF/spring/dispatcher-servlet.xml"); ctx.setServletContext(servletContext); Dynamic servlet = servletContext.addServlet("dispatcher", new DispatcherServlet(ctx)); servlet.addMapping("/"); servlet.setLoadOnStartup(1);//from www .j a v a2 s . c o m }
From source file:de.interseroh.report.webapp.UiWebAppInitializer.java
private void addMvcServlet(ServletContext servletContext) { AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext(); context.register(WebMvcConfig.class); DispatcherServlet dispatcherServlet = new DispatcherServlet(context); ServletRegistration.Dynamic dispatcher = servletContext.addServlet(DISPATCHER_SERVLET_NAME, dispatcherServlet);//from w w w . jav a2 s. co m dispatcher.setLoadOnStartup(1); dispatcher.addMapping(VIEWS_BASE); }
From source file:com.controller.config.MainWebApplicationInitizer.java
@Override public void onStartup(ServletContext servletContext) throws ServletException { AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext(); rootContext.scan("com.controller.config"); servletContext.addListener(new ContextLoaderListener(rootContext)); ServletRegistration.Dynamic dispather = servletContext.addServlet("CXFServlet", CXFServlet.class); dispather.addMapping("/rest/*"); }
From source file:org.kew.rmf.reconciliation.config.WebAppInitializer.java
@Override public void onStartup(ServletContext servletContext) { WebApplicationContext rootContext = createRootContext(servletContext); configureSpringMvc(servletContext, rootContext); // Add Perf4J graphing servlet ServletRegistration.Dynamic servletRegistration = servletContext.addServlet("perf4j", org.perf4j.logback.servlet.GraphingServlet.class); servletRegistration.setInitParameter("graphNames", "graphOtherTimes,graphQueryTimes,graphQueriesPerSecond"); servletRegistration.addMapping("/perf4j"); String TAG_SWAP_FILTER_CLASS = "org.kew.servlet.filter.TagSwapFilter"; try {// w w w . j av a2s .co m Class.forName(TAG_SWAP_FILTER_CLASS, false, this.getClass().getClassLoader()); String[] urlPatterns = { "/", "/about/*", "/admin", "/filematch/*", "/help" }; FilterRegistration.Dynamic cssLinkFilter = servletContext.addFilter("CssLinkFilter", TAG_SWAP_FILTER_CLASS); cssLinkFilter.setInitParameter("include_file_name", "/var/lib/science-apps/web-resources/head.chunk"); cssLinkFilter.setInitParameter("tag_name", "[KEWCSS]"); cssLinkFilter.addMappingForUrlPatterns(null, true, urlPatterns); FilterRegistration.Dynamic headerFilter = servletContext.addFilter("HeaderFilter", TAG_SWAP_FILTER_CLASS); headerFilter.setInitParameter("include_file_name", "/var/lib/science-apps/web-resources/bodytop.chunk"); headerFilter.setInitParameter("tag_name", "[KEWHEADER]"); headerFilter.addMappingForUrlPatterns(null, true, urlPatterns); FilterRegistration.Dynamic footerFilter = servletContext.addFilter("FooterFilter", TAG_SWAP_FILTER_CLASS); footerFilter.setInitParameter("include_file_name", "/var/lib/science-apps/web-resources/bodybottom.chunk"); footerFilter.setInitParameter("tag_name", "[KEWFOOTER]"); footerFilter.addMappingForUrlPatterns(null, true, urlPatterns); } catch (ClassNotFoundException e) { log.error("Kew servlet filters not in use, class {} not on classpath", TAG_SWAP_FILTER_CLASS); } }
From source file:org.cloudfoundry.caldecott.server.config.SpringWebApplicationInitializer.java
@Override public void onStartup(ServletContext servletContext) throws ServletException { AnnotationConfigWebApplicationContext springContext = new AnnotationConfigWebApplicationContext(); springContext.register(WebApplicationConfiguration.class); DispatcherServlet servlet = new DispatcherServlet(springContext); ServletRegistration.Dynamic registration = servletContext.addServlet("dispatcher", servlet); registration.setLoadOnStartup(1);/*w ww .j a va 2 s. c o m*/ registration.addMapping("/*"); }
From source file:com.github.marsbits.restfbmessenger.sample.EchoWebApplicationInitializer.java
@Override public void onStartup(ServletContext servletContext) throws ServletException { AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext(); context.setConfigLocation(this.getClass().getPackage().getName()); servletContext.addListener(new ContextLoaderListener(context)); ServletRegistration.Dynamic dispatcher = servletContext.addServlet("DispatcherServlet", new DispatcherServlet(context)); dispatcher.setLoadOnStartup(1);/* w ww . j a v a2 s. co m*/ dispatcher.addMapping("/*"); }
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);/*from ww w. j a va 2s.co m*/ ServletRegistration.Dynamic appServlet = servletContext.addServlet("webservice", new DispatcherServlet(mvcContext)); appServlet.setLoadOnStartup(1); 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:edu.co.unbosque.software2.helloworld.config.WebInitializer.java
@Override public void onStartup(ServletContext servletContext) throws ServletException { AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext(); ctx.register(Configuracion.class); ctx.setServletContext(servletContext); // servletContext.addListener(new ContextLoaderListener(ctx)); Dynamic servlet;//from w w w . j av a 2 s . c o m servlet = servletContext.addServlet("dispatcher", new DispatcherServlet(ctx)); servlet.addMapping("/"); servlet.setLoadOnStartup(1); }
From source file:net.oneandone.stool.overview.initializer.ApplicationInitializer.java
@Override public void afterSpringSecurityFilterChain(ServletContext servletContext) { AnnotationConfigWebApplicationContext context; ServletRegistration.Dynamic dispatcher; context = new AnnotationConfigWebApplicationContext(); context.setConfigLocation("net.oneandone.stool.overview.config"); servletContext.addListener(new ContextLoaderListener(context)); dispatcher = servletContext.addServlet("DispatcherServlet", new DispatcherServlet(context)); dispatcher.setLoadOnStartup(1);//from w w w . j a va 2 s .c o m dispatcher.addMapping("/"); }