Skip to content

Commit

Permalink
Integrate Micronaut-Coherence 4.0.0
Browse files Browse the repository at this point in the history
Integrate Coherence 23.03.1
  • Loading branch information
rlubke committed Jul 25, 2023
1 parent cf0b0e8 commit ad61394
Show file tree
Hide file tree
Showing 51 changed files with 420 additions and 251 deletions.
45 changes: 22 additions & 23 deletions carts/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>io.micronaut</groupId>
<groupId>io.micronaut.platform</groupId>
<artifactId>micronaut-parent</artifactId>
<version>3.7.2</version>
<version>4.0.0</version>
<relativePath/>
</parent>

Expand All @@ -28,14 +28,14 @@
<exec.mainClass>com.oracle.coherence.examples.sockshop.micronaut.carts.Application</exec.mainClass>
<container.repo>ghcr.io/oracle/coherence-micronaut-sockshop</container.repo>
<coherence.groupId>com.oracle.coherence.ce</coherence.groupId>
<coherence.version>23.03</coherence.version>
<coherence.version>23.03.1</coherence.version>
<version.lib.lombok>1.18.24</version.lib.lombok>
<version.lib.hamcrest>2.2</version.lib.hamcrest>
<version.lib.rest-assured>5.3.0</version.lib.rest-assured>
<version.lib.rest-assured>5.3.1</version.lib.rest-assured>
<version.lib.tracerresolver>0.1.8</version.lib.tracerresolver>

<!-- micronaut-parent overrides -->
<micronaut.coherence.version>3.7.2</micronaut.coherence.version>
<micronaut.coherence.version>4.0.0</micronaut.coherence.version>
</properties>

<repositories>
Expand Down Expand Up @@ -118,7 +118,7 @@
</dependency>
<dependency>
<groupId>io.micronaut</groupId>
<artifactId>micronaut-validation</artifactId>
<artifactId>micronaut-jackson-databind</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -156,6 +156,11 @@
<groupId>io.micronaut.micrometer</groupId>
<artifactId>micronaut-micrometer-registry-prometheus</artifactId>
</dependency>
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
Expand All @@ -177,6 +182,12 @@
<artifactId>logback-classic</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.fusesource.jansi</groupId>
<artifactId>jansi</artifactId>
<version>2.4.0</version>
<scope>test</scope>
</dependency>

<!-- tracing dependencies -->

Expand All @@ -186,20 +197,8 @@
</dependency>
<dependency>
<groupId>io.micronaut.tracing</groupId>
<artifactId>micronaut-tracing-zipkin</artifactId>
</dependency>

<!-- TODO Needs to be removed -->

<dependency>
<groupId>javax.json</groupId>
<artifactId>javax.json-api</artifactId>
<version>1.1.4</version>
</dependency>
<dependency>
<groupId>javax.json.bind</groupId>
<artifactId>javax.json.bind-api</artifactId>
<version>1.0</version>
<artifactId>micronaut-tracing-brave-http</artifactId>
<scope>compile</scope>
</dependency>

<!-- TODO Needs to be removed -->
Expand All @@ -214,9 +213,9 @@
<build>
<plugins>
<plugin>
<groupId>io.micronaut.build</groupId>
<groupId>io.micronaut.maven</groupId>
<artifactId>micronaut-maven-plugin</artifactId>
<version>3.1.1</version>
<version>${micronaut.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down Expand Up @@ -267,7 +266,7 @@
<version>${micronaut.version}</version>
</path>
<path>
<groupId>io.micronaut</groupId>
<groupId>io.micronaut.validation</groupId>
<artifactId>micronaut-validation</artifactId>
<version>${micronaut.version}</version>
</path>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Oracle and/or its affiliates.
* Copyright (c) 2021, 2023 Oracle and/or its affiliates.
*
* Licensed under the Universal Permissive License v 1.0 as shown at
* https://oss.oracle.com/licenses/upl.
Expand All @@ -12,7 +12,7 @@
import io.micronaut.http.annotation.Controller;
import io.micronaut.tracing.annotation.NewSpan;

import javax.inject.Inject;
import jakarta.inject.Inject;


/**
Expand All @@ -25,21 +25,20 @@ public class CartResource implements CartApi {
private CartRepository carts;

@Override
@NewSpan
public Cart getCart(String customerId) {
return carts.getOrCreateCart(customerId);
}

@Override
@NewSpan
@NewSpan("delete-cart")
public HttpResponse deleteCart(String customerId) {
return carts.deleteCart(customerId)
? HttpResponse.accepted()
: HttpResponse.notFound();
}

@Override
@NewSpan
@NewSpan("merge-carts")
public HttpResponse mergeCarts(String customerId, String sessionId) {
boolean fMerged = carts.mergeCarts(customerId, sessionId);
return fMerged
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Oracle and/or its affiliates.
* Copyright (c) 2021, 2023 Oracle and/or its affiliates.
*
* Licensed under the Universal Permissive License v 1.0 as shown at
* https://oss.oracle.com/licenses/upl.
Expand All @@ -11,7 +11,7 @@
import io.micronaut.http.annotation.Controller;
import io.micronaut.tracing.annotation.NewSpan;

import javax.inject.Inject;
import jakarta.inject.Inject;

import java.util.concurrent.CompletionStage;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Oracle and/or its affiliates.
* Copyright (c) 2021, 2023 Oracle and/or its affiliates.
*
* Licensed under the Universal Permissive License v 1.0 as shown at
* https://oss.oracle.com/licenses/upl.
Expand All @@ -11,6 +11,7 @@

import io.micronaut.coherence.data.annotation.CoherenceRepository;

import io.micronaut.tracing.annotation.NewSpan;
import java.util.List;

/**
Expand All @@ -23,11 +24,13 @@ public abstract class CoherenceCartRepository
implements CartRepository {

@Override
@NewSpan("getOrCreateCart")
public Cart getOrCreateCart(String customerId) {
return getMap().computeIfAbsent(customerId, v -> new Cart(customerId));
}

@Override
@NewSpan("mergeCarts")
public boolean mergeCarts(String targetId, String sourceId) {
final Cart source = this.removeById(sourceId, true);
if (source == null) {
Expand All @@ -40,31 +43,37 @@ public boolean mergeCarts(String targetId, String sourceId) {
}

@Override
@NewSpan("deleteCart")
public boolean deleteCart(String customerId) {
return removeById(customerId);
}

@Override
@NewSpan("getItems")
public List<Item> getItems(final String cartId) {
return getOrCreateCart(cartId).getItems();
}

@Override
@NewSpan("getItem")
public Item getItem(String cartId, String itemId) {
return getOrCreateCart(cartId).getItem(itemId);
}

@Override
@NewSpan("addItem")
public Item addItem(String cartId, Item item) {
return update(cartId, Cart::add, item, Cart::new);
}

@Override
@NewSpan("updateItem")
public Item updateItem(String cartId, Item item) {
return update(cartId, Cart::update, item, Cart::new);
}

@Override
@NewSpan("deleteItem")
public void deleteItem(String cartId, String itemId) {
update(cartId, Cart::remove, itemId, Cart::new);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Oracle and/or its affiliates.
* Copyright (c) 2021, 2023 Oracle and/or its affiliates.
*
* Licensed under the Universal Permissive License v 1.0 as shown at
* https://oss.oracle.com/licenses/upl.
Expand All @@ -10,6 +10,7 @@
import io.micronaut.coherence.data.AbstractCoherenceAsyncRepository;
import io.micronaut.coherence.data.annotation.CoherenceRepository;

import io.micronaut.tracing.annotation.NewSpan;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
Expand All @@ -24,11 +25,13 @@ public abstract class CoherenceCartRepositoryAsync
implements CartRepositoryAsync {

@Override
@NewSpan("asyncGetOrCreateCart")
public CompletionStage<Cart> getOrCreateCart(String customerId) {
return getMap().computeIfAbsent(customerId, v -> new Cart(customerId));
}

@Override
@NewSpan("asyncMergeCarts")
public CompletionStage<Boolean> mergeCarts(String targetId, String sourceId) {
CompletableFuture<Boolean> future = new CompletableFuture<>();
removeById(sourceId, true)
Expand All @@ -55,31 +58,37 @@ public CompletionStage<Boolean> mergeCarts(String targetId, String sourceId) {
}

@Override
@NewSpan("asyncDeleteCart")
public CompletionStage<Boolean> deleteCart(final String customerId) {
return removeById(customerId);
}

@Override
@NewSpan("asyncGetItem")
public CompletionStage<Item> getItem(String cartId, String itemId) {
return getOrCreateCart(cartId).thenApply(cart -> cart.getItem(itemId));
}

@Override
@NewSpan("asyncGetItems")
public CompletionStage<List<Item>> getItems(String cartId) {
return getOrCreateCart(cartId).thenApply(Cart::getItems);
}

@Override
@NewSpan("asyncAddItem")
public CompletionStage<Item> addItem(String cartId, Item item) {
return update(cartId, Cart::add, item, Cart::new);
}

@Override
@NewSpan("asyncUpdateItem")
public CompletionStage<Item> updateItem(String cartId, Item item) {
return update(cartId, Cart::update, item, Cart::new);
}

@Override
@NewSpan("asyncDeleteItem")
public CompletionStage<Void> deleteItem(String cartId, String itemId) {
return update(cartId, Cart::remove, itemId, Cart::new).thenAccept(cart -> {});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Oracle and/or its affiliates.
* Copyright (c) 2021, 2023 Oracle and/or its affiliates.
*
* Licensed under the Universal Permissive License v 1.0 as shown at
* https://oss.oracle.com/licenses/upl.
Expand All @@ -10,6 +10,7 @@
import com.fasterxml.jackson.annotation.JsonProperty;

import io.micronaut.http.HttpResponse;
import io.micronaut.http.annotation.Body;
import io.micronaut.http.annotation.Consumes;
import io.micronaut.http.annotation.Delete;
import io.micronaut.http.annotation.Get;
Expand Down Expand Up @@ -61,7 +62,7 @@ List<Item> getItems(@Parameter(name = "customerId", description = "Customer iden
schema = @Schema(implementation = Item.class)))
HttpResponse<Item> addItem(@Parameter(name = "customerId", description = "Customer identifier")
@PathVariable("customerId") String customerId,
@RequestBody(description = "Item to add to the cart") Item item);
@RequestBody(description = "Item to add to the cart") @Body Item item);

@Get("{itemId}")
@Produces(APPLICATION_JSON)
Expand Down Expand Up @@ -95,5 +96,5 @@ HttpResponse deleteItem(@Parameter(name = "customerId", description = "Customer
+ "if it does")
@ApiResponse(responseCode = "202", description = "Regardless of whether the specified item exists in the cart")
HttpResponse updateItem(@PathVariable("customerId") String customerId,
@RequestBody(description = "Item to update") Item item);
@RequestBody(description = "Item to update") @Body Item item);
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Oracle and/or its affiliates.
* Copyright (c) 2021, 2023 Oracle and/or its affiliates.
*
* Licensed under the Universal Permissive License v 1.0 as shown at
* https://oss.oracle.com/licenses/upl.
Expand All @@ -9,6 +9,7 @@


import io.micronaut.http.HttpResponse;
import io.micronaut.http.annotation.Body;
import io.micronaut.http.annotation.Consumes;
import io.micronaut.http.annotation.Delete;
import io.micronaut.http.annotation.Get;
Expand Down Expand Up @@ -59,7 +60,7 @@ public interface ItemsApiAsync {
content = @Content(mediaType = APPLICATION_JSON,
schema = @Schema(implementation = Item.class)))
CompletionStage<HttpResponse<Item>> addItem(@PathVariable("customerId") String customerId,
@RequestBody(description = "Item to add to the cart") Item item);
@RequestBody(description = "Item to add to the cart") @Body Item item);

@Get("{itemId}")
@Produces(APPLICATION_JSON)
Expand Down Expand Up @@ -91,5 +92,5 @@ CompletionStage<HttpResponse> deleteItem(@PathVariable("customerId") String cust
+ "if it does")
@ApiResponse(responseCode = "202", description = "Regardless of whether the specified item exists in the cart")
CompletionStage<HttpResponse> updateItem(@PathVariable("customerId") String customerId,
@RequestBody(description = "Item to update") Item item);
@RequestBody(description = "Item to update") @Body Item item);
}
Loading

0 comments on commit ad61394

Please sign in to comment.