DefaultProjectionRepository

public class DefaultProjectionRepository<I, P extends Projection<I, S, ? extends Object>, S extends EntityState> extends ProjectionRepository<I, P, S> implements DefaultRepository

Default implementation of ProjectionRepository.

See also

Constructors

Link copied to clipboard
public void DefaultProjectionRepository(Class<P> cls)
Creates a new repository managing projections of the passed class.

Functions

Link copied to clipboard
Obtains model class for the entities managed by this repository.
Link copied to clipboard
public String toString()

Inherited functions

Link copied to clipboard
public final void applyMigration<T extends TransactionalEntity<I, S, ? extends Object>>(I id, Migration<I, T, S> migration)
Applies a given Migration to an entity with the given ID.
public final void applyMigration<T extends TransactionalEntity<I, S, ? extends Object>>(Set<I> ids, Migration<I, T, S> migration)
Applies a Migration to several entities in batch.
Link copied to clipboard
public boolean canDispatch(E envelope)
public final boolean canDispatch(EventEnvelope event)
Checks if this dispatcher can dispatch the given message.
Link copied to clipboard
public CatchUpId catchUp(Timestamp since, Set<I> ids)
Repeats the dispatching of the events from the event log to the requested entities since the specified time.
Link copied to clipboard
public CatchUpId catchUpAll(Timestamp since)
Starts the catch-up of all entities in this repository.
Link copied to clipboard
public void checkNotRegistered()
Verifies that this instance is NOT registered yet.
Link copied to clipboard
public void checkOpen()
Ensures that the object is open.
Link copied to clipboard
public void checkRegistered()
Verifies that this instance is already registered.
Link copied to clipboard
protected static S checkStorage<S extends AutoCloseable>(S storage)
Ensures that the storage is not null.
Link copied to clipboard
public void close()
Closes the repository by closing the underlying storage.
public abstract void close()
Link copied to clipboard
protected final BoundedContext context()
Obtains the BoundedContext to which this repository belongs.
Link copied to clipboard
public E create(I id)
public P create(I id)
Create a new entity instance with its default state.
Link copied to clipboard
protected abstract Storage<I, ? extends Object, ? extends Object> createStorage()
protected final ProjectionStorage<I> createStorage()
Creates the storage for this repository.
Link copied to clipboard
Obtains StorageFactory associated with the ServerEnvironment for creating standard storages.
Link copied to clipboard
public abstract DispatchOutcome dispatch(E envelope)
Dispatches the message contained in the passed envelope and returns the outcome.
public final DispatchOutcome dispatch(EventEnvelope event)
Dispatches the event to the corresponding entities.
Link copied to clipboard
public boolean dispatchesEvents()
Verifies if this instance dispatches at least one event.
Link copied to clipboard
public boolean dispatchesExternalEvents()
Verifies if this instance dispatches at least one external event.
Link copied to clipboard
protected final DispatchOutcome dispatchTo(Set<I> ids, EventEnvelope event)
Dispatches the given event to entities with the given identifiers, and returns the dispatch outcome.
Link copied to clipboard
public final ImmutableSet<EventClass> domesticEventClasses()
Obtains classes of domestic events processed by this dispatcher.
Link copied to clipboard
public final Class<E> entityClass()
Returns the class of entities managed by this repository.
Link copied to clipboard
Obtains EntityFactory associated with this repository.
Link copied to clipboard
public final TypeUrl entityStateType()
Obtains the TypeUrl for the state objects wrapped by entities managed by this repository.
Link copied to clipboard
public ImmutableSet<EventClass> eventClasses()
Obtains classes of all events processed by this dispatcher.
Link copied to clipboard
Creates an EventFilter for this repository.
Link copied to clipboard
public final ImmutableSet<EventClass> externalEventClasses()
Obtains classes of external events processed by this dispatcher.
Link copied to clipboard
public Optional<E> find(I id)
Finds an entity with the passed ID.
public Iterator<E> find(TargetFilters filters, ResponseFormat format)
Finds the entities passing the given filters and applies the given FieldMask to the results.
Link copied to clipboard
public Optional<E> findActive(I id)
Finds an entity with the passed ID even if the entity is active.
Link copied to clipboard
protected E findOrCreate(I id)
protected final P findOrCreate(I id)
Loads an entity by the passed ID or creates a new one, if the entity was not found.
Link copied to clipboard
public Iterator<EntityRecord> findRecords(TargetFilters filters, ResponseFormat format)
Obtains iterator over entity records matching the passed filters.
Link copied to clipboard
protected final boolean hasContext()
Verifies whether the repository is registered with a BoundedContext.
Link copied to clipboard
public final Class<I> idClass()
Returns the class of IDs used by this repository.
Link copied to clipboard
protected TypeUrl inboxStateType()
Returns a TypeUrl under which the entities of this repository will register their Inboxes.
Link copied to clipboard
public Iterator<I> index()
Returns an iterator over the identifiers of all the entities managed by this repository.
Link copied to clipboard
protected boolean isCatchUpEnabled()
Tells whether the catch-up feature is enabled for this repository.
Link copied to clipboard
public final boolean isOpen()
Verifies if the repository is open.
Link copied to clipboard
public boolean isRegistered()
Tells if the repository is registered in a BoundedContext.
Link copied to clipboard
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.
Link copied to clipboard
public Iterator<E> iterator(Predicate<E> filter)
Returns an iterator over the entities managed by the repository that match the passed filter.
Link copied to clipboard
Obtains an instance of EntityLifecycle for the entity with the given ID.
Link copied to clipboard
public Iterator<E> loadAll(ResponseFormat format)

public Iterator<E> loadAll(Iterable<I> ids, FieldMask fieldMask)
Loads all the entities in this repository with IDs, contained within the passed ids values.
Link copied to clipboard
public Iterator<EntityRecord> loadAllRecords(ResponseFormat format)
Obtains iterator over all present entity records.
Link copied to clipboard
public String logName()
Obtains the logging name of this repository.
Link copied to clipboard
public abstract ImmutableSet<C> messageClasses()
public final ImmutableSet<EventClass> messageClasses()
Obtains a set of message classes that can be processed by this dispatcher.
Link copied to clipboard
public static Repository<I, E> of<I, E extends Entity<I, ? extends Object>>(Class<E> cls)
Creates default repository for the passed entity class.
Link copied to clipboard
public void onRegistered()
The callback is invoked by a BoundedContext when adding the repository.
Link copied to clipboard
protected void onRoutingFailed(SignalEnvelope<? extends Object, ? extends Object, ? extends Object> envelope, Throwable cause)
A callback invoked when an exception is thrown from message routing.
Link copied to clipboard
protected final void open()
Initializes the storage of the repository.
Link copied to clipboard
protected final RecordStorage<I> recordStorage()
Ensures that the repository has the storage.
Link copied to clipboard
public void registerWith(BoundedContext context)
Initializes the repository.
Link copied to clipboard
protected Set<I> route(EventEnvelope event)
Determines the targets of the given event.
protected final Optional<R> route<M extends Message, C extends MessageContext, R>(Route<M, C, R> routing, SignalEnvelope<? extends Object, ? extends Object, C> envelope)
Link copied to clipboard
protected void setupEventRouting(EventRouting<I> routing)
A callback for derived repository classes to customize routing schema for events.
Link copied to clipboard
protected void setupStateRouting(StateUpdateRouting<I> routing)
A callback for derived repository classes to customize routing schema for delivering updated state to subscribed entities, if the default schema does not satisfy the routing needs.
Link copied to clipboard
protected final Stand stand()
Obtains the Stand from the BoundedContext of this repository.
Link copied to clipboard
protected final Storage<I, ? extends Object, ? extends Object> storage()
Returns the storage assigned to this repository.
Link copied to clipboard
public final boolean storageAssigned()
Returns true if the storage is assigned, false otherwise.
Link copied to clipboard
protected final StorageConverter<I, E, S> storageConverter()
Obtains StorageConverter associated with this repository.
Link copied to clipboard
public void store(E entity)
protected abstract void store(E obj)
public final void store(P entity)
Stores the passed object.
public void store(Collection<E> entities)
Stores Entities in bulk.
Link copied to clipboard
protected E toEntity(EntityRecord record)
Converts the passed record into an entity.
Link copied to clipboard
protected EntityClass<E> toModelClass(Class<E> cls)
protected final ProjectionClass<P> toModelClass(Class<P> cls)
Obtains a model class for the passed entity class value.