public abstract class AbstractBroadcaster extends Object implements Broadcaster
Broadcaster
class.Modifier and Type | Field and Description |
---|---|
protected Broadcaster |
next
next
Broadcaster in the chain |
Constructor and Description |
---|
AbstractBroadcaster() |
Modifier and Type | Method and Description |
---|---|
<T extends Broadcaster> |
chain(T broadcaster)
Specifies an additional
Broadcaster that should receive broadcasted events after this one has processed it. |
void |
chainBroadcast(Broadcastable broadcastable,
Broadcaster first,
Broadcaster... broadcasters)
Broadcasts the given event (syntax unit).
|
void |
cut(Broadcaster broadcaster)
Cuts the given
Broadcaster from the chain so that it will no long receive additional events. |
protected void |
relay(Broadcastable broadcastable)
Relays events down the chain to the next
Broadcaster , if one was given via
Broadcaster.chain(Broadcaster) . |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
broadcast
protected Broadcaster next
Broadcaster
in the chainpublic void chainBroadcast(Broadcastable broadcastable, Broadcaster first, Broadcaster... broadcasters)
Broadcaster
This will first call Broadcaster.chain(Broadcaster)
on this broadcaster with the given broadcasters, so that all given
broadcasters will be at the end of the chain. Then the broadcast occurs. Afterwards all given broadcasters will be cut
from the chain.
chainBroadcast
in interface Broadcaster
broadcastable
- The Broadcastable
syntax unit.first
- The first broadcaster to chain.broadcasters
- Optional additional broadcasters to chain.public <T extends Broadcaster> T chain(T broadcaster)
Broadcaster
Broadcaster
that should receive broadcasted events after this one has processed it.
If this Broadcaster
is already relaying events to another one then chain will be called on that broadcaster
instead, all the way down the line until the given Broadcaster
is at the bottom of the chain.
There are two main ways to use this method. The first way is that you create a new Broadcaster
instance, either
passing the original broadcaster to the constructor or calling chain on the new broadcaster. Then you use your new
broadcaster in place of the old one. This puts your new broadcaster at the top of the chain. This way is the easiest, but
doesn't work in some scenarios.
The second way is that you call chain on the original broadcaster, passing it a newly created one. This results in the new
broadcaster being at the bottom of the chain instead. When doing it this way, you must call Broadcaster.cut(Broadcaster)
on the original broadcaster before your method returns, after you are finished with the
broadcasting. Otherwise your new broadcaster will be left dangling. However this way is required if the broadcasted
events need to pass through Refine
plugin methods. Those methods will not use a broadcaster you place at the top
of the chain so being at the bottom is required. In this scenario prefer to use Broadcaster.chainBroadcast(Broadcastable,
Broadcaster, Broadcaster...)
, which will take care of the cutting responsibility.
chain
in interface Broadcaster
T
- The type of the broadcaster given.broadcaster
- The inner Broadcaster
.public void cut(Broadcaster broadcaster)
Broadcaster
Broadcaster
from the chain so that it will no long receive additional events.cut
in interface Broadcaster
broadcaster
- The broadcaster to cut.protected void relay(Broadcastable broadcastable)
Broadcaster
, if one was given via
Broadcaster.chain(Broadcaster)
.broadcastable
- The event.Copyright (c) 2019, Salesforce.com, Inc. All rights reserved. Licensed under the BSD 3-Clause license. For full license text, see the LICENSE file in the repository.