org.atmosphere.cpr
Class BroadcasterFactory

java.lang.Object
  extended by org.atmosphere.cpr.BroadcasterFactory
Direct Known Subclasses:
DefaultBroadcasterFactory

public abstract class BroadcasterFactory
extends Object

Factory for Broadcaster used by Atmosphere when creating broadcasters.

Author:
Jeanfrancois Arcand

Field Summary
protected  ConcurrentLinkedQueue<BroadcasterListener> broadcasterListeners
           
protected static AtmosphereConfig config
           
protected static BroadcasterFactory factory
           
 
Constructor Summary
BroadcasterFactory()
           
 
Method Summary
abstract  boolean add(Broadcaster b, Object id)
          Add a Broadcaster to the list.
 BroadcasterFactory addBroadcasterListener(BroadcasterListener b)
           
abstract  void destroy()
          Shutdown all Broadcasters.
abstract  Broadcaster get()
          Return an instance of the default Broadcaster.
abstract
<T extends Broadcaster>
T
get(Class<T> c, Object id)
          Create a new instance of Broadcaster and store it for.
abstract  Broadcaster get(Object id)
          Create a new instance of Broadcaster and store it for.
static BroadcasterFactory getDefault()
          Deprecated. Use AtmosphereConfig.resourcesFactory()
abstract
<T extends Broadcaster>
T
lookup(Class<T> c, Object id)
          Lookup a Broadcaster instance using Broadcaster.getID() or ID used when invoking getDefault().
abstract
<T extends Broadcaster>
T
lookup(Class<T> c, Object id, boolean createIfNull)
          Lookup a Broadcaster instance using Broadcaster.getID() or ID used when invoking getDefault().
abstract
<T extends Broadcaster>
T
lookup(Object id)
          Lookup a Broadcaster instance using Broadcaster.getID() or ID used when invoking getDefault().
abstract
<T extends Broadcaster>
T
lookup(Object id, boolean createIfNull)
          Lookup a Broadcaster instance using Broadcaster.getID() or ID used when invoking getDefault().
abstract  Collection<Broadcaster> lookupAll()
          Return an immutable Collection of Broadcaster this factory contains.
abstract  boolean remove(Broadcaster b, Object id)
          Remove a Broadcaster from the list.
abstract  boolean remove(Object id)
          Remove the associated Broadcaster.
abstract  void removeAllAtmosphereResource(AtmosphereResource r)
          Remove all instances of AtmosphereResource from all registered Broadcasters.
 BroadcasterFactory removeBroadcasterListener(BroadcasterListener b)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

factory

protected static BroadcasterFactory factory

config

protected static AtmosphereConfig config

broadcasterListeners

protected final ConcurrentLinkedQueue<BroadcasterListener> broadcasterListeners
Constructor Detail

BroadcasterFactory

public BroadcasterFactory()
Method Detail

get

public abstract Broadcaster get()
Return an instance of the default Broadcaster.

The name of the Broadcaster will be randomly generated.

Returns:
an instance of the default Broadcaster
Throws:
IllegalAccessException
InstantiationException

get

public abstract Broadcaster get(Object id)
Create a new instance of Broadcaster and store it for.

Parameters:
id - The unique ID used to retrieve Broadcaster
Returns:
a new instance of Broadcaster

get

public abstract <T extends Broadcaster> T get(Class<T> c,
                                              Object id)
Create a new instance of Broadcaster and store it for.

Parameters:
c - The Broadcaster class instance.
id - The unique ID used to retrieve Broadcaster
Returns:
a new instance of Broadcaster

destroy

public abstract void destroy()
Shutdown all Broadcasters.


add

public abstract boolean add(Broadcaster b,
                            Object id)
Add a Broadcaster to the list.

Parameters:
b - a Broadcaster
Returns:
false if a with the same name Broadcaster was already stored

remove

public abstract boolean remove(Broadcaster b,
                               Object id)
Remove a Broadcaster from the list.

Parameters:
b - a Broadcaster
id - the ID
Returns:
false if wasn't present, or Broadcaster

lookup

public abstract <T extends Broadcaster> T lookup(Class<T> c,
                                                 Object id)
Lookup a Broadcaster instance using Broadcaster.getID() or ID used when invoking getDefault().

Parameters:
c -
id - The Broadcaster's unique ID, or name.
Returns:
a Broadcaster, or null if not found.

lookup

public abstract <T extends Broadcaster> T lookup(Class<T> c,
                                                 Object id,
                                                 boolean createIfNull)
Lookup a Broadcaster instance using Broadcaster.getID() or ID used when invoking getDefault().

Parameters:
c -
id - The Broadcaster's unique ID, or name.
createIfNull - If the broadcaster is not found, create it.
Returns:
a Broadcaster, or null if not found.

lookup

public abstract <T extends Broadcaster> T lookup(Object id)
Lookup a Broadcaster instance using Broadcaster.getID() or ID used when invoking getDefault().

Parameters:
id - The Broadcaster's unique ID, or name.
Returns:
a Broadcaster, or null if not found.

lookup

public abstract <T extends Broadcaster> T lookup(Object id,
                                                 boolean createIfNull)
Lookup a Broadcaster instance using Broadcaster.getID() or ID used when invoking getDefault().

Parameters:
id - The Broadcaster's unique ID, or name.
createIfNull - If the broadcaster is not found, create it.
Returns:
a Broadcaster, or null if not found.

removeAllAtmosphereResource

public abstract void removeAllAtmosphereResource(AtmosphereResource r)
Remove all instances of AtmosphereResource from all registered Broadcasters.

Parameters:
r - an void AtmosphereResource

remove

public abstract boolean remove(Object id)
Remove the associated Broadcaster.


lookupAll

public abstract Collection<Broadcaster> lookupAll()
Return an immutable Collection of Broadcaster this factory contains.

Returns:
an immutable Collection of Broadcaster this factory contains.

getDefault

public static BroadcasterFactory getDefault()
Deprecated. Use AtmosphereConfig.resourcesFactory()

Return the default BroadcasterFactory.

Returns:
the default BroadcasterFactory.

addBroadcasterListener

public BroadcasterFactory addBroadcasterListener(BroadcasterListener b)

removeBroadcasterListener

public BroadcasterFactory removeBroadcasterListener(BroadcasterListener b)


Copyright © 2014. All Rights Reserved.