List of usage examples for javax.servlet ServletContext addServlet
public ServletRegistration.Dynamic addServlet(String servletName, Class<? extends Servlet> servletClass);
From source file:com.gopivotal.cloudfoundry.test.ApplicationInitializer.java
@Override public void onStartup(ServletContext servletContext) throws ServletException { AnnotationConfigWebApplicationContext webContext = new AnnotationConfigWebApplicationContext(); webContext.register(ApplicationConfiguration.class); ServletRegistration.Dynamic dispatcherServlet = servletContext.addServlet("dispatcher", new DispatcherServlet(webContext)); dispatcherServlet.setLoadOnStartup(1); dispatcherServlet.addMapping("/"); }
From source file:id.ac.ipb.ilkom.training.ApplicationInitializer.java
@Override public void onStartup(ServletContext container) throws ServletException { AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext(); ctx.register(ApplicationConfiguration.class); ctx.setServletContext(container);//www. j a va 2 s. co m ServletRegistration.Dynamic servlet = container.addServlet("dispatcher", new DispatcherServlet(ctx)); servlet.setLoadOnStartup(1); servlet.addMapping("/"); }
From source file:org.ado.biblio.config.AppInitializer.java
public void onStartup(ServletContext container) throws ServletException { AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext(); ctx.register(AppConfig.class); ctx.setServletContext(container);//from w ww. ja v a 2s . c o m ServletRegistration.Dynamic servlet = container.addServlet("dispatcher", new DispatcherServlet(ctx)); servlet.setLoadOnStartup(1); servlet.addMapping("/*"); }
From source file:com.spawnin.battlecat.webapp.servletcontext.BattlecatWebApplicationInitializer.java
@Override public void onStartup(ServletContext servletContext) throws ServletException { AnnotationConfigWebApplicationContext appContext = new AnnotationConfigWebApplicationContext(); appContext.setConfigLocation("com.spawnin.battlecat.core.config"); ServletRegistration.Dynamic registration = servletContext.addServlet("battlecat", new DispatcherServlet(appContext)); registration.setLoadOnStartup(1);/*from w w w.j a v a 2s . c o m*/ registration.addMapping("/"); }
From source file:io.gravitee.management.war.WebAppInitializer.java
@Override public void onStartup(ServletContext context) throws ServletException { // initialize initialize();/*from www.j a va 2 s . c o m*/ Properties prop = propertiesLoader.load(); // REST configuration ServletRegistration.Dynamic servletRegistration = context.addServlet("REST", ServletContainer.class.getName()); servletRegistration.addMapping("/management/*"); servletRegistration.setLoadOnStartup(1); servletRegistration.setInitParameter("javax.ws.rs.Application", GraviteeApplication.class.getName()); // Spring configuration System.setProperty(AbstractEnvironment.ACTIVE_PROFILES_PROPERTY_NAME, prop.getProperty("security.type", "basic-auth")); context.addListener(new ContextLoaderListener()); context.setInitParameter("contextClass", AnnotationConfigWebApplicationContext.class.getName()); context.setInitParameter("contextConfigLocation", RestConfiguration.class.getName()); // Spring Security filter context.addFilter("springSecurityFilterChain", DelegatingFilterProxy.class) .addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD), false, "/*"); }
From source file:org.fon.documentmanagementsystem.config.WebAppInitializer.java
@Override public void onStartup(ServletContext servletContext) throws ServletException { AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext(); ctx.register(AppConfig.class); ctx.setServletContext(servletContext); ServletRegistration.Dynamic servlet = servletContext.addServlet("dispatcher", new DispatcherServlet(ctx)); servlet.addMapping("/"); servlet.setLoadOnStartup(1);//from w ww . ja va 2 s .c o m servlet.setMultipartConfig(new MultipartConfigElement("", 1024 * 1024 * 25, 1024 * 1024 * 25, 0)); CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter(); characterEncodingFilter.setEncoding("UTF-8"); characterEncodingFilter.setForceEncoding(true); FilterRegistration.Dynamic characterEncoding = servletContext.addFilter("characterEncoding", characterEncodingFilter); EnumSet<DispatcherType> dispatcherTypes = EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD); characterEncoding.addMappingForUrlPatterns(dispatcherTypes, true, "/*"); }
From source file:org.jblogcms.core.config.MainConfig.java
@Override public void onStartup(ServletContext servletContext) throws ServletException { AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext(); rootContext.register(MainContext.class); ServletRegistration.Dynamic dispatcher = servletContext.addServlet(DISPATCHER_SERVLET_NAME, new DispatcherServlet(rootContext)); dispatcher.setLoadOnStartup(1);//from w ww. j av a 2s. c om dispatcher.addMapping(DISPATCHER_SERVLET_MAPPING); EnumSet<DispatcherType> dispatcherTypes = EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD); CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter(); characterEncodingFilter.setEncoding("UTF-8"); characterEncodingFilter.setForceEncoding(true); FilterRegistration.Dynamic characterEncoding = servletContext.addFilter("characterEncoding", characterEncodingFilter); characterEncoding.addMappingForUrlPatterns(dispatcherTypes, true, "/*"); FilterRegistration.Dynamic security = servletContext.addFilter("springSecurityFilterChain", new DelegatingFilterProxy()); security.addMappingForUrlPatterns(dispatcherTypes, true, "/*"); servletContext.addListener(new ContextLoaderListener(rootContext)); }
From source file:com.opencart.config.Initializer.java
@Override public void onStartup(ServletContext sc) throws ServletException { AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext(); ctx.register(SpringConfigurations.class); sc.addListener(new ContextLoaderListener(ctx)); ctx.setServletContext(sc);//from w w w . j a va 2s . c om Dynamic servlet = sc.addServlet("dispatcher", new DispatcherServlet(ctx)); servlet.addMapping("/"); servlet.setLoadOnStartup(1); }
From source file:org.bitcoinrt.spring.config.BitcoinServletInitializer.java
public void onStartup(ServletContext servletContext) throws ServletException { AnnotationConfigWebApplicationContext cxt = new AnnotationConfigWebApplicationContext(); cxt.register(ServerConfig.class); DispatcherServlet servlet = new DispatcherServlet(cxt); ServletRegistration.Dynamic dispatcher = servletContext.addServlet("main", servlet); dispatcher.setLoadOnStartup(1);//ww w. jav a 2 s.c o m dispatcher.setAsyncSupported(true); dispatcher.addMapping("/"); }
From source file:com.thebinaryidiot.springnoxml.WebAppInitializer.java
/** * Called by Servlet Container when application is initialized * * @param sc//from w w w . j a va 2 s. c o m * @throws ServletException */ @Override public void onStartup(final ServletContext sc) throws ServletException { // register spring web components AnnotationConfigWebApplicationContext dispatcherContext = new AnnotationConfigWebApplicationContext(); dispatcherContext.register(WebAppConfig.class); ServletRegistration.Dynamic dispatcher = sc.addServlet("dispatcher", new DispatcherServlet(dispatcherContext)); dispatcher.setLoadOnStartup(1); dispatcher.addMapping("/"); }