registration.setAsyncSupported(isAsyncSupported());
@Override public void onStartup(ServletContext servletContext) throws ServletException { String servletName = getServletName(); Assert.hasLength(servletName, "getServletName() must not return null or empty"); ApplicationContext applicationContext = createApplicationContext(); Assert.notNull(applicationContext, "createApplicationContext() must not return null"); refreshApplicationContext(applicationContext); registerCloseListener(servletContext, applicationContext); HttpHandler httpHandler = WebHttpHandlerBuilder.applicationContext(applicationContext).build(); ServletHttpHandlerAdapter servlet = new ServletHttpHandlerAdapter(httpHandler); ServletRegistration.Dynamic registration = servletContext.addServlet(servletName, servlet); if (registration == null) { throw new IllegalStateException("Failed to register servlet with name '" + servletName + "'. " + "Check if there is another servlet registered under the same name."); } registration.setLoadOnStartup(1); registration.addMapping(getServletMapping()); registration.setAsyncSupported(true); }
/** * Add new servlet according to {@link Application} subclass with {@link ApplicationPath} annotation or existing * {@code servlet-mapping}. */ private static void addServletWithApplication(final ServletContext context, final Class<? extends Application> clazz, final Set<Class<?>> defaultClasses) throws ServletException { final ApplicationPath ap = clazz.getAnnotation(ApplicationPath.class); if (ap != null) { // App is annotated with ApplicationPath final ResourceConfig resourceConfig = ResourceConfig.forApplicationClass(clazz, defaultClasses) .addProperties(Utils.getContextParams(context)); final ServletContainer s = new ServletContainer(resourceConfig); final ServletRegistration.Dynamic dsr = context.addServlet(clazz.getName(), s); dsr.setAsyncSupported(true); dsr.setLoadOnStartup(1); final String mapping = createMappingPath(ap); if (!mappingExists(context, mapping)) { dsr.addMapping(mapping); LOGGER.log(Level.CONFIG, LocalizationMessages.JERSEY_APP_REGISTERED_MAPPING(clazz.getName(), mapping)); } else { LOGGER.log(Level.WARNING, LocalizationMessages.JERSEY_APP_MAPPING_CONFLICT(clazz.getName(), mapping)); } } }
public void onStartup(final ServletContext servletContext) throws ServletException { Dynamic atmosphere = servletContext.addServlet("ATMOSPHERE", AtmosphereServlet.class); atmosphere.setLoadOnStartup(1); Map<String, String> map = new HashMap<>(6); map.put("org.atmosphere.cpr.packages", "com.jtbdevelopment"); map.put("org.atmosphere.websocket.messageContentType", "application/json"); map.put("org.atmosphere.cpr.broadcasterLifeCyclePolicy", "EMPTY_DESTROY"); map.put("org.atmosphere.cpr.sessionSupport", "true"); map.put("org.atmosphere.interceptor.HeartbeatInterceptor.heartbeatFrequencyInSeconds", "20"); map.put("org.atmosphere.cpr.dropAccessControlAllowOriginHeader", "true"); atmosphere.setInitParameters(map); atmosphere.setAsyncSupported(true); atmosphere.addMapping("/livefeed/*"); }
protected void registerAppServlet(ServletContext servletContext) { CubaApplicationServlet cubaServlet = new CubaApplicationServlet(); cubaServlet.setClassLoader(Thread.currentThread().getContextClassLoader()); // we need to register servlet first in order to initialize Atmosphere Framework ServletRegistration.Dynamic cubaServletReg = servletContext.addServlet("app_servlet", cubaServlet); cubaServletReg.setLoadOnStartup(0); cubaServletReg.setAsyncSupported(true); cubaServletReg.addMapping("/*"); // init JSR 356 explicitly initAtmosphereForVaadinServlet(cubaServletReg, servletContext); try { cubaServlet.init(new CubaServletConfig("app_servlet", servletContext)); } catch (ServletException e) { throw new RuntimeException("An error occurred while initializing app_servlet servlet", e); } }
private void configureAthmosphere(AtmosphereServlet servlet, ServletContext servletContext) { ServletRegistration.Dynamic atmosphereServlet = servletContext.addServlet("atmosphereServlet", servlet); atmosphereServlet.setInitParameter(ApplicationConfig.ANNOTATION_PACKAGE, ToastService.class.getPackage().getName()); atmosphereServlet.setInitParameter(ApplicationConfig.BROADCASTER_CACHE, UUIDBroadcasterCache.class.getName()); atmosphereServlet.setInitParameter(ApplicationConfig.BROADCASTER_SHARABLE_THREAD_POOLS, "true"); atmosphereServlet.setInitParameter(ApplicationConfig.BROADCASTER_MESSAGE_PROCESSING_THREADPOOL_MAXSIZE, "10"); atmosphereServlet.setInitParameter(ApplicationConfig.BROADCASTER_ASYNC_WRITE_THREADPOOL_MAXSIZE, "10"); servletContext.addListener(new org.atmosphere.cpr.SessionSupport()); atmosphereServlet.addMapping("/websocket/*"); atmosphereServlet.setLoadOnStartup(0); atmosphereServlet.setAsyncSupported(true); }
@Override public void onStartup(ServletContext context) { Bootstrap.start(); Dynamic dynamic = context .addServlet(DispatcherServlet.class.getSimpleName(), DispatcherServlet.class); dynamic.setLoadOnStartup(0); dynamic.addMapping(Constants.ROOT_PATH); dynamic.setAsyncSupported(true); }
/** * 访问 h2 console * @param servletContext ServletContext */ public static void initializeH2Console(ServletContext servletContext){ ServletRegistration.Dynamic h2console = servletContext.addServlet("h2console", WebServlet.class); h2console.setInitParameter("webAllowOthers", ""); h2console.addMapping("/h2console/*"); h2console.setLoadOnStartup(1); h2console.setAsyncSupported(true); } }
/** * Uses dynamic servlet registartaion for registering PushServlet automatically */ private static void registerPushServlet(ServletContext context) { Dynamic dynamicRegistration = context.addServlet("AutoRegisteredPushServlet", PushServlet.class); dynamicRegistration.addMapping(PUSH_CONTEXT_DEFAULT_MAPPING); dynamicRegistration.setAsyncSupported(true); if (LOGGER.isInfoEnabled()) { LOGGER.info("Auto-registered servlet " + PushServlet.class.getSimpleName() + " with mapping '" + PUSH_CONTEXT_DEFAULT_MAPPING + "'"); } }
final ServletRegistration.Dynamic websocket = environment.servlets().addServlet( "websocket", new MyWebSocketServlet( environment.getObjectMapper(), environment.metrics(), configuration.getKafkaConfig() ) ); websocket.setAsyncSupported(true); websocket.addMapping("/websocket/*");
reg.setAsyncSupported(true); reg.setInitParameter("javax.ws.rs.Application", applicationClass.getName());
public Dynamic inject(ServletContext servletContext, String urlPattern) { String[] urlPatterns = splitUrlPattern(urlPattern); if (urlPatterns.length == 0) { LOGGER.warn("urlPattern is empty, ignore register {}.", SERVLET_NAME); return null; } String listenAddress = ServletConfig.getLocalServerAddress(); if (!ServletUtils.canPublishEndpoint(listenAddress)) { LOGGER.warn("ignore register {}.", SERVLET_NAME); return null; } // dynamic deploy a servlet to handle serviceComb RESTful request Dynamic dynamic = servletContext.addServlet(SERVLET_NAME, RestServlet.class); dynamic.setAsyncSupported(true); dynamic.addMapping(urlPatterns); dynamic.setLoadOnStartup(0); LOGGER.info("RESTful servlet url pattern: {}.", Arrays.toString(urlPatterns)); return dynamic; }
websocket.setAsyncSupported(true); provisioning.setAsyncSupported(true);
servletRegistration.setInitParameter(key, initParams.get(key)); servletRegistration.setAsyncSupported(true); servletRegistration.setInitParameter("javax.ws.rs.Application", serverData.getModule() .getJaxWsRsApplication());
spanServlet.setAsyncSupported(true); healthServlet.setAsyncSupported(true);
dynamicRegistration.setAsyncSupported(true); dynamicRegistration.setLoadOnStartup(1); registration = dynamicRegistration;
registration.setAsyncSupported(isAsyncSupported());
dynamicRegistration.setAsyncSupported(true); dynamicRegistration.setLoadOnStartup(1); registration = dynamicRegistration;
/** * Add new servlet according to {@link Application} subclass with {@link ApplicationPath} annotation or existing * {@code servlet-mapping}. */ private static void addServletWithApplication(final ServletContext context, final Class<? extends Application> clazz, final Set<Class<?>> defaultClasses) throws ServletException { final ApplicationPath ap = clazz.getAnnotation(ApplicationPath.class); if (ap != null) { // App is annotated with ApplicationPath final ResourceConfig resourceConfig = ResourceConfig.forApplicationClass(clazz, defaultClasses) .addProperties(Utils.getContextParams(context)); final ServletContainer s = new ServletContainer(resourceConfig); final ServletRegistration.Dynamic dsr = context.addServlet(clazz.getName(), s); dsr.setAsyncSupported(true); dsr.setLoadOnStartup(1); final String mapping = createMappingPath(ap); if (!mappingExists(context, mapping)) { dsr.addMapping(mapping); LOGGER.log(Level.CONFIG, LocalizationMessages.JERSEY_APP_REGISTERED_MAPPING(clazz.getName(), mapping)); } else { LOGGER.log(Level.WARNING, LocalizationMessages.JERSEY_APP_MAPPING_CONFLICT(clazz.getName(), mapping)); } } }
@Override public void onStartup(ServletContext servletContext) throws ServletException { String servletName = getServletName(); Assert.hasLength(servletName, "getServletName() must not return null or empty"); ApplicationContext applicationContext = createApplicationContext(); Assert.notNull(applicationContext, "createApplicationContext() must not return null"); refreshApplicationContext(applicationContext); registerCloseListener(servletContext, applicationContext); HttpHandler httpHandler = WebHttpHandlerBuilder.applicationContext(applicationContext).build(); ServletHttpHandlerAdapter servlet = new ServletHttpHandlerAdapter(httpHandler); ServletRegistration.Dynamic registration = servletContext.addServlet(servletName, servlet); if (registration == null) { throw new IllegalStateException("Failed to register servlet with name '" + servletName + "'. " + "Check if there is another servlet registered under the same name."); } registration.setLoadOnStartup(1); registration.addMapping(getServletMapping()); registration.setAsyncSupported(true); }