Skip to content

Commit

Permalink
Manual Changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jmontleon committed Apr 9, 2024
1 parent ab36d4c commit 29bb0f6
Show file tree
Hide file tree
Showing 2,539 changed files with 214 additions and 387 deletions.
117 changes: 53 additions & 64 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,116 +13,105 @@
<maven.build.timestamp.format>yyyyMMdd'T'HHmmss</maven.build.timestamp.format>
<project.encoding>UTF-8</project.encoding>
<maven.test.skip>true</maven.test.skip>
<quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
<quarkus.platform.group-id>io.quarkus.platform</quarkus.platform.group-id>
<quarkus.platform.version>3.1.0.Final</quarkus.platform.version>
<compiler-plugin.version>3.10.1</compiler-plugin.version>

<quarkus.platform.version>3.6.6</quarkus.platform.version>
<compiler-plugin.version>3.11.0</compiler-plugin.version>
<maven.compiler.release>11</maven.compiler.release>
<surefire-plugin.version>3.0.0</surefire-plugin.version>
<surefire-plugin.version>3.1.2</surefire-plugin.version>
<skipITs>true</skipITs>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>${quarkus.platform.group-id}</groupId>
<artifactId>${quarkus.platform.artifact-id}</artifactId>
<groupId>io.quarkus.platform</groupId>
<artifactId>quarkus-bom</artifactId>
<version>${quarkus.platform.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>com.sun.activation</groupId>
<artifactId>javax.activation</artifactId>
<version>1.2.0</version>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-arc</artifactId>
</dependency>
<!-- RESTEasy reactive is recommended, but won't work with @SessionScoped -->
<dependency>
<groupId>jakarta.platform</groupId>
<artifactId>jakarta.jakartaee-api</artifactId>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-jackson</artifactId>
</dependency>
<dependency>
<groupId>jakarta.platform</groupId>
<artifactId>jakarta.jakartaee-web-api</artifactId>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-rest-client</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-rest-client-jackson</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-reactive-messaging</artifactId>
</dependency>
<!-- Activate the dependency below if using AMQP -->
<!--
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-reactive-messaging-amqp</artifactId>
</dependency>
-->
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-hibernate-orm</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jdbc-postgresql</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-flyway</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-undertow</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-container-image-jib</artifactId>
</dependency>
</dependencies>

<build>
<finalName>ROOT</finalName>

<plugins>
<plugin>
<groupId>${quarkus.platform.group-id}</groupId>
<groupId>io.quarkus.platform</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<version>${quarkus.platform.version}</version>
<extensions>true</extensions>
<executions>
<execution>
<goals>
<goal>build</goal>
<goal>generate-code</goal>
<goal>generate-code-tests</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>${compiler-plugin.version}</version>
<configuration>
<compilerArgs>
<arg>-parameters</arg>
</compilerArgs>
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>${surefire-plugin.version}</version>
<configuration>
<systemPropertyVariables>
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
<maven.home>$</maven.home>
</systemPropertyVariables>
</configuration>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${surefire-plugin.version}</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<systemPropertyVariables>
<native.image.path>$/$-runner</native.image.path>
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
<maven.home>$</maven.home>
</systemPropertyVariables>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>native</id>
<activation>
<property>
<name>native</name>
</property>
</activation>
<properties>
<skipITs>false</skipITs>
<quarkus.package.type>native</quarkus.package.type>
</properties>
</profile>
<!-- TODO: Add OpenShift profile here -->
</profiles>
</project>
</project>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.redhat.coolstore.model;

import javax.persistence.*;
import jakarta.persistence.*;
import java.io.Serializable;

@Entity
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/redhat/coolstore/model/ShoppingCart.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import java.util.ArrayList;
import java.util.List;

import javax.enterprise.context.Dependent;
import jakarta.enterprise.context.Dependent;

@Dependent
public class ShoppingCart implements Serializable {
Expand Down
29 changes: 0 additions & 29 deletions src/main/java/com/redhat/coolstore/persistence/Resources.java

This file was deleted.

3 changes: 3 additions & 0 deletions src/main/java/com/redhat/coolstore/rest/RestApplication.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package com.redhat.coolstore.rest;

import jakarta.ws.rs.ApplicationPath;
import jakarta.ws.rs.core.Application;


@ApplicationPath("/services")
public class RestApplication extends Application {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.redhat.coolstore.rest.client;

import org.eclipse.microprofile.rest.client.inject.RegisterRestClient;

import com.redhat.coolstore.model.ShoppingCart;

import jakarta.ws.rs.Path;
import jakarta.ws.rs.POST;

@Path("/shipping")
@RegisterRestClient(configKey="shipping-service-api")
public interface ShippingServiceClient {

@POST
@Path("/calculateShipping")
public double calculateShipping(ShoppingCart sc);

@POST
@Path("/calculateShippingInsurance")
public double calculateShippingInsurance(ShoppingCart sc);

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,18 @@
import java.util.List;
import java.util.logging.Logger;

import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import jakarta.persistence.EntityManager;

import jakarta.persistence.criteria.CriteriaBuilder;
import jakarta.persistence.criteria.CriteriaQuery;
import jakarta.persistence.criteria.Root;

import jakarta.persistence.EntityManager;

import com.redhat.coolstore.model.*;

@ApplicationScoped
public class CatalogService {

@Inject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,26 @@

import com.redhat.coolstore.model.Order;
import com.redhat.coolstore.utils.Transformers;

import io.smallrye.common.annotation.Blocking;
import jakarta.inject.Inject;
import jakarta.naming.InitialContext;
import jakarta.naming.NamingException;
import io.smallrye.mutiny.Uni;
import io.smallrye.reactive.messaging.Channel;
import io.smallrye.reactive.messaging.Emitter;
import org.eclipse.microprofile.reactive.messaging.Message;
import jakarta.transaction.Transactional;

import org.eclipse.microprofile.reactive.messaging.Incoming;

public class InventoryNotificationMDB implements MessageListener {
public class InventoryNotificationMDB {

private static final int LOW_THRESHOLD = 50;

@Inject
private CatalogService catalogService;

@Inject
@Channel("topic/orders")
Emitter<String> orderEmitter;
@Incoming("orders")
@Blocking
@Transactional
public void onMessage(String orderStr) {
System.out.println("received message inventory");

@Override
public void onMessage(Message<String> rcvMessage) {
String orderStr = rcvMessage.getPayload();
Order order = Transformers.jsonToOrder(orderStr);
order.getItemList().forEach(orderItem -> {
int old_quantity = catalogService.getCatalogItemById(orderItem.getProductId()).getInventory().getQuantity();
Expand All @@ -34,10 +32,5 @@ public void onMessage(Message<String> rcvMessage) {
orderItem.setQuantity(new_quantity);
}
});

// Emit the updated order to the "topic/orders" channel
orderEmitter.send(Message.of(Transformers.orderToJson(order)));
}

// ... init() and close() methods remain unchanged
}
}
4 changes: 3 additions & 1 deletion src/main/java/com/redhat/coolstore/service/OrderService.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import com.redhat.coolstore.model.Order;
import java.util.List;

import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import jakarta.persistence.EntityManager;
import jakarta.persistence.criteria.CriteriaBuilder;
Expand Down Expand Up @@ -29,4 +31,4 @@ public List<Order> getOrders() {
public Order getOrderById(long id) {
return em.find(Order.class, id);
}
}
}
Loading

0 comments on commit 29bb0f6

Please sign in to comment.