1919import org .axonframework .modelling .command .AggregateIdentifier ;
2020import org .axonframework .modelling .command .CreationPolicy ;
2121import org .axonframework .spring .stereotype .Aggregate ;
22+ import org .slf4j .Logger ;
23+ import org .slf4j .LoggerFactory ;
2224
2325import static org .axonframework .modelling .command .AggregateLifecycle .*;
2426
2527@ Aggregate (snapshotTriggerDefinition = "dwellingSnapshotTrigger" )
2628public class Dwelling {
2729
30+ private static final Logger logger = LoggerFactory .getLogger (Dwelling .class );
31+
2832 @ AggregateIdentifier
2933 public DwellingId dwellingId ;
3034 public CreatureId creatureId ;
@@ -47,6 +51,7 @@ void decide(BuildDwelling command) {
4751
4852 @ EventSourcingHandler
4953 void evolve (DwellingBuilt event ) {
54+ logger .info ("🏗️ Dwelling built with ID: {}, creature type: {}" , event .dwellingId (), event .creatureId ());
5055 this .dwellingId = new DwellingId (event .dwellingId ());
5156 this .creatureId = new CreatureId (event .creatureId ());
5257 this .costPerTroop = Resources .fromRaw (event .costPerTroop ());
@@ -69,6 +74,8 @@ void decide(IncreaseAvailableCreatures command) {
6974
7075 @ EventSourcingHandler
7176 void evolve (AvailableCreaturesChanged event ) {
77+ logger .info ("📈 Available creatures changed for dwelling {}: {} creatures now available" ,
78+ event .dwellingId (), event .changedTo ());
7279 this .availableCreatures = new Amount (event .changedTo ());
7380 }
7481
@@ -104,11 +111,14 @@ void decide(RecruitCreature command) {
104111
105112 @ EventSourcingHandler
106113 void evolve (CreatureRecruited event ) {
114+ logger .info ("🧙 Recruited {} creatures of type {} from dwelling {} to army {}" ,
115+ event .quantity (), event .creatureId (), event .dwellingId (), event .toArmy ());
107116 // todo: consider if it's OK or RecruitCreature should cause also AvailableCreaturesChanged event
108117 this .availableCreatures = this .availableCreatures .minus (new Amount (event .quantity ()));
109118 }
110119
111120 Dwelling () {
121+ logger .info ("🏠 Creating empty Dwelling (required by Axon)" );
112122 // required by Axon
113123 }
114124}
0 commit comments