org.atmosphere.cpr
Class DefaultBroadcaster

java.lang.Object
  extended by org.atmosphere.cpr.DefaultBroadcaster
All Implemented Interfaces:
Broadcaster<String>

public class DefaultBroadcaster
extends Object
implements Broadcaster<String>

Broadcaster implementation. Broadcast messages to suspended reponse using the caller's Thread. This basic Broadcaster isn't using any ExecutorService to broadcast messages, so it is single threaded.

Author:
Jeanfrancois Arcand

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.atmosphere.cpr.Broadcaster
Broadcaster.SCOPE
 
Constructor Summary
DefaultBroadcaster()
           
 
Method Summary
 AtmosphereEvent addAtmosphereEvent(AtmosphereEvent event)
          Add a AtmosphereEvent to the list of item to be notified when the Broadcaster.broadcast(F) is invoked.
 String broadcast(String msg)
          Broadcast the F to all suspended response, e.g.
 String broadcast(String msg, AtmosphereEvent event)
          Broadcast the F to all suspended response, e.g.
 String broadcast(String msg, Set<AtmosphereEvent> subset)
          Broadcast the F to all suspended response, e.g.
 void destroy()
          Destroy this instance and shutdown it's associated ExecutorServices
 Iterator<AtmosphereEvent> getAtmosphereEvents()
          Return an Iterator of AtmosphereEvent
 BroadcasterConfig getBroadcasterConfig()
          Return the current BroadcasterConfig
 String getName()
          Return the name of this Broadcaster
 Broadcaster.SCOPE getScope()
          Retunr the Broadcaster#SCOPE
 AtmosphereEvent removeAtmosphereEvent(AtmosphereEvent event)
          Remove a AtmosphereEvent from the list of item to be notified when the Broadcaster.broadcast(F) is invoked.
 void setBroadcasterConfig(BroadcasterConfig bc)
          Set the BroadcasterConfig instance.
 void setName(String name)
          Set the name of this Broadcaster
 void setScope(Broadcaster.SCOPE scope)
          Set the Broadcaster#SCOPE
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultBroadcaster

public DefaultBroadcaster()
Method Detail

destroy

public void destroy()
Destroy this instance and shutdown it's associated ExecutorServices

Specified by:
destroy in interface Broadcaster<String>

getAtmosphereEvents

public Iterator<AtmosphereEvent> getAtmosphereEvents()
Return an Iterator of AtmosphereEvent

Specified by:
getAtmosphereEvents in interface Broadcaster<String>

setScope

public void setScope(Broadcaster.SCOPE scope)
Set the Broadcaster#SCOPE

Specified by:
setScope in interface Broadcaster<String>

getScope

public Broadcaster.SCOPE getScope()
Retunr the Broadcaster#SCOPE

Specified by:
getScope in interface Broadcaster<String>
Returns:
Broadcaster#SCOPE

setName

public void setName(String name)
Set the name of this Broadcaster

Specified by:
setName in interface Broadcaster<String>
Parameters:
name - of this Broadcaster

getName

public String getName()
Return the name of this Broadcaster

Specified by:
getName in interface Broadcaster<String>
Returns:
the name of this Broadcaster

broadcast

public String broadcast(String msg)
Broadcast the F to all suspended response, e.g. invoke AtmosphereHandler.onMessage(org.atmosphere.cpr.AtmosphereEvent).

Specified by:
broadcast in interface Broadcaster<String>
Parameters:
msg - and F to be shared.
Returns:
the final F, which might have been transformed by MessageTransformer

broadcast

public String broadcast(String msg,
                        AtmosphereEvent event)
Broadcast the F to all suspended response, e.g. invoke AtmosphereHandler.onMessage(org.atmosphere.cpr.AtmosphereEvent) with an instance of AtmosphereEvent, representing a set of AtmosphereHandler.

Specified by:
broadcast in interface Broadcaster<String>
Parameters:
msg - and F to be shared.
event - an AtmosphereEvent
Returns:
the final F, which might have been transformed by MessageTransformer

broadcast

public String broadcast(String msg,
                        Set<AtmosphereEvent> subset)
Broadcast the F to all suspended response, e.g. invoke AtmosphereHandler.onMessage(org.atmosphere.cpr.AtmosphereEvent) with a Set of AtmosphereEvent, representing a set of AtmosphereHandler.

Specified by:
broadcast in interface Broadcaster<String>
Parameters:
msg - and F to be shared.
Returns:
the final F, which might have been transformed by MessageTransformer

addAtmosphereEvent

public AtmosphereEvent addAtmosphereEvent(AtmosphereEvent event)
Add a AtmosphereEvent to the list of item to be notified when the Broadcaster.broadcast(F) is invoked.

Specified by:
addAtmosphereEvent in interface Broadcaster<String>
Parameters:
event - an AtmosphereEvent
Returns:
AtmosphereEvent if added, or null if it was already there.

removeAtmosphereEvent

public AtmosphereEvent removeAtmosphereEvent(AtmosphereEvent event)
Remove a AtmosphereEvent from the list of item to be notified when the Broadcaster.broadcast(F) is invoked.

Specified by:
removeAtmosphereEvent in interface Broadcaster<String>
Parameters:
event - an AtmosphereEvent
Returns:
AtmosphereEvent if removed, or null if it was not.

setBroadcasterConfig

public void setBroadcasterConfig(BroadcasterConfig bc)
Set the BroadcasterConfig instance.

Specified by:
setBroadcasterConfig in interface Broadcaster<String>
Parameters:
bf -

getBroadcasterConfig

public BroadcasterConfig getBroadcasterConfig()
Return the current BroadcasterConfig

Specified by:
getBroadcasterConfig in interface Broadcaster<String>
Returns:
the current BroadcasterConfig


Copyright © 2009 SUN Microsystems. All Rights Reserved.