Package com.oracle.coherence.repository
Class AbstractRepositoryBase<ID,T,M>
- java.lang.Object
-
- com.oracle.coherence.repository.AbstractRepositoryBase<ID,T,M>
-
- Type Parameters:
ID
- the type of entity's identifierT
- the type of entity stored in this repositoryM
- the underlying map type
- Direct Known Subclasses:
AbstractAsyncRepository
,AbstractRepository
public abstract class AbstractRepositoryBase<ID,T,M> extends Object
Base functionality for all Coherence repository implementations.- Since:
- 21.06
- Author:
- Ryan Lubke 2021.04.08, Aleks Seovic
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
AbstractRepositoryBase.Listener<T>
An interface that should be implemented by the clients interested in repository events.protected static class
AbstractRepositoryBase.MapListenerAdapter<ID,T>
Adapter fromAbstractRepositoryBase.Listener
toMapListener
that can be registered with the backingNamedMap
.
-
Constructor Summary
Constructors Constructor Description AbstractRepositoryBase()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
addListener(AbstractRepositoryBase.Listener<? super T> listener)
Register a listener that will observe all repository events.void
addListener(Filter<?> filter, AbstractRepositoryBase.Listener<? super T> listener)
Register a listener that will observe all events for entities that satisfy the specified criteria.void
addListener(ID id, AbstractRepositoryBase.Listener<? super T> listener)
Register a listener that will observe all events for a specific entity.protected void
createIndices()
Creates indices for this repository that are defined via@Accelerated
and@Indexed
annotations.protected void
ensureInitialized()
Ensures that this repository is initialized by creating necessary indices on the backing map.protected abstract Class<? extends T>
getEntityType()
Return the type of entities in this repository.protected abstract ID
getId(T entity)
Return the identifier of the specified entity instance.protected abstract M
getMap()
Return the map that is used as the underlying entity store.protected MapListener<? super ID,? super T>
instantiateMapListener(AbstractRepositoryBase.Listener<? super T> delegate)
Factory method forAbstractRepositoryBase.Listener
adapter toMapListener
.AbstractRepositoryBase.Listener.Builder<T>
listener()
Create newAbstractRepositoryBase.Listener.Builder
instance.void
removeListener(AbstractRepositoryBase.Listener<? super T> listener)
Unregister a listener that observes all repository events.void
removeListener(Filter<?> filter, AbstractRepositoryBase.Listener<? super T> listener)
Unregister a listener that observes all events for entities that satisfy the specified criteria.void
removeListener(ID id, AbstractRepositoryBase.Listener<? super T> listener)
Unregister a listener that observes all events for a specific entity.
-
-
-
Method Detail
-
getId
protected abstract ID getId(T entity)
Return the identifier of the specified entity instance.- Parameters:
entity
- the entity to get the identifier from- Returns:
- the identifier of the specified entity instance
-
getEntityType
protected abstract Class<? extends T> getEntityType()
Return the type of entities in this repository.- Returns:
- the type of entities in this repository
-
getMap
protected abstract M getMap()
Return the map that is used as the underlying entity store.- Returns:
- the map that is used as the underlying entity store
-
ensureInitialized
protected void ensureInitialized()
Ensures that this repository is initialized by creating necessary indices on the backing map. Base framework classes that extend this class should call this method after the backing map has been initialized, but before any other calls are made.
-
createIndices
protected void createIndices()
Creates indices for this repository that are defined via@Accelerated
and@Indexed
annotations. If overriding this method, please callsuper.createIndices()
or the standard behavior will not work.
-
instantiateMapListener
protected MapListener<? super ID,? super T> instantiateMapListener(AbstractRepositoryBase.Listener<? super T> delegate)
Factory method forAbstractRepositoryBase.Listener
adapter toMapListener
.- Parameters:
delegate
- theAbstractRepositoryBase.Listener
to delegate events to- Returns:
- a
MapListener
that can be registered with aNamedMap
and will delegate events to theAbstractRepositoryBase.Listener
it wraps
-
addListener
public void addListener(AbstractRepositoryBase.Listener<? super T> listener)
Register a listener that will observe all repository events.- Parameters:
listener
- the event listener to register
-
removeListener
public void removeListener(AbstractRepositoryBase.Listener<? super T> listener)
Unregister a listener that observes all repository events.- Parameters:
listener
- the event listener to unregister
-
addListener
public void addListener(ID id, AbstractRepositoryBase.Listener<? super T> listener)
Register a listener that will observe all events for a specific entity.- Parameters:
id
- the identifier of the entity to observelistener
- the event listener to register
-
removeListener
public void removeListener(ID id, AbstractRepositoryBase.Listener<? super T> listener)
Unregister a listener that observes all events for a specific entity.- Parameters:
id
- the identifier of the entity to observelistener
- the event listener to unregister
-
addListener
public void addListener(Filter<?> filter, AbstractRepositoryBase.Listener<? super T> listener)
Register a listener that will observe all events for entities that satisfy the specified criteria.- Parameters:
filter
- the criteria to use to select entities to observelistener
- the event listener to register
-
removeListener
public void removeListener(Filter<?> filter, AbstractRepositoryBase.Listener<? super T> listener)
Unregister a listener that observes all events for entities that satisfy the specified criteria.- Parameters:
filter
- the criteria to use to select entities to observelistener
- the event listener to unregister
-
listener
public AbstractRepositoryBase.Listener.Builder<T> listener()
Create newAbstractRepositoryBase.Listener.Builder
instance.- Returns:
- a new
AbstractRepositoryBase.Listener.Builder
instance
-
-