/** {@inheritDoc} */ public void setScope(SCOPE scope) { this.scope = scope; if (scope != SCOPE.REQUEST) { return; } try { for (AtmosphereResource<?, ?> resource : resources) { Broadcaster b = BroadcasterFactory.getDefault() .get(getClass(), getClass().getSimpleName() + "/" + UUID.randomUUID()); if (DefaultBroadcaster.class.isAssignableFrom(this.getClass())) { BroadcasterCache cache = bc.getBroadcasterCache().getClass().newInstance(); InjectorProvider.getInjector().inject(cache); DefaultBroadcaster.class.cast(b).broadcasterCache = cache; } resource.setBroadcaster(b); if (resource.getAtmosphereResourceEvent().isSuspended()) { b.addAtmosphereResource(resource); } } if (!resources.isEmpty()) { destroy(); } } catch (Exception e) { logger.error("failed to set request scope for current resources", e); } }
protected void start() { if (!started.getAndSet(true)) { broadcasterCache = bc.getBroadcasterCache(); broadcasterCache.start(); notifierFuture = bc.getExecutorService().submit(getBroadcastHandler()); asyncWriteFuture = bc.getAsyncWriteService().submit(getAsyncWriteHandler()); } }