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 interfaceAbstractRepositoryBase.Listener<T>An interface that should be implemented by the clients interested in repository events.protected static classAbstractRepositoryBase.MapListenerAdapter<ID,T>Adapter fromAbstractRepositoryBase.ListenertoMapListenerthat 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 voidaddListener(AbstractRepositoryBase.Listener<? super T> listener)Register a listener that will observe all repository events.voidaddListener(Filter<?> filter, AbstractRepositoryBase.Listener<? super T> listener)Register a listener that will observe all events for entities that satisfy the specified criteria.voidaddListener(ID id, AbstractRepositoryBase.Listener<? super T> listener)Register a listener that will observe all events for a specific entity.protected voidcreateIndices()Creates indices for this repository that are defined via@Acceleratedand@Indexedannotations.protected voidensureInitialized()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 IDgetId(T entity)Return the identifier of the specified entity instance.protected abstract MgetMap()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.Listeneradapter toMapListener.AbstractRepositoryBase.Listener.Builder<T>listener()Create newAbstractRepositoryBase.Listener.Builderinstance.voidremoveListener(AbstractRepositoryBase.Listener<? super T> listener)Unregister a listener that observes all repository events.voidremoveListener(Filter<?> filter, AbstractRepositoryBase.Listener<? super T> listener)Unregister a listener that observes all events for entities that satisfy the specified criteria.voidremoveListener(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@Acceleratedand@Indexedannotations. 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.Listeneradapter toMapListener.- Parameters:
delegate- theAbstractRepositoryBase.Listenerto delegate events to- Returns:
- a
MapListenerthat can be registered with aNamedMapand will delegate events to theAbstractRepositoryBase.Listenerit 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.Builderinstance.- Returns:
- a new
AbstractRepositoryBase.Listener.Builderinstance
-
-