org.axonframework.eventstore.jpa
Class DefaultEventEntryFactory

java.lang.Object
  extended by org.axonframework.eventstore.jpa.DefaultEventEntryFactory
All Implemented Interfaces:
EventEntryFactory<byte[]>

public final class DefaultEventEntryFactory
extends Object
implements EventEntryFactory<byte[]>

Implementation of the EventEntryFactory that provides the default Axon entities, which store payload and meta data of Events as byte arrays. This implementation also supports converting TimeZone of event timestamps to UTC before storing them.

Since:
2.3
Author:
Allard Buijze

Constructor Summary
DefaultEventEntryFactory()
          Creates a new instance of the factory which stores the timestamps with the original timezone of the event messages.
DefaultEventEntryFactory(boolean forceUtc)
          Creates a new instance of the factory which, when forceUtc true, stores the timestamps converted to UTC timezone.
 
Method Summary
 Object createDomainEventEntry(String aggregateType, DomainEventMessage event, SerializedObject<byte[]> serializedPayload, SerializedObject<byte[]> serializedMetaData)
          Creates an entity representing a Domain Event, which contains the data provided in the parameters, which can be stored using the JPA Entity Manager configured on the JpaEventStore using this factory.
 Object createSnapshotEventEntry(String aggregateType, DomainEventMessage snapshotEvent, SerializedObject<byte[]> serializedPayload, SerializedObject<byte[]> serializedMetaData)
          Creates an entity representing a Snapshot Event, which contains the data provided in the parameters, which can be stored using the JPA Entity Manager configured on the JpaEventStore using this factory.
 Class<byte[]> getDataType()
          Returns the type used to store serialized payloads.
 String getDomainEventEntryEntityName()
          Returns the entity name of the Domain Event Entry provided by this factory.
 String getSnapshotEventEntryEntityName()
          Returns the entity name of the Snapshot Event Entry provided by this factory.
 String resolveDateTimeValue(org.joda.time.DateTime dateTime)
          Returns the representation used for the given dateTime in the event entry.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultEventEntryFactory

public DefaultEventEntryFactory()
Creates a new instance of the factory which stores the timestamps with the original timezone of the event messages.


DefaultEventEntryFactory

public DefaultEventEntryFactory(boolean forceUtc)
Creates a new instance of the factory which, when forceUtc true, stores the timestamps converted to UTC timezone.

Parameters:
forceUtc - whether to convert timestamps to the UTC time zone.
Method Detail

getDataType

public Class<byte[]> getDataType()
Description copied from interface: EventEntryFactory
Returns the type used to store serialized payloads. This must correspond to the declared type of the snapshot event entry and domain event entry returned by EventEntryFactory.createSnapshotEventEntry(String, org.axonframework.domain.DomainEventMessage, org.axonframework.serializer.SerializedObject, org.axonframework.serializer.SerializedObject) and EventEntryFactory.createDomainEventEntry(String, org.axonframework.domain.DomainEventMessage, org.axonframework.serializer.SerializedObject, org.axonframework.serializer.SerializedObject) respectively.

Specified by:
getDataType in interface EventEntryFactory<byte[]>
Returns:
the type used to store serialized payloads

createDomainEventEntry

public Object createDomainEventEntry(String aggregateType,
                                     DomainEventMessage event,
                                     SerializedObject<byte[]> serializedPayload,
                                     SerializedObject<byte[]> serializedMetaData)
Description copied from interface: EventEntryFactory
Creates an entity representing a Domain Event, which contains the data provided in the parameters, which can be stored using the JPA Entity Manager configured on the JpaEventStore using this factory.

Specified by:
createDomainEventEntry in interface EventEntryFactory<byte[]>
Parameters:
aggregateType - The type identifier of the aggregate that generated the domain event
event - The DomainEventMessage containing the data to store
serializedPayload - The serialized payload
serializedMetaData - The serialized meta data
Returns:
the instance to store using the EntityManager

createSnapshotEventEntry

public Object createSnapshotEventEntry(String aggregateType,
                                       DomainEventMessage snapshotEvent,
                                       SerializedObject<byte[]> serializedPayload,
                                       SerializedObject<byte[]> serializedMetaData)
Description copied from interface: EventEntryFactory
Creates an entity representing a Snapshot Event, which contains the data provided in the parameters, which can be stored using the JPA Entity Manager configured on the JpaEventStore using this factory.

Specified by:
createSnapshotEventEntry in interface EventEntryFactory<byte[]>
Parameters:
aggregateType - The type identifier of the aggregate that generated the domain event
snapshotEvent - The DomainEventMessage containing the data to store
serializedPayload - The serialized payload
serializedMetaData - The serialized meta data
Returns:
the instance to store using the EntityManager

getDomainEventEntryEntityName

public String getDomainEventEntryEntityName()
Description copied from interface: EventEntryFactory
Returns the entity name of the Domain Event Entry provided by this factory.

Specified by:
getDomainEventEntryEntityName in interface EventEntryFactory<byte[]>
Returns:
the entity name of the Domain Event Entry provided by this factory

getSnapshotEventEntryEntityName

public String getSnapshotEventEntryEntityName()
Description copied from interface: EventEntryFactory
Returns the entity name of the Snapshot Event Entry provided by this factory.

Specified by:
getSnapshotEventEntryEntityName in interface EventEntryFactory<byte[]>
Returns:
the entity name of the Snapshot Event Entry provided by this factory

resolveDateTimeValue

public String resolveDateTimeValue(org.joda.time.DateTime dateTime)
Returns the representation used for the given dateTime in the event entry.

For example, if the date is stored as an ISO-8601 String, this methods return the dateTime.toString().

This implementation returns the a String containing a ISO-8601 representation of the given date.

Specified by:
resolveDateTimeValue in interface EventEntryFactory<byte[]>
Parameters:
dateTime - The date to return the representation for
Returns:
The value used to store the given date


Copyright © 2010-2016. All Rights Reserved.