public class InstrumentProfileCollector extends Object
InstrumentProfileConnection
as a repository that keeps
profiles of all known instruments. See InstrumentProfileConnection
for a usage example.
As set of instrument profiles stored in this collector can be accessed with view
method.
A snapshot plus a live stream of updates can be accessed with
addUpdateListener
method.
Removal of instrument profile is represented by an InstrumentProfile
instance with a
type
equal to
.
InstrumentProfileType
.REMOVED
.name
()
This class is thread-safe.
Constructor and Description |
---|
InstrumentProfileCollector() |
Modifier and Type | Method and Description |
---|---|
void |
addUpdateListener(InstrumentProfileUpdateListener listener)
Adds listener that is notified about any updates in the set of instrument profiles.
|
protected InstrumentProfile |
copyInstrumentProfile(InstrumentProfile ip)
A hook to create a defensive copy of the instrument profile that is saved into
this collector.
|
protected static Executor |
createAgentExecutor() |
Executor |
getExecutor()
Returns executor for processing instrument profile update notifications.
|
long |
getLastUpdateTime()
Returns last modification time (in milliseconds) of instrument profiles or zero if it is unknown.
|
void |
removeGenerations(Set<Object> generations)
Removes instrument profiles with non-null generation tags from a given set.
|
void |
removeUpdateListener(InstrumentProfileUpdateListener listener)
Removes listener that is notified about any updates in the set of instrument profiles.
|
void |
setExecutor(Executor executor)
Changes executor for processing instrument profile update notifications.
|
void |
updateInstrumentProfile(InstrumentProfile ip)
Convenience method to update one instrument profile in this collector.
|
void |
updateInstrumentProfiles(List<InstrumentProfile> ips,
Object generation)
Updates a list of instrument profile and assign them a generation tag.
|
Iterable<InstrumentProfile> |
view()
Returns a concurrent view of the set of instrument profiles.
|
public final long getLastUpdateTime()
public final void updateInstrumentProfile(InstrumentProfile ip)
updateInstrumentProfiles
(Collections.singletonList(ip), null);
Note, that this method stores reference to an instance of a given InstrumentProfile
object
inside this collector, unless a protected method
copyInstrumentProfile
is overridden to create a copy.
ip
- instrument profile.public final void updateInstrumentProfiles(List<InstrumentProfile> ips, Object generation)
removeGenerations
method.
Removal of instrument profile is represented by an InstrumentProfile
instance with a
type
equal to
.
InstrumentProfileType
.REMOVED
.name
()
Note, that this method stores references to instances of InstrumentProfile
objects from
a given list inside this collector, unless a protected method
copyInstrumentProfile
is overridden to create a copy.
ips
- a list of instrument profiles.generation
- a generation tag, may be null
.public final void removeGenerations(Set<Object> generations)
generations
- a set of generation tags.public final Iterable<InstrumentProfile> view()
InstrumentProfile
instance with a
type
equal to
InstrumentProfileType
.REMOVED
.name
()
.
Normally, this view exposes only non-removed profiles. However, if iteration is concurrent with removal,
then a removed instrument profile (with a removed type) can be exposed by this view.public Executor getExecutor()
public void setExecutor(Executor executor)
executor
- non-null executor for processing instrument profile update notifications.public final void addUpdateListener(InstrumentProfileUpdateListener listener)
notified
.listener
- profile update listener.public final void removeUpdateListener(InstrumentProfileUpdateListener listener)
listener
- profile update listener.protected InstrumentProfile copyInstrumentProfile(InstrumentProfile ip)
updateInstrumentProfile
and
updateInstrumentProfiles
methods
when a decision is made to save an instrument profile into this data
structure.
This implementation returns the original instrument reference. Overriding methods may choose to create and return a copy of the instrument profile object instead.
Override this method to safely reuse InstrumentProfile
instances that are
passed into this collector. This lazily creates their defensive copies,
just when the corresponding instrument profile is detected to have been changed.
ip
- the original instrument profile.protected static Executor createAgentExecutor()
Copyright © 2002–2023 Devexperts LLC. All rights reserved.