org.atmosphere.cpr
Class DefaultBroadcasterFactory

java.lang.Object
  extended by org.atmosphere.cpr.DefaultBroadcasterFactory
All Implemented Interfaces:
BroadcasterFactory
Direct Known Subclasses:
PoolableBroadcasterFactory

public class DefaultBroadcasterFactory
extends Object
implements BroadcasterFactory

This class is responsible for creating Broadcaster instances. You can also add and remove Broadcaster

Author:
Jeanfrancois Arcand, Jason Burgess

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.atmosphere.cpr.BroadcasterFactory
BroadcasterFactory.BroadcasterCreationException
 
Field Summary
protected  ConcurrentLinkedQueue<BroadcasterListener> broadcasterListeners
           
protected  Class<? extends Broadcaster> clazz
           
protected  AtmosphereConfig config
           
protected  Broadcaster.POLICY defaultPolicy
           
protected  int defaultPolicyInteger
           
static URI legacyBroadcasterURI
           
protected  BroadcasterListener lifeCycleListener
           
protected  BroadcasterLifeCyclePolicy policy
           
protected  ConcurrentHashMap<Object,Broadcaster> store
           
 
Constructor Summary
DefaultBroadcasterFactory()
           
DefaultBroadcasterFactory(Class<? extends Broadcaster> clazz, String broadcasterLifeCyclePolicy, AtmosphereConfig c)
          Deprecated. 
 
Method Summary
 boolean add(Broadcaster b, Object id)
          Add a Broadcaster to the list.
 BroadcasterFactory addBroadcasterListener(BroadcasterListener l)
          Add a BroadcasterListener
 Collection<BroadcasterListener> broadcasterListeners()
          Return all BroadcasterListener.
 void configure(Class<? extends Broadcaster> clazz, String broadcasterLifeCyclePolicy, AtmosphereConfig c)
          Configure the factory
protected  void configure(String broadcasterLifeCyclePolicy)
           
protected
<T extends Broadcaster>
T
createBroadcaster(Class<T> c, Object id)
           
 void destroy()
          Shutdown all Broadcasters.
 Broadcaster get()
          Return an instance of the default Broadcaster.
<T extends Broadcaster>
T
get(Class<T> c, Object id)
          Create a new instance of Broadcaster and store it for.
 Broadcaster get(Object id)
          Create a new instance of Broadcaster and store it for.
<T extends Broadcaster>
T
lookup(Class<T> c, Object id)
          Lookup a Broadcaster instance using Broadcaster.getID() or ID
<T extends Broadcaster>
T
lookup(Class<T> c, Object id, boolean createIfNull)
          Lookup a Broadcaster instance using Broadcaster.getID() or ID
<T extends Broadcaster>
T
lookup(Class<T> c, Object id, boolean createIfNull, boolean unique)
           
 Broadcaster lookup(Object id)
          Lookup a Broadcaster instance using Broadcaster.getID() or ID
 Broadcaster lookup(Object id, boolean createIfNull)
          Lookup a Broadcaster instance using Broadcaster.getID() or ID
 Collection<Broadcaster> lookupAll()
          Return an immutable Collection of Broadcaster this factory contains.
 void notifyOnPostCreate(Broadcaster b)
           
 boolean remove(Broadcaster b, Object id)
          Remove a Broadcaster from the list.
 boolean remove(Object id)
          Remove the associated Broadcaster.
 void removeAllAtmosphereResource(AtmosphereResource r)
          Deprecated. 
 BroadcasterFactory removeBroadcasterListener(BroadcasterListener l)
          Remove a BroadcasterListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

broadcasterListeners

protected final ConcurrentLinkedQueue<BroadcasterListener> broadcasterListeners

store

protected final ConcurrentHashMap<Object,Broadcaster> store

clazz

protected Class<? extends Broadcaster> clazz

policy

protected BroadcasterLifeCyclePolicy policy

defaultPolicy

protected Broadcaster.POLICY defaultPolicy

defaultPolicyInteger

protected int defaultPolicyInteger

config

protected AtmosphereConfig config

lifeCycleListener

protected final BroadcasterListener lifeCycleListener

legacyBroadcasterURI

public static final URI legacyBroadcasterURI
Constructor Detail

DefaultBroadcasterFactory

public DefaultBroadcasterFactory()

DefaultBroadcasterFactory

@Deprecated
public DefaultBroadcasterFactory(Class<? extends Broadcaster> clazz,
                                            String broadcasterLifeCyclePolicy,
                                            AtmosphereConfig c)
Deprecated. 

Method Detail

configure

public void configure(Class<? extends Broadcaster> clazz,
                      String broadcasterLifeCyclePolicy,
                      AtmosphereConfig c)
Description copied from interface: BroadcasterFactory
Configure the factory

Specified by:
configure in interface BroadcasterFactory
Parameters:
clazz - Broadcaster
broadcasterLifeCyclePolicy - BroadcasterLifeCyclePolicy
c - AtmosphereConfig

configure

protected void configure(String broadcasterLifeCyclePolicy)

get

public Broadcaster get()
Description copied from interface: BroadcasterFactory
Return an instance of the default Broadcaster.

The name of the Broadcaster will be randomly generated.

Specified by:
get in interface BroadcasterFactory
Returns:
an instance of the default Broadcaster

get

public Broadcaster get(Object id)
Description copied from interface: BroadcasterFactory
Create a new instance of Broadcaster and store it for.

Specified by:
get in interface BroadcasterFactory
Parameters:
id - The unique ID used to retrieve Broadcaster
Returns:
a new instance of Broadcaster

get

public <T extends Broadcaster> T get(Class<T> c,
                                     Object id)
Description copied from interface: BroadcasterFactory
Create a new instance of Broadcaster and store it for.

Specified by:
get in interface BroadcasterFactory
Parameters:
c - The Broadcaster class instance.
id - The unique ID used to retrieve Broadcaster
Returns:
a new instance of Broadcaster

createBroadcaster

protected <T extends Broadcaster> T createBroadcaster(Class<T> c,
                                                      Object id)
                                           throws BroadcasterFactory.BroadcasterCreationException
Throws:
BroadcasterFactory.BroadcasterCreationException

add

public boolean add(Broadcaster b,
                   Object id)
Description copied from interface: BroadcasterFactory
Add a Broadcaster to the list.

Specified by:
add in interface BroadcasterFactory
Parameters:
b - a Broadcaster
Returns:
false if a with the same name Broadcaster was already stored

remove

public boolean remove(Broadcaster b,
                      Object id)
Description copied from interface: BroadcasterFactory
Remove a Broadcaster from the list.

Specified by:
remove in interface BroadcasterFactory
Parameters:
b - a Broadcaster
id - the ID
Returns:
false if wasn't present, or Broadcaster

lookup

public <T extends Broadcaster> T lookup(Class<T> c,
                                        Object id)
Description copied from interface: BroadcasterFactory
Lookup a Broadcaster instance using Broadcaster.getID() or ID

Specified by:
lookup in interface BroadcasterFactory
id - The Broadcaster's unique ID, or name.
Returns:
a Broadcaster, or null if not found.

lookup

public Broadcaster lookup(Object id)
Description copied from interface: BroadcasterFactory
Lookup a Broadcaster instance using Broadcaster.getID() or ID

Specified by:
lookup in interface BroadcasterFactory
Parameters:
id - The Broadcaster's unique ID, or name.
Returns:
a Broadcaster, or null if not found.

lookup

public Broadcaster lookup(Object id,
                          boolean createIfNull)
Description copied from interface: BroadcasterFactory
Lookup a Broadcaster instance using Broadcaster.getID() or ID

Specified by:
lookup in interface BroadcasterFactory
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.

lookup

public <T extends Broadcaster> T lookup(Class<T> c,
                                        Object id,
                                        boolean createIfNull)
Description copied from interface: BroadcasterFactory
Lookup a Broadcaster instance using Broadcaster.getID() or ID

Specified by:
lookup in interface BroadcasterFactory
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 <T extends Broadcaster> T lookup(Class<T> c,
                                        Object id,
                                        boolean createIfNull,
                                        boolean unique)

removeAllAtmosphereResource

@Deprecated
public void removeAllAtmosphereResource(AtmosphereResource r)
Deprecated. 

Description copied from interface: BroadcasterFactory
Remove all instances of AtmosphereResource from all registered Broadcasters.

Specified by:
removeAllAtmosphereResource in interface BroadcasterFactory
Parameters:
r - an void AtmosphereResource

remove

public boolean remove(Object id)
Description copied from interface: BroadcasterFactory
Remove the associated Broadcaster.

Specified by:
remove in interface BroadcasterFactory

lookupAll

public Collection<Broadcaster> lookupAll()
Description copied from interface: BroadcasterFactory
Return an immutable Collection of Broadcaster this factory contains.

Specified by:
lookupAll in interface BroadcasterFactory
Returns:
an immutable Collection of Broadcaster this factory contains.

destroy

public void destroy()
Description copied from interface: BroadcasterFactory
Shutdown all Broadcasters.

Specified by:
destroy in interface BroadcasterFactory

notifyOnPostCreate

public void notifyOnPostCreate(Broadcaster b)

addBroadcasterListener

public BroadcasterFactory addBroadcasterListener(BroadcasterListener l)
Description copied from interface: BroadcasterFactory
Add a BroadcasterListener

Specified by:
addBroadcasterListener in interface BroadcasterFactory
Parameters:
l - a BroadcasterListener
Returns:
this

removeBroadcasterListener

public BroadcasterFactory removeBroadcasterListener(BroadcasterListener l)
Description copied from interface: BroadcasterFactory
Remove a BroadcasterListener

Specified by:
removeBroadcasterListener in interface BroadcasterFactory
Parameters:
l - a BroadcasterListener
Returns:
this

broadcasterListeners

public Collection<BroadcasterListener> broadcasterListeners()
Return all BroadcasterListener.

Specified by:
broadcasterListeners in interface BroadcasterFactory
Returns:
BroadcasterListener


Copyright © 2015. All Rights Reserved.