@Override public AtmosphereFramework get() { return config.framework(); } });
@Override public AtmosphereFramework get() { return config.framework(); } });
@Override public <T, U extends T> U newClassInstance(Class<T> classType, Class<U> classToInstantiate) throws InstantiationException, IllegalAccessException { initInjector(config.framework()); U t; if (injector != null) { t = injector.getInstance(classToInstantiate); } else { logger.warn("No Guice Injector found in current ServletContext. Are you using {}?", AtmosphereGuiceServlet.class.getName()); logger.trace("Unable to find {}. Creating the object directly.", classToInstantiate.getName()); t = classToInstantiate.newInstance(); } return t; }
@Override public <T, U extends T> U newClassInstance(Class<T> classType, Class<U> classToInstantiate) throws InstantiationException, IllegalAccessException { initInjector(config.framework()); U t; if (injector != null) { t = injector.getInstance(classToInstantiate); } else { logger.warn("No Guice Injector found in current ServletContext. Are you using {}?", AtmosphereGuiceServlet.class.getName()); logger.trace("Unable to find {}. Creating the object directly.", classToInstantiate.getName()); t = classToInstantiate.newInstance(); } return t; }
protected AnnotatedProxy proxyHandler() throws IllegalAccessException, InstantiationException { return config.framework().newClassInstance(AnnotatedProxy.class, PushEndpointHandlerProxy.class); }
@Override public void configure(AtmosphereConfig config) { config.framework().broadcasterFilters(encoder); }
private void populateDecoders() { for (Method m : onMessageMethods) { List<Decoder<?, ?>> l = new CopyOnWriteArrayList<Decoder<?, ?>>(); for (Class<? extends Decoder> s : m.getAnnotation(OnMessage.class).decoders()) { try { l.add(config.framework().newClassInstance(Decoder.class, s)); } catch (Exception e) { LOG.error("Unable to load encoder {}", s); } } decoders.put(m, l); } }
private void populateEncoders() { for (Method m : onMessageMethods) { List<Encoder<?, ?>> l = new CopyOnWriteArrayList<Encoder<?, ?>>(); for (Class<? extends Encoder> s : m.getAnnotation(OnMessage.class).encoders()) { try { l.add(config.framework().newClassInstance(Encoder.class, s)); } catch (Exception e) { LOG.error("Unable to load encoder {}", s); } } encoders.put(m, l); } }
@Override public void configure(AtmosphereConfig config) { servletPath = IOUtils.guestServletPath(config); config.framework().getAtmosphereConfig().properties().put("servletPath", servletPath); this.config = config; }
private void _close(AtmosphereRequest request) { AtmosphereResourceImpl r = AtmosphereResourceImpl.class.cast(request.resource()); if (request != null && r != null) { AsynchronousProcessor.class.cast(r.getAtmosphereConfig().framework().getAsyncSupport()).endRequest(r, true); } }
@Override public void configure(final AtmosphereConfig config) { framework = config.framework(); supportWebSocket = config.framework().getAsyncSupport().supportWebSocket(); config.properties().put(HeaderConfig.JSONP_CALLBACK_NAME, "c"); for (AtmosphereInterceptor i : framework.interceptors()) { if (HeartbeatInterceptor.class.isAssignableFrom(i.getClass())) { HeartbeatInterceptor.class.cast(i).paddingText("h".getBytes()).heartbeatFrequencyInSeconds(25); } } if (config.handlers().size() == 0) { framework.addAtmosphereHandler("/*", ECHO_ATMOSPHEREHANDLER); } }
if (doneProcessing.get() && !response.resource().getAtmosphereConfig().framework().isDestroyed()){ throw Utils.ioExceptionForChannel(channel, response.uuid());
if (doneProcessing.get() && !response.resource().getAtmosphereConfig().framework().isDestroyed()){ throw Utils.ioExceptionForChannel(channel, response.uuid());
@Override public void configure(AtmosphereConfig config) { try { String s = config.getInitParameter(ATMOSPHERE_SPRING_EXCLUDE_CLASSES); if (s != null) { String[] list = s.split(","); for (String clazz : list) { excludedFromInjection.add(IOUtils.loadClass(getClass(), clazz)); } if (list.length > 0) { preventSpringInjection = true; } } context = new AnnotationConfigApplicationContext(); context.setParent(WebApplicationContextUtils.getWebApplicationContext(config.framework().getServletContext())); context.refresh(); // Hack to make it injectable context.register(AtmosphereConfig.class); ((AtmosphereConfig) context.getBean(AtmosphereConfig.class.getCanonicalName(), config.framework())).populate(config); } catch (Exception ex) { logger.warn("Unable to configure injection", ex); } } }
@Override public void configure(AtmosphereConfig config) { if (config.getServletContext().getServerInfo().contains("jetty")) { config.framework().setAsyncSupport(new JettyAsyncSupport( config)); } }
@Override public void resume() { try { r.getAtmosphereConfig().framework().doCometSupport(r.getRequest(), r.getResponse()); } catch (IOException e) { logger.warn("",e); } catch (ServletException e) { logger.warn("", e); } r.resume(); }
@Override public U map(AtmosphereRequest req, Map<String, U> handlers) { U handler = super.map(req, handlers); if (handler == null) { synchronized (config) { LOGER.trace("Preserving backward PrimeFaces behavior"); PrimeAtmosphereHandler pah = new PrimeAtmosphereHandler(configureRules(config.getServletConfig())); String path = computePath(req); config.framework().addAtmosphereHandler(path, pah); handler = (U) config.framework().getAtmosphereHandlers().get(path); req.setAttribute(FrameworkConfig.MAPPED_PATH, path); } } return handler; }
public JettyAsyncSupport(AtmosphereConfig config) { super(config); final WebSocketProcessor webSocketProcessor = WebSocketProcessorFactory.getDefault().getWebSocketProcessor(config.framework()); WebSocketFactory wsf; try { String[] jettyVersion = config.getServletContext().getServerInfo().substring(6).split("\\."); if (Integer.valueOf(jettyVersion[0]) > 7 || Integer.valueOf(jettyVersion[0]) == 7 && Integer.valueOf(jettyVersion[1]) > 4) { wsf = JettyWebSocketUtil.getFactory(config, webSocketProcessor); } else { wsf = null; } } catch (Throwable e) { // If we can't parse Jetty version, assume it's 8 and up. try { logger.trace("Unable to parse Jetty version {}", config.getServletContext().getServerInfo()); } catch (Throwable t) { } wsf = JettyWebSocketUtil.getFactory(config, webSocketProcessor); } webSocketFactory = wsf; }
@Override public void onResume(AtmosphereResourceEvent event) { if (event.isResuming()) { listener.onComplete(AtmosphereContinuation.this); } else { try { r.getAtmosphereConfig().framework().doCometSupport(r.getRequest(), r.getResponse()); } catch (IOException e) { logger.warn("", e); } catch (ServletException e) { logger.warn("", e); } listener.onTimeout(AtmosphereContinuation.this); } } });
@Override public void preStart() { try { this.playWebSocket = new PlayWebSocket(actorRef, atmosphereConfig); this.webSocketProcessor = WebSocketProcessorFactory.getDefault().getWebSocketProcessor(atmosphereConfig.framework()); AtmosphereRequest atmosphereRequest = AtmosphereUtils.request(new Http.RequestImpl(requestHeader), additionalAttributes); this.webSocketProcessor.open(playWebSocket, atmosphereRequest, AtmosphereResponseImpl.newInstance(atmosphereConfig, atmosphereRequest, playWebSocket)); } catch (Throwable throwable) { LOG.error("Failed to start the actor ", throwable); } }