public static boolean isJetty(AtmosphereResource r) { final String container = r.getAtmosphereConfig().getServletContext().getServerInfo(); if (container != null && container.toLowerCase().indexOf("jetty") != -1) { return true; } return false; } }
@Ready public void onReady(AtmosphereResource resource) throws Exception { factory = resource.getAtmosphereConfig().getBroadcasterFactory(); resourceFactory = resource.getAtmosphereConfig().resourcesFactory(); notificationService = (NotificationService) resource.getAtmosphereConfig().getServletContext().getAttribute(AtmosphereModule.NOTIFICATION_SERVICE); if(!notificationService.subscribe(topicName, resource)) { logger.debug("Subscription to topic {} refused (resource: {})", topicName, resource); close(resource); } }
private String path; private BroadcasterFactory broadcasterFactory; @Ready(value = Ready.DELIVER_TO.ALL) public void onReady(final AtmosphereResource r) { System.out.println("onConnect"); r.addEventListener(new AtmosphereConnectionController()); if(broadcasterFactory == null){ path = r.getBroadcaster().getID(); broadcasterFactory = r.getAtmosphereConfig().getBroadcasterFactory(); } } //later in code broadcasterFactory.lookup(path).broadcast("message");
@Override public Object fromString(String topic) { Broadcaster broadcaster; try { AtmosphereResource r = (AtmosphereResource) req.getAttribute(FrameworkConfig.ATMOSPHERE_RESOURCE); BroadcasterFactory bp = r.getAtmosphereConfig().getBroadcasterFactory(); Class<? extends Broadcaster> c; try { c = (Class<Broadcaster>) Class.forName((String) req.getAttribute(ApplicationConfig.BROADCASTER_CLASS)); } catch (Throwable e) { throw new IllegalStateException(e.getMessage()); } broadcaster = bp.lookup(c, topic, true); } catch (Throwable ex) { throw new WebApplicationException(ex); } logger.trace("Injected Broadcaster {}", broadcaster); req.setAttribute(AtmosphereFilter.INJECTED_BROADCASTER, broadcaster); return broadcaster; } }
@Override public BroadcasterFactory getValue() { return getAtmosphereResource(AtmosphereResource.class, true).getAtmosphereConfig().getBroadcasterFactory(); } };
BroadcasterFactory _get() { return getAtmosphereResource(AtmosphereResource.class, true).getAtmosphereConfig().getBroadcasterFactory(); }
private void ensureInitialized(AtmosphereResource resource) { if (userRepository == null) { Injector injector = (Injector) resource.getAtmosphereConfig().getServletContext().getAttribute(Injector.class.getName()); injector.injectMembers(this); } if (broadcastConsumer == null) { broadcastConsumer = new WorkQueueRepository.BroadcastConsumer() { @Override public void broadcastReceived(JSONObject json) { if (broadcaster != null) { broadcaster.broadcast(json.toString()); } } }; this.workQueueRepository.subscribeToBroadcastMessages(broadcastConsumer); } broadcaster = resource.getBroadcaster(); }
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 resume() { try { r.getAtmosphereConfig().framework().doCometSupport(r.getRequest(), r.getResponse()); } catch (IOException e) { logger.warn("",e); } catch (ServletException e) { logger.warn("", e); } r.resume(); }
public void onRequest(AtmosphereResource resource) throws IOException { AtmosphereRequest r = resource.getRequest(); // We only handle GET. POST are supported by PrimeFaces directly via the Broadcaster. if (r.getMethod().equalsIgnoreCase("GET")) { applyRules(resource); } else { StringBuilder stringBuilder = read(resource); resource.getAtmosphereConfig().metaBroadcaster().broadcastTo("/*", stringBuilder.toString()); } }
@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); } } });
static void writeResponse(AtmosphereResource resource, Object message) throws IOException { try { RPCRequest rpcRequest = (RPCRequest) resource.getRequest().getAttribute(AtmospherePollService.GWT_REQUEST); String response = encodeResponse(rpcRequest, message); writeResponse(resource.getRequest(), resource.getResponse(), resource.getAtmosphereConfig().getServletContext(), response); } catch (IncompatibleRemoteServiceException ex) { try { String error = RPC.encodeResponseForFailure(null, ex); writeResponse(resource.getRequest(), resource.getResponse(), resource.getAtmosphereConfig().getServletContext(), error); } catch (SerializationException ex2) { throw new IOException(ex2); } } catch (SerializationException ex) { throw new IOException(ex); } }
BroadcasterFactory broadcasterFactory = r.getAtmosphereConfig().getBroadcasterFactory();
b = configureHeaders(b); AtmosphereConfig config = r.getAtmosphereConfig();
@Override public Action inspect(AtmosphereResource r) { final SecurityContextRepository securityContextRepo = getSecurityContextRepository( r.getAtmosphereConfig().getServletContext()); if (securityContextRepo.containsContext(r.getRequest())) { LOGGER.trace("Loading the security context from the session"); final HttpRequestResponseHolder requestResponse = new HttpRequestResponseHolder(r.getRequest(), r.getResponse()); final SecurityContext securityContext = securityContextRepo.loadContext(requestResponse); SecurityContextHolder.setContext(securityContext); } return Action.CONTINUE; }
@Override public Action inspect(AtmosphereResource r) { final SecurityContextRepository securityContextRepo = getSecurityContextRepository( r.getAtmosphereConfig().getServletContext()); if (securityContextRepo.containsContext(r.getRequest())) { LOGGER.trace("Loading the security context from the session"); final HttpRequestResponseHolder requestResponse = new HttpRequestResponseHolder(r.getRequest(), r.getResponse()); final SecurityContext securityContext = securityContextRepo.loadContext(requestResponse); SecurityContextHolder.setContext(securityContext); } return Action.CONTINUE; }
m = r.getAtmosphereConfig().getInitParameter(ApplicationConfig.SSE_CONTENT_TYPE); if (m == null) { m = "text/plain";
/** * Creates channel (named {@link Broadcaster} in Atmosphere) based on the {@link org.atmosphere.cpr.AtmosphereRequest#getPathInfo()} * * @param resource An {@link AtmosphereResource} * @return */ public boolean apply(AtmosphereResource resource) { String pathInfo = resource.getRequest().getPathInfo(); BroadcasterFactory f = resource.getAtmosphereConfig().getBroadcasterFactory(); if (pathInfo == null) { resource.setBroadcaster(f.lookup("/*")); return true; } final Broadcaster b = f.lookup(pathInfo, true); resource.setBroadcaster(b); return true; } }
AtmosphereResponse response = null; AtmosphereFramework framework = r.getAtmosphereConfig().framework(); try { byte[] data = WebSocketUtils.readBody(request.getInputStream());