AxonFramework/AxonFramework — pull request #109 by Hippoom (2014-02-11 02:46:11+00:00)
Title: Try to solve http://issues.axonframework.org/youtrack/issue/AXON-211.

Try to add support for http://issues.axonframework.org/youtrack/issue/AXON-211.

Just want to know if this development goes in the right direction.

In this case, custom jpa entity could extend DomainEventEntry or SnapshotEventEntry and their corresponding EventEntryStore implementation could extend AbstractEntityCustomizableEventEntryStore:

class OrderDomainEventEntry extends DomainEventEntry {}

class OrderEventEntryStore extends AbstractEntityCustomizableEventEntryStore {
@Override
protected DomainEventEntry aDomainEventEntryWith(String aggregateType,
DomainEventMessage event, SerializedObject serializedPayload,
SerializedObject serializedMetaData) {
return new OrderEventEntry(aggregateType, event, serializedPayload,
serializedMetaData);
}

@Override
protected String domainEventEntryEntityName() {
return OrderEventEntry.class.getSimpleName();
}
}

By the way, what about using reflection? Therefore, axon-namespace-support could be used for injection. For example:

class OrderDomainEventEntry extends DomainEventEntry {}

class EntityCustomizableEventEntryStore extends AbstractEntityCustomizableEventEntryStore {
private String domainEventEntryEntityName;//injected
@Override
protected DomainEventEntry aDomainEventEntryWith(String aggregateType,
DomainEventMessage event, SerializedObject serializedPayload,
SerializedObject serializedMetaData) {
//return DomainEventEntry instance intiated by reflection with domainEventEntryEntityName
}

@Override
protected String domainEventEntryEntityName() {
return domainEventEntryEntityName;
}
}