public class BroadcasterConfig extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
BroadcasterConfig.FilterManipulator
Manipulate the message before and after they are getting filtered by
BroadcastFilter |
Modifier and Type | Field and Description |
---|---|
protected ConcurrentLinkedQueue<BroadcastFilter> |
filters |
protected ConcurrentLinkedQueue<PerRequestBroadcastFilter> |
perRequestFilters |
Constructor and Description |
---|
BroadcasterConfig(ExecutorService executorService,
ExecutorService asyncWriteService,
ScheduledExecutorService scheduler,
AtmosphereConfig config,
String broadcasterId)
Create a new BroadcasterConfig.
|
BroadcasterConfig(List<String> broadcastFilters,
AtmosphereConfig config,
boolean handleExecutors,
String broadcasterId)
Create a new BroadcasterConfig.
|
BroadcasterConfig(List<String> broadcastFilters,
AtmosphereConfig config,
String broadcasterId)
Create a new BroadcasterConfig.
|
protected final ConcurrentLinkedQueue<BroadcastFilter> filters
protected final ConcurrentLinkedQueue<PerRequestBroadcastFilter> perRequestFilters
public BroadcasterConfig(List<String> broadcastFilters, AtmosphereConfig config, String broadcasterId)
broadcastFilters
- config
- broadcasterId
- public BroadcasterConfig(List<String> broadcastFilters, AtmosphereConfig config, boolean handleExecutors, String broadcasterId)
broadcastFilters
- config
- handleExecutors
- broadcasterId
- public BroadcasterConfig(ExecutorService executorService, ExecutorService asyncWriteService, ScheduledExecutorService scheduler, AtmosphereConfig config, String broadcasterId)
executorService
- asyncWriteService
- scheduler
- config
- broadcasterId
- public BroadcasterConfig init()
protected void configureSharedCacheExecutor()
protected BroadcasterConfig broadcasterID(String broadcasterId)
protected void initClusterExtension()
public boolean handleExecutors()
protected void configExecutors()
public BroadcasterConfig setExecutorService(ExecutorService executorService)
ExecutorService
which can be used to dispatch
AtmosphereResourceEvent
. By default, the result of ExecutorsFactory.getMessageDispatcher(AtmosphereConfig, String)
is used if this method is not invoked.executorService
- to be used when broadcasting.public BroadcasterConfig setExecutorService(ExecutorService executorService, boolean isExecutorShared)
ExecutorService
which can be used to dispatch
AtmosphereResourceEvent
. By default, the result of ExecutorsFactory.getMessageDispatcher(AtmosphereConfig, String)
is used if this method is not invoked.executorService
- to be used when broadcasting.isExecutorShared
- true if the life cycle of the ExecutorService
will be executed by the application.
It means Atmosphere will NOT invoke the shutdown method when destroy()
is invoked.public ExecutorService getExecutorService()
ExecutorService
this Broadcaster
supports.
By default it returns the result of ExecutorsFactory.getMessageDispatcher(AtmosphereConfig, String)
}.public BroadcasterConfig setAsyncWriteService(ExecutorService asyncWriteService)
ExecutorService
which can be used to write
AtmosphereResourceEvent.getMessage()
. By default, the result of ExecutorsFactory.getAsyncOperationExecutor(AtmosphereConfig, String)
is used if this method is not invoked.asyncWriteService
- to be used when writing events.public BroadcasterConfig setAsyncWriteService(ExecutorService asyncWriteService, boolean isAsyncExecutorShared)
ExecutorService
which can be used to write
AtmosphereResourceEvent.getMessage()
. By default, the result of ExecutorsFactory.getAsyncOperationExecutor(AtmosphereConfig, String)
is used if this method is not invoked.asyncWriteService
- to be used when writing events.isAsyncExecutorShared
- true if the life cycle of the ExecutorService
will be executed by the application.
It means Atmosphere will NOT invoke the shutdown method when this destroy()
is invoked.public ExecutorService getAsyncWriteService()
ExecutorService
this Broadcaster
use for executing asynchronous write of events.
By default it returns the result of ExecutorsFactory.getAsyncOperationExecutor(AtmosphereConfig, String)
.public boolean addFilter(BroadcastFilter e)
BroadcastFilter
.e
- BroadcastFilter
protected boolean addFilter(BroadcastFilter e, boolean init)
BroadcastFilter
.e
- BroadcastFilter
public Collection<BroadcastFilter> filters()
BroadcastFilter
s.BroadcastFilter
spublic void destroy()
protected void destroy(boolean force)
public void forceDestroy()
ExecutorService
s.public boolean removeFilter(BroadcastFilter filter)
BroadcastFilter
.filter
- BroadcastFilter
public void removeAllFilters()
BroadcastFilter
s.public boolean hasFilters()
BroadcastFilter
s.BroadcastFilter
spublic boolean hasPerRequestFilters()
BroadcastFilter
s.BroadcastFilter
sprotected BroadcastFilter.BroadcastAction filter(Object object)
BroadcastFilter
s in the order they were added.object
- the broadcasted object.protected BroadcastFilter.BroadcastAction filter(AtmosphereResource r, Object message, Object originalMessage)
BroadcastFilter
s in the order they were added, with a unique AtmosphereRequest
.r
- AtmosphereResource
message
- the broadcasted object.message
- the broadcasted object.public List<Object> applyFilters(AtmosphereResource r, List<Object> cacheMessages)
AtmosphereResource
and the provided List
of messages.r
- AtmosphereResource
cacheMessages
- list of messagespublic BroadcasterConfig setScheduledExecutorService(ScheduledExecutorService scheduler)
ExecutorService
which can be used to dispatch
AtmosphereResourceEvent
s. By default a ScheduledExecutorService
is used if this method is not invoked.scheduler
- to be used when broadcasting.public ScheduledExecutorService getScheduledExecutorService()
ScheduledExecutorService
this Broadcaster
supports.
By default it returns an Executors.newScheduledThreadPool(int)
and will use
the underlying number of core/protocol as an indication of the thread number.public BroadcasterConfig setBroadcasterCache(BroadcasterCache broadcasterCache)
BroadcasterCache
.broadcasterCache
- a BroadcasterCache
public BroadcasterCache getBroadcasterCache()
BroadcasterCache
used for this Broadcaster
.BroadcasterCache
protected BroadcastFilter.BroadcastAction wrap(BroadcastFilter.BroadcastAction a, boolean wasUnwraped)
public AtmosphereConfig getAtmosphereConfig()
AtmosphereConfig
value. This value might be null
if the associated Broadcaster
has been created manually.AtmosphereConfig
Copyright © 2016. All rights reserved.