Permalink
Browse files

removed some of the event handling methods in domain classes that are…

… not required anymore.
  • Loading branch information...
jettro committed Feb 24, 2012
1 parent cdefc1b commit c71f4cd8269824cb70d2c886e404693c0e86bdd4
@@ -17,7 +17,6 @@
package org.axonframework.samples.trader.company.command;
import org.axonframework.domain.AggregateIdentifier;
-import org.axonframework.eventhandling.annotation.EventHandler;
import org.axonframework.eventsourcing.annotation.AbstractAnnotatedAggregateRoot;
import org.axonframework.samples.trader.company.api.CompanyCreatedEvent;
@@ -36,8 +35,4 @@ public Company(AggregateIdentifier identifier) {
super(identifier);
}
- @EventHandler
- public void onCompanyCreated(CompanyCreatedEvent event) {
- // nothing for now
- }
}
@@ -20,18 +20,8 @@
import org.axonframework.eventhandling.annotation.EventHandler;
import org.axonframework.eventsourcing.annotation.AbstractAnnotatedAggregateRoot;
import org.axonframework.samples.trader.orders.api.portfolio.PortfolioCreatedEvent;
-import org.axonframework.samples.trader.orders.api.portfolio.item.ItemReservationCancelledForPortfolioEvent;
-import org.axonframework.samples.trader.orders.api.portfolio.item.ItemReservationConfirmedForPortfolioEvent;
-import org.axonframework.samples.trader.orders.api.portfolio.item.ItemToReserveNotAvailableInPortfolioEvent;
-import org.axonframework.samples.trader.orders.api.portfolio.item.ItemsAddedToPortfolioEvent;
-import org.axonframework.samples.trader.orders.api.portfolio.item.ItemsReservedEvent;
-import org.axonframework.samples.trader.orders.api.portfolio.item.NotEnoughItemsAvailableToReserveInPortfolio;
-import org.axonframework.samples.trader.orders.api.portfolio.money.MoneyDepositedToPortfolioEvent;
-import org.axonframework.samples.trader.orders.api.portfolio.money.MoneyReservationCancelledFromPortfolioEvent;
-import org.axonframework.samples.trader.orders.api.portfolio.money.MoneyReservationConfirmedFromPortfolioEvent;
-import org.axonframework.samples.trader.orders.api.portfolio.money.MoneyReservedFromPortfolioEvent;
-import org.axonframework.samples.trader.orders.api.portfolio.money.MoneyWithdrawnFromPortfolioEvent;
-import org.axonframework.samples.trader.orders.api.portfolio.money.NotEnoughMoneyInPortfolioToMakeReservationEvent;
+import org.axonframework.samples.trader.orders.api.portfolio.item.*;
+import org.axonframework.samples.trader.orders.api.portfolio.money.*;
import java.util.HashMap;
import java.util.Map;
@@ -84,15 +74,15 @@ public void reserveItems(AggregateIdentifier orderBookIdentifier, AggregateIdent
public void confirmReservation(AggregateIdentifier orderBookIdentifier, AggregateIdentifier transactionIdentifier,
long amountOfItemsToConfirm) {
apply(new ItemReservationConfirmedForPortfolioEvent(orderBookIdentifier,
- transactionIdentifier,
- amountOfItemsToConfirm));
+ transactionIdentifier,
+ amountOfItemsToConfirm));
}
public void cancelReservation(AggregateIdentifier orderBookIdentifier, AggregateIdentifier transactionIdentifier,
long amountOfItemsToCancel) {
apply(new ItemReservationCancelledForPortfolioEvent(orderBookIdentifier,
- transactionIdentifier,
- amountOfItemsToCancel));
+ transactionIdentifier,
+ amountOfItemsToCancel));
}
public void addMoney(long moneyToAddInCents) {
@@ -120,21 +110,6 @@ public void confirmMoneyReservation(AggregateIdentifier transactionIdentifier, l
}
/* EVENT HANDLING */
- @EventHandler
- public void onPortfolioCreated(PortfolioCreatedEvent event) {
- // nothing for now
- }
-
- @EventHandler
- public void onNoItemsAvailableToReserve(ItemToReserveNotAvailableInPortfolioEvent event) {
- // nothing for now
- }
-
- @EventHandler
- public void onNotEnoughItemsAvailableToReserve(NotEnoughItemsAvailableToReserveInPortfolio event) {
- // nothing for now
- }
-
@EventHandler
public void onItemsAddedToPortfolio(ItemsAddedToPortfolioEvent event) {
long available = obtainCurrentAvailableItems(event.getOrderBookIdentifier());
@@ -184,11 +159,6 @@ public void onMoneyReservedFromPortfolio(MoneyReservedFromPortfolioEvent event)
reservedAmountOfMoney += event.getAmountToReserve();
}
- @EventHandler
- public void onNotEnoughMoneyToMakeReservation(NotEnoughMoneyInPortfolioToMakeReservationEvent event) {
- // do nothing
- }
-
@EventHandler
public void onMoneyReservationCancelled(MoneyReservationCancelledFromPortfolioEvent event) {
amountOfMoney += event.getAmountOfMoneyToCancel();
@@ -19,27 +19,12 @@
import org.axonframework.domain.AggregateIdentifier;
import org.axonframework.eventhandling.annotation.EventHandler;
import org.axonframework.eventsourcing.annotation.AbstractAnnotatedAggregateRoot;
-import org.axonframework.samples.trader.orders.api.transaction.BuyTransactionCancelledEvent;
-import org.axonframework.samples.trader.orders.api.transaction.BuyTransactionConfirmedEvent;
-import org.axonframework.samples.trader.orders.api.transaction.BuyTransactionExecutedEvent;
-import org.axonframework.samples.trader.orders.api.transaction.BuyTransactionPartiallyExecutedEvent;
-import org.axonframework.samples.trader.orders.api.transaction.BuyTransactionStartedEvent;
-import org.axonframework.samples.trader.orders.api.transaction.SellTransactionCancelledEvent;
-import org.axonframework.samples.trader.orders.api.transaction.SellTransactionConfirmedEvent;
-import org.axonframework.samples.trader.orders.api.transaction.SellTransactionExecutedEvent;
-import org.axonframework.samples.trader.orders.api.transaction.SellTransactionPartiallyExecutedEvent;
-import org.axonframework.samples.trader.orders.api.transaction.SellTransactionStartedEvent;
-import org.axonframework.samples.trader.orders.api.transaction.TransactionType;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.axonframework.samples.trader.orders.api.transaction.*;
/**
* @author Jettro Coenradie
*/
public class Transaction extends AbstractAnnotatedAggregateRoot {
-
- private final static Logger logger = LoggerFactory.getLogger(Transaction.class);
-
private long amountOfItems;
private long amountOfExecutedItems;
private TransactionType type;
@@ -56,15 +41,15 @@ public Transaction(TransactionType type,
switch (type) {
case BUY:
apply(new BuyTransactionStartedEvent(orderbookIdentifier,
- portfolioIdentifier,
- amountOfItems,
- pricePerItem));
+ portfolioIdentifier,
+ amountOfItems,
+ pricePerItem));
break;
case SELL:
apply(new SellTransactionStartedEvent(orderbookIdentifier,
- portfolioIdentifier,
- amountOfItems,
- pricePerItem));
+ portfolioIdentifier,
+ amountOfItems,
+ pricePerItem));
break;
}
}
@@ -96,17 +81,17 @@ public void execute(long amountOfItems, long itemPrice) {
case BUY:
if (isPartiallyExecuted(amountOfItems)) {
apply(new BuyTransactionPartiallyExecutedEvent(amountOfItems,
- amountOfItems + amountOfExecutedItems,
- itemPrice));
+ amountOfItems + amountOfExecutedItems,
+ itemPrice));
} else {
apply(new BuyTransactionExecutedEvent(amountOfItems, itemPrice));
}
break;
case SELL:
if (isPartiallyExecuted(amountOfItems)) {
apply(new SellTransactionPartiallyExecutedEvent(amountOfItems,
- amountOfItems + amountOfExecutedItems,
- itemPrice));
+ amountOfItems + amountOfExecutedItems,
+ itemPrice));
} else {
apply(new SellTransactionExecutedEvent(amountOfItems, itemPrice));
}
@@ -130,28 +115,6 @@ public void onSellTransactionStarted(SellTransactionStartedEvent event) {
this.type = TransactionType.SELL;
}
- @EventHandler
- public void onTransactionConfirmed(BuyTransactionConfirmedEvent event) {
- logger.debug("Buy transaction is confirmed, but we do not have to do anything. (Id of transaction is {}",
- getIdentifier().asString());
- }
-
- @EventHandler
- public void onTransactionConfirmed(SellTransactionConfirmedEvent event) {
- logger.debug("Sell transaction is confirmed, but we do not have to do anything. (Id of transaction is {}",
- getIdentifier().asString());
- }
-
- @EventHandler
- public void onTransactionCancelled(BuyTransactionCancelledEvent event) {
- // do nothing for now
- }
-
- @EventHandler
- public void onTransactionCancelled(SellTransactionCancelledEvent event) {
- // do nothing for now
- }
-
@EventHandler
public void onTransactionExecuted(BuyTransactionExecutedEvent event) {
this.amountOfExecutedItems = this.amountOfItems;
@@ -26,6 +26,8 @@
import org.springframework.stereotype.Component;
/**
+ * <p>Listener that is used to create a new portfolio for each new user that is created.</p>
+ *
* @author Jettro Coenradie
*/
@Component
@@ -37,7 +39,7 @@
@EventHandler
public void createNewPortfolioWhenUserIsCreated(UserCreatedEvent event) {
logger.debug("About to dispatch a new command to create a Portfolio for the new user {}",
- event.getUserIdentifier());
+ event.getUserIdentifier());
CreatePortfolioCommand command = new CreatePortfolioCommand(event.getUserIdentifier());
commandBus.dispatch(command);
}
@@ -53,11 +53,6 @@ public void onUserCreated(UserCreatedEvent event) {
this.passwordHash = event.getPassword();
}
- @EventHandler
- public void onUserAuthenticated(UserAuthenticatedEvent event) {
- // nothing for now
- }
-
private String hashOf(char[] password) {
return DigestUtils.sha1(String.valueOf(password));
}

0 comments on commit c71f4cd

Please sign in to comment.