@Bean public AtmosphereFramework atmosphereFramework() { return atmosphereServlet().framework(); }
private void initializeAtmosphere(MultiBitExchangeApiConfiguration configuration, Environment environment) { FilterBuilder fconfig = environment.addFilter(CrossOriginFilter.class, "/stream"); fconfig.setInitParam(CrossOriginFilter.ALLOWED_ORIGINS_PARAM, "*"); AtmosphereServlet atmosphereServlet = new AtmosphereServlet(); atmosphereServlet.framework().addInitParameter("com.sun.jersey.config.property.packages", ATMOSPHERE_RESOURCE_BASE_PACKAGE); atmosphereServlet.framework().addInitParameter("org.atmosphere.websocket.messageContentType", "application/json"); atmosphereServlet.framework().addInitParameter("com.sun.jersey.config.feature.DisableWADL", "true"); atmosphereServlet.framework().addInitParameter("org.atmosphere.cpr.AtmosphereInterceptor.disableDefaults", "true"); atmosphereServlet.framework().addInitParameter("org.atmosphere.cpr.broadcasterCacheClass", "org.atmosphere.cache.UUIDBroadcasterCache"); atmosphereServlet.framework().addInitParameter("org.atmosphere.cpr.sessionSupport", "true"); atmosphereServlet.framework().addInitParameter("org.atmosphere.cpr.AtmosphereResource.uniqueUUID", "true"); atmosphereServlet.framework().addInitParameter(ApplicationConfig.class.getName() + ".scanClassPath", "false"); environment.addServlet(atmosphereServlet, "/stream/*"); } }
AtmosphereServlet s = new AtmosphereServlet(); AtmosphereFramework f = s.framework(); ReflectorServletProcessor r = new ReflectorServletProcessor(); r.setServletClassName("com.sun.jersey.spi.spring.container.servlet.SpringServlet"); f.addAtmosphereHandler("/api/*", r); ServletRegistration atmosphereServletRegistration = ctx.addServlet("AtmosphereServlet", s);
public AtmosphereBridge(ServletContext context, String path) { AtmosphereServlet servlet = null; try { servlet = context.createServlet(AtmosphereServlet.class); } catch (ServletException e) { throw new RuntimeException(e); } AtmosphereFramework framework = servlet.framework(); framework.addAtmosphereHandler("/", new AtmosphereHandlerAdapter() { @Override public void onRequest(AtmosphereResource resource) throws IOException { if (resource.transport() == TRANSPORT.WEBSOCKET) { if (resource.getRequest().getMethod().equals("GET")) { wsActions.fire(new AtmosphereServerWebSocket(resource)); } } else { httpActions.fire(new AtmosphereServerHttpExchange(resource)); } } }); ServletRegistration.Dynamic reg = context.addServlet("wes#" + UUID.randomUUID(), servlet); reg.setAsyncSupported(true); reg.addMapping(path); }
private void installAtmosphere(ServletContext context, Options options) { AtmosphereServlet servlet = null; try { servlet = context.createServlet(AtmosphereServlet.class); } catch (ServletException e) { throw new IllegalStateException(e); } ServletRegistration.Dynamic registration = context.addServlet("portal#" + options.name(), servlet); registration.setLoadOnStartup(0); registration.setAsyncSupported(true); registration.addMapping(options.url()); registration.setInitParameter(ApplicationConfig.DISABLE_ATMOSPHEREINTERCEPTOR, Boolean.FALSE.toString()); modifyAtmosphereServletRegistration(registration); logger.info("AtmosphereServlet '{}' is installed in accordance with the registration '{}'", servlet, registration); framework = servlet.framework(); }