org.atmosphere.util
Class SimpleBroadcaster

java.lang.Object
  extended by org.atmosphere.cpr.DefaultBroadcaster
      extended by org.atmosphere.util.SimpleBroadcaster
All Implemented Interfaces:
Broadcaster
Direct Known Subclasses:
JerseySimpleBroadcaster

public class SimpleBroadcaster
extends DefaultBroadcaster

Simple Broadcaster implementation that use the calling thread when broadcasting events.

Author:
Jeanfrancois Arcand

Nested Class Summary
 
Nested classes/interfaces inherited from class org.atmosphere.cpr.DefaultBroadcaster
DefaultBroadcaster.AsyncWriteToken, DefaultBroadcaster.WriteQueue
 
Nested classes/interfaces inherited from interface org.atmosphere.cpr.Broadcaster
Broadcaster.POLICY, Broadcaster.SCOPE
 
Field Summary
 
Fields inherited from class org.atmosphere.cpr.DefaultBroadcaster
ASYNC_TOKEN, asyncWriteFuture, bc, broadcasterListeners, broadcastOnResume, CACHED, config, delayedBroadcast, destroyed, dispatchThread, initialized, lifeCycleListeners, messages, name, notifierFuture, POLLING_DEFAULT, resources, scope, started, uniqueWriteQueue, uri, waitTime, writeQueues, writeTimeoutInSecond
 
Fields inherited from interface org.atmosphere.cpr.Broadcaster
ROOT_MASTER
 
Constructor Summary
SimpleBroadcaster()
           
 
Method Summary
 Future<Object> broadcast(Object msg)
          Broadcast the Object to all suspended responses, eg.
 Future<Object> broadcast(Object msg, AtmosphereResource r)
          Broadcast the Object to all suspended responses, eg.
 Future<Object> broadcast(Object msg, Set<AtmosphereResource> subset)
          Broadcast the Object to all suspended response, eg.
protected  BroadcasterConfig createBroadcasterConfig(AtmosphereConfig config)
          Create BroadcasterConfig.
 Broadcaster initialize(String id, AtmosphereConfig config)
           
protected  void prepareInvokeOnStateChange(AtmosphereResource r, AtmosphereResourceEvent e)
           
protected  void queueWriteIO(AtmosphereResource r, Deliver deliver, AtomicInteger count)
           
 void setBroadcasterConfig(BroadcasterConfig bc)
          Set the BroadcasterConfig instance.
protected  void start()
           
 
Methods inherited from class org.atmosphere.cpr.DefaultBroadcaster
addAtmosphereResource, addBroadcasterLifeCyclePolicyListener, addBroadcasterListener, awaitAndBroadcast, broadcasterListeners, broadcastOnResume, broadcastOnResume, cacheAndSuspend, cacheLostMessage, cacheLostMessage, cacheLostMessage, cacheLostMessage, checkCachedAndPush, delayBroadcast, delayBroadcast, deliverPush, destroy, dispatchMessages, endBroadcast, entryDone, executeAsyncWrite, executeBlockingWrite, filter, futureDone, getAsyncWriteHandler, getAtmosphereResources, getBroadcasterConfig, getBroadcastHandler, getID, getScope, initialize, invokeOnStateChange, isDestroyed, killReactiveThreads, lifeCycleListeners, lifeCyclePolicy, messages, notifyAndAdd, notifyBroadcastListener, notifyDestroyListener, notifyEmptyListener, notifyIdleListener, notifyOnAddAtmosphereResourceListener, notifyOnMessage, notifyOnRemoveAtmosphereResourceListener, onException, onException, outOfOrderBroadcastSupported, perRequestFilter, policy, push, reactiveThreadsCount, releaseExternalResources, removeAtmosphereResource, removeAtmosphereResource, removeBroadcasterLifeCyclePolicyListener, removeBroadcasterListener, resumeAll, retrieveTrackedBroadcast, scheduleFixedBroadcast, scheduleFixedBroadcast, setBroadcasterLifeCyclePolicy, setID, setScope, setSuspendPolicy, spawnReactor, toString, writeQueues
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SimpleBroadcaster

public SimpleBroadcaster()
Method Detail

initialize

public Broadcaster initialize(String id,
                              AtmosphereConfig config)
Overrides:
initialize in class DefaultBroadcaster

createBroadcasterConfig

protected BroadcasterConfig createBroadcasterConfig(AtmosphereConfig config)
Description copied from class: DefaultBroadcaster
Create BroadcasterConfig.

Overrides:
createBroadcasterConfig in class DefaultBroadcaster
Parameters:
config - the AtmosphereConfig
Returns:
an instance of BroadcasterConfig

start

protected void start()
Overrides:
start in class DefaultBroadcaster

setBroadcasterConfig

public void setBroadcasterConfig(BroadcasterConfig bc)
Description copied from interface: Broadcaster
Set the BroadcasterConfig instance.

Specified by:
setBroadcasterConfig in interface Broadcaster
Overrides:
setBroadcasterConfig in class DefaultBroadcaster
Parameters:
bc - Configuration to be set.

broadcast

public Future<Object> broadcast(Object msg)
Description copied from interface: Broadcaster
Broadcast the Object to all suspended responses, eg. invoke AtmosphereHandler.onStateChange(org.atmosphere.cpr.AtmosphereResourceEvent).

Specified by:
broadcast in interface Broadcaster
Overrides:
broadcast in class DefaultBroadcaster
Parameters:
msg - the Object to be broadcasted
Returns:
a Future that can be used to synchronize using the Future.get()

broadcast

public Future<Object> broadcast(Object msg,
                                AtmosphereResource r)
Description copied from interface: Broadcaster
Broadcast the Object to all suspended responses, eg. invoke AtmosphereHandler.onStateChange(org.atmosphere.cpr.AtmosphereResourceEvent) with an instance of AtmosphereResource, representing a single suspended response.

Specified by:
broadcast in interface Broadcaster
Overrides:
broadcast in class DefaultBroadcaster
Parameters:
msg - the Object to be broadcasted
r - an AtmosphereResource
Returns:
a Future that can be used to synchronize using the Future.get()

broadcast

public Future<Object> broadcast(Object msg,
                                Set<AtmosphereResource> subset)
Description copied from interface: Broadcaster
Broadcast the Object to all suspended response, eg. invoke AtmosphereHandler.onStateChange(org.atmosphere.cpr.AtmosphereResourceEvent) with a Set of AtmosphereResource, representing a set of AtmosphereHandler.

Specified by:
broadcast in interface Broadcaster
Overrides:
broadcast in class DefaultBroadcaster
Parameters:
msg - the Object to be broadcasted
subset - a Set of AtmosphereResource
Returns:
a Future that can be used to synchronize using the Future.get()

prepareInvokeOnStateChange

protected void prepareInvokeOnStateChange(AtmosphereResource r,
                                          AtmosphereResourceEvent e)
Overrides:
prepareInvokeOnStateChange in class DefaultBroadcaster

queueWriteIO

protected void queueWriteIO(AtmosphereResource r,
                            Deliver deliver,
                            AtomicInteger count)
                     throws InterruptedException
Overrides:
queueWriteIO in class DefaultBroadcaster
Throws:
InterruptedException


Copyright © 2014. All rights reserved.