public class SelectionContext extends Object
SelectionContext
holds information for a set Selection
objects, mostly acting as a cache.
Some of the information is identical to what's in the database and can be safely be GC'ed, so it lives in a memory-sensitive map (softMap), otherwise it's moved to a normal map (hardMap) (creation or deletion).
Modifier and Type | Field and Description |
---|---|
protected com.codahale.metrics.Timer |
cacheGetTimer |
protected com.codahale.metrics.Counter |
cacheHitCount |
Map<Serializable,Selection> |
hardMap |
protected com.codahale.metrics.Counter |
modifiedInTransactionCount |
protected com.codahale.metrics.MetricRegistry |
registry |
Constructor and Description |
---|
SelectionContext(SelectionType selType,
Serializable criterion,
RowMapper mapper,
PersistenceContext context) |
Modifier and Type | Method and Description |
---|---|
boolean |
applicable(SimpleFragment fragment) |
int |
clearCaches() |
void |
gatherInvalidations(Invalidations invalidations)
Gathers invalidations from this session.
|
SimpleFragment |
getSelectionFragment(Serializable selId,
String filter)
Find a fragment given its selection id and value.
|
List<SimpleFragment> |
getSelectionFragments(Serializable selId,
String filter)
Finds all the selection fragments for a given id.
|
Set<Serializable> |
getSelectionIds(List<Serializable> values)
Gets all the selection fragment ids for a given list of values.
|
protected Selection |
getSelectionOrNull(Serializable selId)
Gets the proper selection cache, if it exists, otherwise returns
null . |
int |
getSize() |
void |
markInvalidated(Set<RowId> modified)
Marks locally all the invalidations gathered by a
Mapper operation (like a version restore). |
void |
newSelection(Serializable selId)
Notes that a new empty selection should be created.
|
void |
postSave() |
void |
processReceivedInvalidations(Set<RowId> modified)
Processes all invalidations accumulated.
|
void |
recordCreated(SimpleFragment fragment)
Records the fragment as a just-created selection member.
|
void |
recordExisting(SimpleFragment fragment,
boolean invalidate) |
void |
recordRemoved(Serializable id,
Serializable selId)
Removes a selection item from the selection.
|
void |
recordRemoved(SimpleFragment fragment)
Removes a selection item from the selection.
|
void |
recordRemovedSelection(Serializable selId)
Records a selection as removed.
|
public final Map<Serializable,Selection> hardMap
protected final com.codahale.metrics.MetricRegistry registry
protected final com.codahale.metrics.Counter modifiedInTransactionCount
protected final com.codahale.metrics.Counter cacheHitCount
protected final com.codahale.metrics.Timer cacheGetTimer
public SelectionContext(SelectionType selType, Serializable criterion, RowMapper mapper, PersistenceContext context)
public int clearCaches()
public int getSize()
protected Selection getSelectionOrNull(Serializable selId)
null
.public boolean applicable(SimpleFragment fragment)
public void recordCreated(SimpleFragment fragment)
public void newSelection(Serializable selId)
public void recordExisting(SimpleFragment fragment, boolean invalidate)
invalidate
- true
if this is for a fragment newly created by internal database process (copy, etc.)
and must notified to other session; false
if this is a normal readpublic void recordRemoved(SimpleFragment fragment)
public void recordRemoved(Serializable id, Serializable selId)
public void recordRemovedSelection(Serializable selId)
public SimpleFragment getSelectionFragment(Serializable selId, String filter)
If the fragment is not in the context, fetch it from the mapper.
selId
- the selection idfilter
- the value to filter onnull
if not foundpublic List<SimpleFragment> getSelectionFragments(Serializable selId, String filter)
No sorting on value is done.
selId
- the selection idfilter
- the value to filter on, or null
for allpublic Set<Serializable> getSelectionIds(List<Serializable> values)
public void postSave()
public void markInvalidated(Set<RowId> modified)
Mapper
operation (like a version restore).public void gatherInvalidations(Invalidations invalidations)
Called post-transaction to gathers invalidations to be sent to others.
public void processReceivedInvalidations(Set<RowId> modified)
Called pre-transaction.
Copyright © 2017 Nuxeo. All rights reserved.