|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.atmosphere.cpr.DefaultBroadcaster
public class DefaultBroadcaster
Broadcaster implementation.
Broadcaster use an ExecutorService
to broadcast message, hence the broadcast operation is asynchronous. Make sure
you block on broadcast(Object).get()} if you need synchronous operations.
| Nested Class Summary | |
|---|---|
class |
DefaultBroadcaster.Entry
|
| Nested classes/interfaces inherited from interface org.atmosphere.cpr.Broadcaster |
|---|
Broadcaster.POLICY, Broadcaster.SCOPE |
| Field Summary | |
|---|---|
protected BroadcasterConfig |
bc
|
protected BroadcasterCache |
broadcasterCache
|
protected ConcurrentLinkedQueue<DefaultBroadcaster.Entry> |
delayedBroadcast
|
protected AtomicBoolean |
destroyed
|
protected ConcurrentLinkedQueue<AtmosphereResource<?,?>> |
events
|
protected BlockingQueue<DefaultBroadcaster.Entry> |
messages
|
protected String |
name
|
protected Broadcaster.SCOPE |
scope
|
protected AtomicBoolean |
started
|
| Constructor Summary | |
|---|---|
DefaultBroadcaster()
|
|
DefaultBroadcaster(String name)
|
|
| Method Summary | |
|---|---|
AtmosphereResource<?,?> |
addAtmosphereResource(AtmosphereResource<?,?> r)
Add a AtmosphereResource,?> to the list of item to be notified when
the Broadcaster.broadcast(java.lang.Object) is invoked. |
protected void |
broadcast(AtmosphereResource<?,?> r,
AtmosphereResourceEvent e)
|
Future<Object> |
broadcast(Object msg)
Broadcast the Object to all suspended response, e.g. |
Future<Object> |
broadcast(Object msg,
AtmosphereResource<?,?> r)
Broadcast the Object to all suspended response, e.g. |
Future<Object> |
broadcast(Object msg,
Set<AtmosphereResource<?,?>> subset)
Broadcast the Object to all suspended response, e.g. |
protected void |
checkCachedAndPush(AtmosphereResource<?,?> r,
AtmosphereResourceEvent e)
|
Future<Object> |
delayBroadcast(Object o)
Delay the broadcast operation. |
Future<Object> |
delayBroadcast(Object o,
long delay,
TimeUnit t)
Delay the broadcast operation. |
void |
destroy()
Destroy this instance and shutdown it's associated ExecutorService |
protected Object |
filter(Object msg)
Invoke the BroadcastFilter |
Collection<AtmosphereResource<?,?>> |
getAtmosphereResources()
Return an List of AtmosphereResource,?>. |
BroadcasterConfig |
getBroadcasterConfig()
Return the current BroadcasterConfig |
String |
getID()
Return the id of this Broadcaster |
Broadcaster.SCOPE |
getScope()
Return the Broadcaster.SCOPE |
protected void |
onException(Throwable t,
AtmosphereResource<?,?> r)
|
protected void |
push(AtmosphereResource<?,?> r,
Object msg)
|
protected void |
push(DefaultBroadcaster.Entry msg)
|
AtmosphereResource<?,?> |
removeAtmosphereResource(AtmosphereResource r)
Remove a AtmosphereResource,?> from the list of item to be notified when
the Broadcaster.broadcast(java.lang.Object) is invoked. |
void |
resumeAll()
Resume all suspended responses ( AtmosphereResource,?>) added via
Broadcaster.addAtmosphereResource(org.atmosphere.cpr.AtmosphereResource, ?>). |
protected boolean |
retrieveTrackedBroadcast(AtmosphereResource<?,?> r,
AtmosphereResourceEvent e)
|
Future<?> |
scheduleFixedBroadcast(Object o,
long waitFor,
long period,
TimeUnit t)
Broadcast periodically. |
Future<?> |
scheduleFixedBroadcast(Object o,
long period,
TimeUnit t)
Broadcast periodically. |
void |
setBroadcasterConfig(BroadcasterConfig bc)
Set the BroadcasterConfig instance. |
void |
setID(String id)
Set the id of this Broadcaster |
void |
setScope(Broadcaster.SCOPE scope)
Set the scope. |
void |
setSuspendPolicy(long maxSuspendResource,
Broadcaster.POLICY policy)
Set the maximum number of suspended AtmosphereResource. |
protected void |
start()
|
String |
toString()
|
protected void |
trackBroadcastMessage(AtmosphereResource<?,?> r,
Object msg)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected final ConcurrentLinkedQueue<AtmosphereResource<?,?>> events
protected BroadcasterConfig bc
protected final BlockingQueue<DefaultBroadcaster.Entry> messages
protected final AtomicBoolean started
protected final AtomicBoolean destroyed
protected Broadcaster.SCOPE scope
protected String name
protected final ConcurrentLinkedQueue<DefaultBroadcaster.Entry> delayedBroadcast
protected BroadcasterCache broadcasterCache
| Constructor Detail |
|---|
public DefaultBroadcaster()
public DefaultBroadcaster(String name)
| Method Detail |
|---|
public void destroy()
ExecutorService
destroy in interface Broadcasterpublic Collection<AtmosphereResource<?,?>> getAtmosphereResources()
List of AtmosphereResource,?>.
getAtmosphereResources in interface BroadcasterList of AtmosphereResource,?> associated with this Broadcaster.Broadcaster.addAtmosphereResource(AtmosphereResource,?>)public void setScope(Broadcaster.SCOPE scope)
setScope in interface Broadcasterscope - Broadcaster.SCOPE to set.public Broadcaster.SCOPE getScope()
Broadcaster.SCOPE
getScope in interface BroadcasterBroadcaster.SCOPE of Broadcaster.public void setID(String id)
Broadcaster
setID in interface Broadcasterid - ID of this Broadcasterpublic String getID()
Broadcaster
getID in interface BroadcasterBroadcasterpublic void resumeAll()
AtmosphereResource,?>) added via
Broadcaster.addAtmosphereResource(org.atmosphere.cpr.AtmosphereResource, ?>).
resumeAll in interface Broadcasterprotected void start()
protected void push(DefaultBroadcaster.Entry msg)
protected void push(AtmosphereResource<?,?> r,
Object msg)
protected void checkCachedAndPush(AtmosphereResource<?,?> r,
AtmosphereResourceEvent e)
protected boolean retrieveTrackedBroadcast(AtmosphereResource<?,?> r,
AtmosphereResourceEvent e)
protected void trackBroadcastMessage(AtmosphereResource<?,?> r,
Object msg)
protected void broadcast(AtmosphereResource<?,?> r,
AtmosphereResourceEvent e)
protected void onException(Throwable t,
AtmosphereResource<?,?> r)
public void setSuspendPolicy(long maxSuspendResource,
Broadcaster.POLICY policy)
BroadcasterAtmosphereResource. If the max is reached, Atmosphere will either
resume AtmosphereResource using Broadcaster.POLICY.FIFO (first in first out)
or Broadcaster.POLICY.REJECT the AtmosphereResource.
By default the number is uunlimited.
setSuspendPolicy in interface BroadcastermaxSuspendResource - max suspendedpublic Future<Object> broadcast(Object msg)
Object to all suspended response, e.g. invoke
AtmosphereHandler.onStateChange(org.atmosphere.cpr.AtmosphereResourceEvent) .
broadcast in interface Broadcastermsg - and Object to be broadcasted.
Future that can be used to synchronize using the Future.get()protected Object filter(Object msg)
BroadcastFilter
msg -
public Future<Object> broadcast(Object msg,
AtmosphereResource<?,?> r)
Object to all suspended response, e.g. invoke
AtmosphereHandler.onStateChange(org.atmosphere.cpr.AtmosphereResourceEvent) with an instance of AtmosphereResource,?>, representing
a single suspended response..
broadcast in interface Broadcastermsg - and Object to be broadcasted.r - an AtmosphereResource,?>
Future that can be used to synchronize using the Future.get()
public Future<Object> broadcast(Object msg,
Set<AtmosphereResource<?,?>> subset)
Object to all suspended response, e.g. invoke
AtmosphereHandler.onStateChange(org.atmosphere.cpr.AtmosphereResourceEvent) with a Set of AtmosphereResource,?>,
representing a set of AtmosphereHandler.
broadcast in interface Broadcastermsg - and Object to be broadcasted.subset - a Set of AtmosphereResource,?>
Future that can be used to synchronize using the Future.get()public AtmosphereResource<?,?> addAtmosphereResource(AtmosphereResource<?,?> r)
AtmosphereResource,?> to the list of item to be notified when
the Broadcaster.broadcast(java.lang.Object) is invoked.
addAtmosphereResource in interface Broadcasterr - an AtmosphereResource,?>
AtmosphereResource,?> if added, or null if it was already there.public AtmosphereResource<?,?> removeAtmosphereResource(AtmosphereResource r)
AtmosphereResource,?> from the list of item to be notified when
the Broadcaster.broadcast(java.lang.Object) is invoked.
removeAtmosphereResource in interface Broadcasterr - an AtmosphereResource,?>
AtmosphereResource,?> if removed, or null if it was not.public void setBroadcasterConfig(BroadcasterConfig bc)
BroadcasterConfig instance.
setBroadcasterConfig in interface Broadcasterbc - public BroadcasterConfig getBroadcasterConfig()
BroadcasterConfig
getBroadcasterConfig in interface BroadcasterBroadcasterConfigpublic Future<Object> delayBroadcast(Object o)
Object will be broadcasted
when the first Broadcaster.broadcast(java.lang.Object)
is invoked.
delayBroadcast in interface Broadcastero - and Object to be broadcasted.
Future that can be used to synchronize using the Future.get()
public Future<Object> delayBroadcast(Object o,
long delay,
TimeUnit t)
Object will be broadcasted once the
specified delay expires or when the first Broadcaster.broadcast(java.lang.Object)
delayBroadcast in interface Broadcastero - and Object to be broadcasted.delay - Amount of time to delay.t - a TimeUnit of delay.
Future that can be used to synchronize using the Future.get()
public Future<?> scheduleFixedBroadcast(Object o,
long period,
TimeUnit t)
Object will be broadcasted after every period
specified time frame expires. If the TimeUnit is set null, the
Object will be broadcasted when the first Broadcaster.broadcast(java.lang.Object)
is invoked.
scheduleFixedBroadcast in interface Broadcastero - and Object to be broadcasted.period - Every so often broadcast.t - a TimeUnit of period.
Future that can be used to synchronize using the Future.get()
public Future<?> scheduleFixedBroadcast(Object o,
long waitFor,
long period,
TimeUnit t)
Object will be broadcasted after every period
specified time frame expires. If the TimeUnit is set null, the
Object will be broadcasted when the first Broadcaster.broadcast(java.lang.Object) * is invoked.
scheduleFixedBroadcast in interface Broadcastero - and Object to be broadcasted.waitFor - Wait for that long before first broadcast.period - The period inbetween broadcast.t - a TimeUnit of waitFor and period.
Future that can be used to synchronize using the Future.get()public String toString()
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||