/** * Initializes a {@link EventSourcingRepository} or {@link CachingEventSourcingRepository} as specified through * this Builder. Will return a CachingEventSourcingRepository if {@link #cache(Cache)} has been set. Otherwise * builds a regular EventSourcingRepository * * @param <R> a generic extending {@link EventSourcingRepository}, so allowing both an EventSourcingRepository * and {@link CachingEventSourcingRepository} return type * @return a {@link EventSourcingRepository} or {@link CachingEventSourcingRepository} (if {@link #cache(Cache)} * has been set) as specified through this Builder */ @SuppressWarnings("unchecked") public <R extends EventSourcingRepository<T>> R build() { return cache != null ? (R) new CachingEventSourcingRepository<>(this) : (R) new EventSourcingRepository<>(this); }
/** * Initializes a {@link EventSourcingRepository} or {@link CachingEventSourcingRepository} as specified through * this Builder. Will return a CachingEventSourcingRepository if {@link #cache(Cache)} has been set. Otherwise * builds a regular EventSourcingRepository * * @param <R> a generic extending {@link EventSourcingRepository}, so allowing both an EventSourcingRepository * and {@link CachingEventSourcingRepository} return type * @return a {@link EventSourcingRepository} or {@link CachingEventSourcingRepository} (if {@link #cache(Cache)} * has been set) as specified through this Builder */ @SuppressWarnings("unchecked") public <R extends EventSourcingRepository<T>> R build() { return cache != null ? (R) new CachingEventSourcingRepository<>(this) : (R) new EventSourcingRepository<>(this); }
/** * Our aggregate root is now created from stream of events and not from a representation in a persistent mechanism, * thus we need a repository that can handle the retrieving of our aggregate root from the stream of events. * * We configure the EventSourcingRepository which does exactly this. We supply it with the event store * @return a {@link EventSourcingRepository} implementation of {@link Repository} */ @Bean public Repository<Account> eventSourcingRepository() { EventSourcingRepository eventSourcingRepository = new EventSourcingRepository(Account.class, jdbcEventStore()); eventSourcingRepository.setEventBus(clusteringEventBus()); return eventSourcingRepository; }
c::repository); return new EventSourcingRepository<>(metaModel.get(), aggregateFactory.get(), c.eventStore(),