org.atmosphere.cpr
Interface Broadcaster<D,E,F>

All Known Implementing Classes:
DefaultBroadcaster

public interface Broadcaster<D,E,F>

A Broadcaster is responsible for delivering messages to its subscribed AtmosphereEvent, which are representing a suspended response. AtmosphereEvent can be added using addAtmosphereEvent(org.atmosphere.cpr.AtmosphereEvent), so when broadcast(java.lang.Object) execute, AtmosphereHandler.onMessage(org.atmosphere.cpr.AtmosphereEvent) will by invoked and the suspended connection will have a chance to write the message available using AtmosphereEvent.getMessage()
A Broadcaster, by default, will use an ExecutorService, and the number of Thread will be computed based on the core/cpu of the OS under which the application run.

Author:
Jeanfrancois Arcand

Nested Class Summary
static class Broadcaster.SCOPE
           
 
Method Summary
 AtmosphereEvent addAtmosphereEvent(AtmosphereEvent<D,E> event)
          Add a AtmosphereEvent to the list of item to be notified when the broadcast(F) is invoked.
 Future<F> broadcast(F o)
          Broadcast the F to all suspended response, e.g.
 Future<F> broadcast(F o, AtmosphereEvent event)
          Broadcast the F to all suspended response, e.g.
 Future<F> broadcast(F o, 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<HttpServletRequest,HttpServletResponse>> 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<D,E> event)
          Remove a AtmosphereEvent from the list of item to be notified when the 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
 

Method Detail

broadcast

Future<F> broadcast(F o)
Broadcast the F to all suspended response, e.g. invoke AtmosphereHandler.onMessage(org.atmosphere.cpr.AtmosphereEvent).

Parameters:
o - and F to be shared.
Returns:
the final F, which might have been transformed by BroadcasterFilter

broadcast

Future<F> broadcast(F o,
                    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.

Parameters:
o - and F to be shared.
event - an AtmosphereEvent
Returns:
the final F, which might have been transformed by BroadcasterFilter

broadcast

Future<F> broadcast(F o,
                    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.

Parameters:
o - and F to be shared.
event - an AtmosphereEvent
Returns:
the final F, which might have been transformed by BroadcasterFilter

addAtmosphereEvent

AtmosphereEvent addAtmosphereEvent(AtmosphereEvent<D,E> event)
Add a AtmosphereEvent to the list of item to be notified when the broadcast(F) is invoked.

Parameters:
event - an AtmosphereEvent
Returns:
AtmosphereEvent if added, or null if it was already there.

removeAtmosphereEvent

AtmosphereEvent removeAtmosphereEvent(AtmosphereEvent<D,E> event)
Remove a AtmosphereEvent from the list of item to be notified when the broadcast(F) is invoked.

Parameters:
event - an AtmosphereEvent
Returns:
AtmosphereEvent if removed, or null if it was not.

setBroadcasterConfig

void setBroadcasterConfig(BroadcasterConfig bc)
Set the BroadcasterConfig instance.

Parameters:
bf -

getBroadcasterConfig

BroadcasterConfig getBroadcasterConfig()
Return the current BroadcasterConfig

Returns:
the current BroadcasterConfig

destroy

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


getAtmosphereEvents

Iterator<AtmosphereEvent<HttpServletRequest,HttpServletResponse>> getAtmosphereEvents()
Return an Iterator of AtmosphereEvent


setScope

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


getScope

Broadcaster.SCOPE getScope()
Retunr the Broadcaster#SCOPE

Returns:
Broadcaster#SCOPE

setName

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

Parameters:
name - of this Broadcaster

getName

String getName()
Return the name of this Broadcaster

Returns:
the name of this Broadcaster


Copyright © 2009 SUN Microsystems. All Rights Reserved.