Skip to content

Commit

Permalink
Create 'commandAuthorization' when deserializing aggregate
Browse files Browse the repository at this point in the history
Aggregates are deserialized when using Axon snapshots.

Fixes #73
  • Loading branch information
markvandenbergh committed Feb 1, 2019
1 parent 4ea765e commit 52234ea
Showing 1 changed file with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
import org.axonframework.eventsourcing.annotation.AggregateIdentifier;
import org.axonframework.eventsourcing.annotation.EventSourcingHandler;

import java.io.IOException;
import java.io.ObjectInputStream;

public class ChargingStation extends AbstractAnnotatedAggregateRoot {

private static final long serialVersionUID = -3089562761704323707L;
Expand Down Expand Up @@ -634,4 +637,18 @@ private void checkCommandAllowed(IdentityContext identityContext, Class commandC
}
}

/**
* Ensures the transient fields are populated upon deserialization. This occurs when an aggregate is read from
* snapshot.
*
* @param in input stream with de serialized object
* @throws IOException if an I/O error occurs.
* @throws ClassNotFoundException if the class of a serialized object could not be found.
*/
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
in.defaultReadObject();

commandAuthorization = new SimpleCommandAuthorization();
}

}

0 comments on commit 52234ea

Please sign in to comment.