Permalink
Browse files

Add the transaction stuff to the code base

  • Loading branch information...
1 parent c74ac79 commit 47eef8c2e97499d2db15807d27f2f477aadedd71 @jettro jettro committed Oct 28, 2011
Showing with 1,100 additions and 0 deletions.
  1. +51 −0 ...in/java/org/axonframework/samples/trader/app/api/transaction/AbstractStartTransactionCommand.java
  2. +56 −0 ...in/java/org/axonframework/samples/trader/app/api/transaction/AbstractTransactionStartedEvent.java
  3. +44 −0 .../main/java/org/axonframework/samples/trader/app/api/transaction/BuyTransactionCancelledEvent.java
  4. +28 −0 .../main/java/org/axonframework/samples/trader/app/api/transaction/BuyTransactionConfirmedEvent.java
  5. +44 −0 ...c/main/java/org/axonframework/samples/trader/app/api/transaction/BuyTransactionExecutedEvent.java
  6. +63 −0 ...va/org/axonframework/samples/trader/app/api/transaction/BuyTransactionPartiallyExecutedEvent.java
  7. +31 −0 ...rc/main/java/org/axonframework/samples/trader/app/api/transaction/BuyTransactionStartedEvent.java
  8. +33 −0 app/src/main/java/org/axonframework/samples/trader/app/api/transaction/CancelTransactionCommand.java
  9. +33 −0 ...src/main/java/org/axonframework/samples/trader/app/api/transaction/ConfirmTransactionCommand.java
  10. +45 −0 ...rc/main/java/org/axonframework/samples/trader/app/api/transaction/ExecutedTransactionCommand.java
  11. +44 −0 ...main/java/org/axonframework/samples/trader/app/api/transaction/SellTransactionCancelledEvent.java
  12. +29 −0 ...main/java/org/axonframework/samples/trader/app/api/transaction/SellTransactionConfirmedEvent.java
  13. +52 −0 .../main/java/org/axonframework/samples/trader/app/api/transaction/SellTransactionExecutedEvent.java
  14. +63 −0 ...a/org/axonframework/samples/trader/app/api/transaction/SellTransactionPartiallyExecutedEvent.java
  15. +27 −0 ...c/main/java/org/axonframework/samples/trader/app/api/transaction/SellTransactionStartedEvent.java
  16. +27 −0 ...rc/main/java/org/axonframework/samples/trader/app/api/transaction/StartBuyTransactionCommand.java
  17. +27 −0 ...c/main/java/org/axonframework/samples/trader/app/api/transaction/StartSellTransactionCommand.java
  18. +147 −0 app/src/main/java/org/axonframework/samples/trader/app/command/trading/Transaction.java
  19. +77 −0 ...src/main/java/org/axonframework/samples/trader/app/command/trading/TransactionCommandHandler.java
  20. +23 −0 app/src/main/java/org/axonframework/samples/trader/app/command/trading/TransactionType.java
  21. +17 −0 app/src/main/resources/META-INF/spring/command-context.xml
  22. +139 −0 ...est/java/org/axonframework/samples/trader/app/command/trading/TransactionCommandHandlingTest.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2011. Gridshore
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.axonframework.samples.trader.app.api.transaction;
+
+import org.axonframework.domain.AggregateIdentifier;
+
+/**
+ * @author Jettro Coenradie
+ */
+public class AbstractStartTransactionCommand {
+ private AggregateIdentifier orderbookIdentifier;
+ private AggregateIdentifier portfolioIdentifier;
+ private long tradeCount;
+ private long itemPrice;
+
+ public AbstractStartTransactionCommand(AggregateIdentifier orderbookIdentifier, AggregateIdentifier portfolioIdentifier, long tradeCount, long itemPrice) {
+ this.itemPrice = itemPrice;
+ this.orderbookIdentifier = orderbookIdentifier;
+ this.portfolioIdentifier = portfolioIdentifier;
+ this.tradeCount = tradeCount;
+ }
+
+ public long getItemPrice() {
+ return itemPrice;
+ }
+
+ public AggregateIdentifier getOrderbookIdentifier() {
+ return orderbookIdentifier;
+ }
+
+ public AggregateIdentifier getPortfolioIdentifier() {
+ return portfolioIdentifier;
+ }
+
+ public long getTradeCount() {
+ return tradeCount;
+ }
+}
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2011. Gridshore
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.axonframework.samples.trader.app.api.transaction;
+
+import org.axonframework.domain.AggregateIdentifier;
+import org.axonframework.domain.DomainEvent;
+
+/**
+ * @author Jettro Coenradie
+ */
+public abstract class AbstractTransactionStartedEvent extends DomainEvent {
+ private AggregateIdentifier orderbookIdentifier;
+ private AggregateIdentifier portfolioIdentifier;
+ private long totalItems;
+ private long pricePerItem;
+
+ public AbstractTransactionStartedEvent(AggregateIdentifier orderbookIdentifier,
+ AggregateIdentifier portfolioIdentifier,
+ long totalItems,
+ long pricePerItem) {
+ this.orderbookIdentifier = orderbookIdentifier;
+ this.portfolioIdentifier = portfolioIdentifier;
+ this.totalItems = totalItems;
+ this.pricePerItem = pricePerItem;
+ }
+
+ public AggregateIdentifier getOrderbookIdentifier() {
+ return orderbookIdentifier;
+ }
+
+ public AggregateIdentifier getPortfolioIdentifier() {
+ return portfolioIdentifier;
+ }
+
+ public long getPricePerItem() {
+ return pricePerItem;
+ }
+
+ public long getTotalItems() {
+ return totalItems;
+ }
+
+}
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2011. Gridshore
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.axonframework.samples.trader.app.api.transaction;
+
+import org.axonframework.domain.AggregateIdentifier;
+import org.axonframework.domain.DomainEvent;
+
+/**
+ * @author Jettro Coenradie
+ */
+public class BuyTransactionCancelledEvent extends DomainEvent {
+ private long totalAmountOfItems;
+ private long amountOfExecutedItems;
+
+ public BuyTransactionCancelledEvent(long totalAmountOfItems, long amountOfExecutedItems) {
+ this.totalAmountOfItems = totalAmountOfItems;
+ this.amountOfExecutedItems = amountOfExecutedItems;
+ }
+
+ public AggregateIdentifier getTransactionIdentifier() {
+ return super.getAggregateIdentifier();
+ }
+
+ public long getAmountOfExecutedItems() {
+ return amountOfExecutedItems;
+ }
+
+ public long getTotalAmountOfItems() {
+ return totalAmountOfItems;
+ }
+}
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2011. Gridshore
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.axonframework.samples.trader.app.api.transaction;
+
+import org.axonframework.domain.AggregateIdentifier;
+import org.axonframework.domain.DomainEvent;
+
+/**
+ * @author Jettro Coenradie
+ */
+public class BuyTransactionConfirmedEvent extends DomainEvent {
+ public AggregateIdentifier getTransactionIdentifier() {
+ return super.getAggregateIdentifier();
+ }
+}
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2011. Gridshore
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.axonframework.samples.trader.app.api.transaction;
+
+import org.axonframework.domain.AggregateIdentifier;
+import org.axonframework.domain.DomainEvent;
+
+/**
+ * @author Jettro Coenradie
+ */
+public class BuyTransactionExecutedEvent extends DomainEvent {
+ private long amountOfItems;
+ private long itemPrice;
+
+ public BuyTransactionExecutedEvent(long amountOfItems, long itemPrice) {
+ this.amountOfItems = amountOfItems;
+ this.itemPrice = itemPrice;
+ }
+
+ public AggregateIdentifier getTransactionIdentifier() {
+ return this.getAggregateIdentifier();
+ }
+
+ public long getAmountOfItems() {
+ return amountOfItems;
+ }
+
+ public long getItemPrice() {
+ return itemPrice;
+ }
+}
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2011. Gridshore
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.axonframework.samples.trader.app.api.transaction;
+
+import org.axonframework.domain.AggregateIdentifier;
+import org.axonframework.domain.DomainEvent;
+
+/**
+ * @author Jettro Coenradie
+ */
+public class BuyTransactionPartiallyExecutedEvent extends DomainEvent {
+ private long amountOfExecutedItems;
+ private long totalOfExecutedItems;
+ private long itemPrice;
+
+ public BuyTransactionPartiallyExecutedEvent(long amountOfExecutedItems, long totalOfExecutedItems, long itemPrice) {
+
+ this.amountOfExecutedItems = amountOfExecutedItems;
+ this.totalOfExecutedItems = totalOfExecutedItems;
+ this.itemPrice = itemPrice;
+ }
+
+ public AggregateIdentifier getTransactionIdentifier() {
+ return this.getAggregateIdentifier();
+ }
+
+ public long getAmountOfExecutedItems() {
+ return amountOfExecutedItems;
+ }
+
+ public void setAmountOfExecutedItems(long amountOfExecutedItems) {
+ this.amountOfExecutedItems = amountOfExecutedItems;
+ }
+
+ public long getItemPrice() {
+ return itemPrice;
+ }
+
+ public void setItemPrice(long itemPrice) {
+ this.itemPrice = itemPrice;
+ }
+
+ public long getTotalOfExecutedItems() {
+ return totalOfExecutedItems;
+ }
+
+ public void setTotalOfExecutedItems(long totalOfExecutedItems) {
+ this.totalOfExecutedItems = totalOfExecutedItems;
+ }
+}
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2011. Gridshore
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.axonframework.samples.trader.app.api.transaction;
+
+import org.axonframework.domain.AggregateIdentifier;
+
+/**
+ * @author Jettro Coenradie
+ */
+public class BuyTransactionStartedEvent extends AbstractTransactionStartedEvent {
+
+ public BuyTransactionStartedEvent(AggregateIdentifier orderbookIdentifier,
+ AggregateIdentifier portfolioIdentifier,
+ long totalItems,
+ long pricePerItem) {
+ super(orderbookIdentifier, portfolioIdentifier, totalItems, pricePerItem);
+ }
+}
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2011. Gridshore
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.axonframework.samples.trader.app.api.transaction;
+
+import org.axonframework.domain.AggregateIdentifier;
+
+/**
+ * @author Jettro Coenradie
+ */
+public class CancelTransactionCommand {
+ private AggregateIdentifier transactionIdentifier;
+
+ public CancelTransactionCommand(AggregateIdentifier transactionIdentifier) {
+ this.transactionIdentifier = transactionIdentifier;
+ }
+
+ public AggregateIdentifier getTransactionIdentifier() {
+ return transactionIdentifier;
+ }
+}
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2011. Gridshore
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.axonframework.samples.trader.app.api.transaction;
+
+import org.axonframework.domain.AggregateIdentifier;
+
+/**
+ * @author Jettro Coenradie
+ */
+public class ConfirmTransactionCommand {
+ private AggregateIdentifier transactionIdentifier;
+
+ public ConfirmTransactionCommand(AggregateIdentifier transactionIdentifier) {
+ this.transactionIdentifier = transactionIdentifier;
+ }
+
+ public AggregateIdentifier getTransactionIdentifier() {
+ return transactionIdentifier;
+ }
+}
Oops, something went wrong.

0 comments on commit 47eef8c

Please sign in to comment.