T
- the type of data associated with the tenant IDpublic abstract class TenantRepository<T extends io.spine.base.EntityState,E extends TenantRepository.Entity<T>> extends DefaultRecordBasedRepository<io.spine.core.TenantId,E,T> implements TenantIndex
Modifier and Type | Class and Description |
---|---|
static class |
TenantRepository.Entity<T extends io.spine.base.EntityState>
Stores data associated with a tenant ID.
|
Constructor and Description |
---|
TenantRepository() |
Modifier and Type | Method and Description |
---|---|
java.util.Set<io.spine.core.TenantId> |
all()
Obtains the set of all stored tenant IDs.
|
protected void |
clearCache()
Clears the cache of known tenant IDs.
|
protected RecordStorage<io.spine.core.TenantId> |
createStorage()
Creates the storage for this repository.
|
protected boolean |
isTypeSupplier()
Tells if this repository should be registered as a type supplier with a
Stand
of the BoundedContext to which this repository belongs. |
void |
keep(io.spine.core.TenantId id)
Stores the passed tenant ID in the index.
|
void |
registerWith(BoundedContext context)
Initializes the repository by performing the validation of the entity class and
creating the storage converter.
|
protected boolean |
unCache(io.spine.core.TenantId id)
Removes the passed value from the in-memory cache of known tenant IDs.
|
entityFactory, storageConverter
applyMigration, applyMigration, create, find, find, findActive, findOrCreate, iterator, loadAll, loadAll, recordStorage, store, store, toEntity
checkStorage, close, context, entityClass, entityStateType, eventFilter, hasContext, idClass, index, isOpen, isRegistered, onRegistered, open, storage, storageAssigned
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
close, createDefault, singleTenant
protected final RecordStorage<io.spine.core.TenantId> createStorage()
Repository
Default implementations use Repository.defaultStorageFactory()
invoking its method
which creates a storage compatible with the repository.
Overwrite this method for creating a custom implementation of Storage
.
createStorage
in class RecordBasedRepository<io.spine.core.TenantId,E extends TenantRepository.Entity<T>,T extends io.spine.base.EntityState>
public final void registerWith(BoundedContext context)
DefaultRecordBasedRepository
registerWith
in class DefaultRecordBasedRepository<io.spine.core.TenantId,E extends TenantRepository.Entity<T>,T extends io.spine.base.EntityState>
context
- the Bounded Context of this repositoryprotected final boolean isTypeSupplier()
Repository
Stand
of the BoundedContext
to which this repository belongs.
Normally repositories are type suppliers. Some types of internal repositories are
not type suppliers because data of their entities should not be exposed.
Those classes of repositories should overwrite this method returning false
.
isTypeSupplier
in class Repository<io.spine.core.TenantId,E extends TenantRepository.Entity<T>>
public final void keep(io.spine.core.TenantId id)
If there is an entity with the passed ID, the method quits. Otherwise, a new entity with the default state will be created and stored.
keep
in interface TenantIndex
id
- the tenant ID to storeprotected final boolean unCache(io.spine.core.TenantId id)
Implementations should call this method for removing the cached value for a tenant for which the record was removed from the repository.
id
- the ID to remove from the cachetrue
if the value was cached before and removed, false
otherwiseprotected final void clearCache()
public final java.util.Set<io.spine.core.TenantId> all()
TenantIndex
all
in interface TenantIndex