org.atmosphere.cpr
Class BroadcasterConfig

java.lang.Object
  extended by org.atmosphere.cpr.BroadcasterConfig
Direct Known Subclasses:
GAEBroadcasterConfig

public class BroadcasterConfig
extends Object

Handle Broadcaster configuration like ExecutorService and BroadcastFilter

Author:
Jeanfrancois Arcand

Nested Class Summary
static class BroadcasterConfig.DefaultBroadcasterCache
           
 
Field Summary
protected  ConcurrentLinkedQueue<BroadcastFilter> filters
           
 
Constructor Summary
BroadcasterConfig()
           
BroadcasterConfig(ExecutorService executorService, ScheduledExecutorService scheduler)
           
 
Method Summary
 boolean addFilter(BroadcastFilter e)
          Add a BroadcastFilter
protected  void configExecutors()
           
 void destroy()
           
protected  BroadcastFilter.BroadcastAction filter(Object object)
          Invoke BroadcastFilter in the other they were added.
 BroadcasterCache getBroadcasterCache()
          Get a BroadcasterConfig.DefaultBroadcasterCache
 ExecutorService getDefaultExecutorService()
          Return the default ExecutorService.
 ExecutorService getExecutorService()
          Return the ExecutorService this Broadcaster support.
 ScheduledExecutorService getScheduledExecutorService()
          Return the ScheduledExecutorService this Broadcaster support.
 boolean hasFilters()
          Return true if this object contains BroadcastFilter
 void removeAllFilters()
          Remove all BroadcastFilter
 boolean removeFilter(BroadcastFilter e)
          Remove a BroadcastFilter
 BroadcasterConfig setBroadcasterCache(BroadcasterCache broadcasterCache)
          Set a BroadcasterConfig.DefaultBroadcasterCache
 BroadcasterConfig setExecutorService(ExecutorService executorService)
          Set an ExecutorService which can be used to dispatch AtmosphereResourceEvent.
 BroadcasterConfig setScheduledExecutorService(ScheduledExecutorService scheduler)
          Set an ExecutorService which can be used to dispatch AtmosphereResourceEvent.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

filters

protected final ConcurrentLinkedQueue<BroadcastFilter> filters
Constructor Detail

BroadcasterConfig

public BroadcasterConfig()

BroadcasterConfig

public BroadcasterConfig(ExecutorService executorService,
                         ScheduledExecutorService scheduler)
Method Detail

configExecutors

protected void configExecutors()

setExecutorService

public BroadcasterConfig setExecutorService(ExecutorService executorService)
Set an ExecutorService which can be used to dispatch AtmosphereResourceEvent. By default, an Executors.newFixedThreadPool(int) is used if that method is not invoked.

Parameters:
executorService - to be used when broadcasting.

getExecutorService

public ExecutorService getExecutorService()
Return the ExecutorService this Broadcaster support. By default it returns and will use the underlying number of core/processor as an indication of the thread number.

Returns:
An ExecutorService.

addFilter

public boolean addFilter(BroadcastFilter e)
Add a BroadcastFilter

Parameters:
e - BroadcastFilter
Returns:
true if added.

destroy

public void destroy()

removeFilter

public boolean removeFilter(BroadcastFilter e)
Remove a BroadcastFilter

Parameters:
e - BroadcastFilter
Returns:
true if removed

removeAllFilters

public void removeAllFilters()
Remove all BroadcastFilter


hasFilters

public boolean hasFilters()
Return true if this object contains BroadcastFilter

Returns:
true if this object contains BroadcastFilter

filter

protected BroadcastFilter.BroadcastAction filter(Object object)
Invoke BroadcastFilter in the other they were added.

Parameters:
object - the broadcasted object.
Returns:
BroadcastAction that tell Atmosphere to invoke the next filter or not.

getDefaultExecutorService

public ExecutorService getDefaultExecutorService()
Return the default ExecutorService.

Returns:
the defaultExecutorService

setScheduledExecutorService

public BroadcasterConfig setScheduledExecutorService(ScheduledExecutorService scheduler)
Set an ExecutorService which can be used to dispatch AtmosphereResourceEvent. By default, an ScheduledExecutorService is used if that method is not invoked.

Parameters:
scheduler - to be used when broadcasting.
Returns:
this.

getScheduledExecutorService

public ScheduledExecutorService getScheduledExecutorService()
Return the ScheduledExecutorService this Broadcaster support. By default it returns Executors.newScheduledThreadPool(int) and will use the underlying number of core/processor as an indication of the thread number.

Returns:
An ExecutorService.

setBroadcasterCache

public BroadcasterConfig setBroadcasterCache(BroadcasterCache broadcasterCache)
Set a BroadcasterConfig.DefaultBroadcasterCache

Parameters:
broadcasterCache - a BroadcasterConfig.DefaultBroadcasterCache
Returns:
this

getBroadcasterCache

public BroadcasterCache getBroadcasterCache()
Get a BroadcasterConfig.DefaultBroadcasterCache

Returns:
this


Copyright © 2011. All Rights Reserved.