Java 26392 Move modules to patterns-module (#15060)
* JAVA-26392 Move axon module and ddd module to patterns-modules * JAVA-26292 Move ddd-contexts to patterns-module
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.baeldung.dddcontexts.ordercontext</groupId>
|
||||
<artifactId>ddd-contexts-ordercontext</artifactId>
|
||||
<version>1.0</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung.dddcontexts</groupId>
|
||||
<artifactId>ddd-contexts</artifactId>
|
||||
<version>1.0</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.baeldung.dddcontexts.sharedkernel</groupId>
|
||||
<artifactId>ddd-contexts-sharedkernel</artifactId>
|
||||
<version>${appmodules.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>${source.version}</source>
|
||||
<target>${target.version}</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<source.version>9</source.version>
|
||||
<target.version>9</target.version>
|
||||
<entitymodule.version>1.0</entitymodule.version>
|
||||
<daomodule.version>1.0</daomodule.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
package com.baeldung.dddcontexts.ordercontext.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CustomerOrder {
|
||||
private int orderId;
|
||||
private String paymentMethod;
|
||||
private String address;
|
||||
private List<OrderItem> orderItems;
|
||||
|
||||
public CustomerOrder() {
|
||||
|
||||
}
|
||||
|
||||
public float calculateTotalPrice() {
|
||||
return orderItems.stream().map(OrderItem::getTotalPrice)
|
||||
.reduce(0F, Float::sum);
|
||||
}
|
||||
|
||||
public void setOrderItems(List<OrderItem> orderItems) {
|
||||
this.orderItems = orderItems;
|
||||
}
|
||||
|
||||
public int getOrderId() {
|
||||
return orderId;
|
||||
}
|
||||
|
||||
public List<OrderItem> getOrderItems() {
|
||||
return orderItems;
|
||||
}
|
||||
|
||||
public void setOrderId(int orderId) {
|
||||
this.orderId = orderId;
|
||||
}
|
||||
|
||||
public String getPaymentMethod() {
|
||||
return paymentMethod;
|
||||
}
|
||||
|
||||
public void setPaymentMethod(String paymentMethod) {
|
||||
this.paymentMethod = paymentMethod;
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public void setAddress(String address) {
|
||||
this.address = address;
|
||||
}
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
package com.baeldung.dddcontexts.ordercontext.model;
|
||||
|
||||
public class OrderItem {
|
||||
private int productId;
|
||||
private int quantity;
|
||||
private float unitPrice;
|
||||
private float unitWeight;
|
||||
|
||||
public OrderItem(int productId, int quantity, float unitPrice, float unitWeight) {
|
||||
this.productId = productId;
|
||||
this.quantity = quantity;
|
||||
this.unitPrice = unitPrice;
|
||||
this.unitWeight = unitWeight;
|
||||
}
|
||||
|
||||
public int getProductId() {
|
||||
return productId;
|
||||
}
|
||||
|
||||
public void setProductId(int productId) {
|
||||
this.productId = productId;
|
||||
}
|
||||
|
||||
public int getQuantity() {
|
||||
return quantity;
|
||||
}
|
||||
|
||||
public void setQuantity(int quantity) {
|
||||
this.quantity = quantity;
|
||||
}
|
||||
|
||||
public float getTotalPrice() {
|
||||
return this.quantity * this.unitPrice;
|
||||
}
|
||||
|
||||
public void setUnitPrice(float unitPrice) {
|
||||
this.unitPrice = unitPrice;
|
||||
}
|
||||
|
||||
public float getUnitWeight() {
|
||||
return unitWeight;
|
||||
}
|
||||
|
||||
public float getUnitPrice() {
|
||||
return unitPrice;
|
||||
}
|
||||
|
||||
public void setUnitWeight(float unitWeight) {
|
||||
this.unitWeight = unitWeight;
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package com.baeldung.dddcontexts.ordercontext.repository;
|
||||
|
||||
import com.baeldung.dddcontexts.ordercontext.model.CustomerOrder;
|
||||
|
||||
public interface CustomerOrderRepository {
|
||||
void saveCustomerOrder(CustomerOrder order);
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
package com.baeldung.dddcontexts.ordercontext.service;
|
||||
|
||||
import com.baeldung.dddcontexts.ordercontext.model.CustomerOrder;
|
||||
import com.baeldung.dddcontexts.ordercontext.repository.CustomerOrderRepository;
|
||||
import com.baeldung.dddcontexts.sharedkernel.events.ApplicationEvent;
|
||||
import com.baeldung.dddcontexts.sharedkernel.events.EventBus;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class CustomerOrderService implements OrderService {
|
||||
public static final String EVENT_ORDER_READY_FOR_SHIPMENT = "OrderReadyForShipmentEvent";
|
||||
|
||||
private CustomerOrderRepository orderRepository;
|
||||
private EventBus eventBus;
|
||||
|
||||
@Override
|
||||
public void placeOrder(CustomerOrder order) {
|
||||
this.orderRepository.saveCustomerOrder(order);
|
||||
Map<String, String> payload = new HashMap<>();
|
||||
payload.put("order_id", String.valueOf(order.getOrderId()));
|
||||
ApplicationEvent event = new ApplicationEvent(payload) {
|
||||
@Override
|
||||
public String getType() {
|
||||
return EVENT_ORDER_READY_FOR_SHIPMENT;
|
||||
}
|
||||
};
|
||||
this.eventBus.publish(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventBus getEventBus() {
|
||||
return eventBus;
|
||||
}
|
||||
|
||||
public void setOrderRepository(CustomerOrderRepository orderRepository) {
|
||||
this.orderRepository = orderRepository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEventBus(EventBus eventBus) {
|
||||
this.eventBus = eventBus;
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package com.baeldung.dddcontexts.ordercontext.service;
|
||||
|
||||
import com.baeldung.dddcontexts.ordercontext.model.CustomerOrder;
|
||||
import com.baeldung.dddcontexts.ordercontext.repository.CustomerOrderRepository;
|
||||
import com.baeldung.dddcontexts.sharedkernel.service.ApplicationService;
|
||||
|
||||
public interface OrderService extends ApplicationService {
|
||||
void placeOrder(CustomerOrder order);
|
||||
|
||||
void setOrderRepository(CustomerOrderRepository orderRepository);
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
module com.baeldung.dddcontexts.ordercontext {
|
||||
requires com.baeldung.dddcontexts.sharedkernel;
|
||||
exports com.baeldung.dddcontexts.ordercontext.service;
|
||||
exports com.baeldung.dddcontexts.ordercontext.model;
|
||||
exports com.baeldung.dddcontexts.ordercontext.repository;
|
||||
provides com.baeldung.dddcontexts.ordercontext.service.OrderService
|
||||
with com.baeldung.dddcontexts.ordercontext.service.CustomerOrderService;
|
||||
}
|
||||
Reference in New Issue
Block a user