|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.axonframework.eventstore.jpa.JpaEventStore
public class JpaEventStore
An EventStore implementation that uses JPA to store DomainEvents in a database. The actual DomainEvent is stored as a serialized blob of bytes. Other columns are used to store meta-data that allow quick finding of DomainEvents for a specific aggregate in the correct order.
The serializer used to serialize the events is configurable. By default, theXStreamEventSerializer is used.
| Constructor Summary | |
|---|---|
JpaEventStore()
Initialize a JpaEventStore using an XStreamEventSerializer, which serializes
events as XML. |
|
JpaEventStore(EventSerializer eventSerializer)
Initialize a JpaEventStore which serializes events using the given EventSerializer. |
|
| Method Summary | |
|---|---|
void |
appendEvents(String type,
DomainEventStream events)
Append the events in the given stream to the event store. |
void |
appendSnapshotEvent(String type,
DomainEvent snapshotEvent)
Append the given snapshotEvent to the snapshot event log for the given type type. |
DomainEventStream |
readEvents(String type,
AggregateIdentifier identifier)
Read the events of the aggregate identified by the given type and identifier that allow the current aggregate state to be rebuilt. |
DomainEventStream |
readEventSegment(String type,
AggregateIdentifier identifier,
long firstSequenceNumber)
Reads a segment of the events of an aggregate. |
void |
setDataSource(DataSource dataSource)
Registers the data source that allows the EventStore to detect the database type and define the error codes that represent concurrent access failures. |
void |
setEntityManager(javax.persistence.EntityManager entityManager)
Sets the EntityManager for this EventStore to use. |
void |
setPersistenceExceptionResolver(PersistenceExceptionResolver persistenceExceptionResolver)
Sets the persistenceExceptionResolver that will help detect concurrency exceptions from the backing database. |
void |
visitEvents(EventVisitor visitor)
Loads all events available in the event store and calls EventVisitor.doWithEvent(org.axonframework.domain.DomainEvent)
for each event found. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public JpaEventStore()
XStreamEventSerializer, which serializes
events as XML.
public JpaEventStore(EventSerializer eventSerializer)
EventSerializer.
eventSerializer - The serializer to (de)serialize domain events with.| Method Detail |
|---|
@Transactional(propagation=MANDATORY)
public void appendEvents(String type,
DomainEventStream events)
stream to the event store.
appendEvents in interface EventStoretype - The type descriptor of the object to storeevents - The event stream containing the events to store
public DomainEventStream readEvents(String type,
AggregateIdentifier identifier)
readEvents in interface EventStoretype - The type descriptor of the object to retrieveidentifier - The unique aggregate identifier of the events to load
public DomainEventStream readEventSegment(String type,
AggregateIdentifier identifier,
long firstSequenceNumber)
firstSequenceNumber, if any. If no events with sequence number equal or
greater to the firstSequenceNumber are available, an empty DomainEventStream is returned.
The DomainEventStream returned by this call will never contain any snapshot events.
Note: To return all events after the firstSequenceNumber, use Long.MAX_VALUE as
lastSequenceNumber.
type - The type descriptor of the object to retrieveidentifier - The unique aggregate identifier of the events to loadfirstSequenceNumber - The sequence number of the first event to return
public void appendSnapshotEvent(String type,
DomainEvent snapshotEvent)
SnapshotEventStoresnapshotEvent to the snapshot event log for the given type type. The
sequence number of the snapshotEvent must be equal to the sequence number of the last regular domain
event that is included in the snapshot.
Note that the aggregate identifier and sequence number must be set on the DomainEvent. See DomainEvent.DomainEvent(long, org.axonframework.domain.AggregateIdentifier).
appendSnapshotEvent in interface SnapshotEventStoretype - The type of aggregate the event belongs tosnapshotEvent - The event summarizing one or more domain events for a specific aggregate.org.axonframework.domain.DomainEvent#DomainEvent(long, org.axonframework.domain.AggregateIdentifier))public void visitEvents(EventVisitor visitor)
EventStoreManagementEventVisitor.doWithEvent(org.axonframework.domain.DomainEvent)
for each event found. Events of a single aggregate are guaranteed to be ordered by their sequence number.
Implementations are encouraged, though not required, to supply events in the absolute chronological order.
Processing stops when the visitor throws an exception.
visitEvents in interface EventStoreManagementvisitor - The visitor the receives each loaded eventpublic void setEntityManager(javax.persistence.EntityManager entityManager)
DomainEventEntry as one of the managed entity types.
entityManager - the EntityManager to use.
public void setDataSource(DataSource dataSource)
throws SQLException
setPersistenceExceptionResolver(PersistenceExceptionResolver),
but rather as a shorthand alternative for most common database types.
dataSource - A data source providing access to the backing database
SQLException - If an error occurs while accessing the dataSourcepublic void setPersistenceExceptionResolver(PersistenceExceptionResolver persistenceExceptionResolver)
persistenceExceptionResolver - the persistenceExceptionResolver that will help detect concurrency
exceptions
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||