Skip to content

Commit

Permalink
Merge pull request #30341 from mkouba/cache-deployment-spi
Browse files Browse the repository at this point in the history
Cache - introduce the dev-spi module
  • Loading branch information
geoand authored Jan 13, 2023
2 parents c548f91 + 8ca8e3c commit 03cb806
Show file tree
Hide file tree
Showing 10 changed files with 75 additions and 5 deletions.
5 changes: 5 additions & 0 deletions bom/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2740,6 +2740,11 @@
<artifactId>quarkus-cache-deployment</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-cache-deployment-spi</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-google-cloud-functions</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,6 @@ public interface Capability {

String SMALLRYE_REACTIVE_MESSAGING = QUARKUS_PREFIX + "smallrye.reactive.messaging";
String REDIS_CLIENT = QUARKUS_PREFIX + "redis";

String CACHE = QUARKUS_PREFIX + "cache";
}
23 changes: 23 additions & 0 deletions extensions/cache/deployment-spi/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?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">
<parent>
<artifactId>quarkus-cache-parent</artifactId>
<groupId>io.quarkus</groupId>
<version>999-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>quarkus-cache-deployment-spi</artifactId>
<name>Quarkus - Cache - Deployment - SPI</name>

<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-core-deployment</artifactId>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package io.quarkus.cache.deployment.spi;

import io.quarkus.builder.item.MultiBuildItem;

/**
* Build item used to ensure that a cache of the specified name is created at runtime.
* <p>
* This is used in order to create caches when means other than the standard cache annotations are used.
*/
public final class AdditionalCacheNameBuildItem extends MultiBuildItem {

private final String name;

public AdditionalCacheNameBuildItem(String name) {
this.name = name;
}

public String getName() {
return name;
}
}
4 changes: 4 additions & 0 deletions extensions/cache/deployment/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-cache</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-cache-deployment-spi</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@
import io.quarkus.builder.item.MultiBuildItem;

/**
* Build item used to ensure that a cache of the specified name is created at runtime
* This is used in order to create caches when means other than the standard cache annotations are used
* Build item used to ensure that a cache of the specified name is created at runtime.
* <p>
* This is used in order to create caches when means other than the standard cache annotations are used.
*
* @deprecated Use {@link io.quarkus.cache.deployment.spi.AdditionalCacheNameBuildItem} instead. This build item will be removed
* at some time after Quarkus 3.0.
*/
@Deprecated(forRemoval = true)
public final class AdditionalCacheNameBuildItem extends MultiBuildItem {

private final String name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import io.quarkus.cache.deployment.exception.PrivateMethodTargetException;
import io.quarkus.cache.deployment.exception.UnsupportedRepeatedAnnotationException;
import io.quarkus.cache.deployment.exception.VoidReturnTypeTargetException;
import io.quarkus.cache.deployment.spi.AdditionalCacheNameBuildItem;
import io.quarkus.cache.runtime.CacheInvalidateAllInterceptor;
import io.quarkus.cache.runtime.CacheInvalidateInterceptor;
import io.quarkus.cache.runtime.CacheManagerRecorder;
Expand Down Expand Up @@ -86,7 +87,9 @@ AnnotationsTransformerBuildItem annotationsTransformer() {

@BuildStep
void validateCacheAnnotationsAndProduceCacheNames(CombinedIndexBuildItem combinedIndex,
List<AdditionalCacheNameBuildItem> additionalCacheNames, BuildProducer<ValidationErrorBuildItem> validationErrors,
List<AdditionalCacheNameBuildItem> additionalCacheNames,
List<io.quarkus.cache.deployment.AdditionalCacheNameBuildItem> additionalCacheNamesDeprecated,
BuildProducer<ValidationErrorBuildItem> validationErrors,
BuildProducer<CacheNamesBuildItem> cacheNames, BeanDiscoveryFinishedBuildItem beanDiscoveryFinished) {

// Validation errors produced by this build step.
Expand Down Expand Up @@ -155,6 +158,9 @@ void validateCacheAnnotationsAndProduceCacheNames(CombinedIndexBuildItem combine
for (AdditionalCacheNameBuildItem additionalCacheName : additionalCacheNames) {
names.add(additionalCacheName.getName());
}
for (io.quarkus.cache.deployment.AdditionalCacheNameBuildItem additionalCacheName : additionalCacheNamesDeprecated) {
names.add(additionalCacheName.getName());
}
cacheNames.produce(new CacheNamesBuildItem(names));

if (!keyGenerators.isEmpty()) {
Expand Down
1 change: 1 addition & 0 deletions extensions/cache/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

<modules>
<module>deployment</module>
<module>deployment-spi</module>
<module>runtime</module>
</modules>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ metadata:
status: "stable"
config:
- "quarkus.cache."
capabilities:
provides:
- "io.quarkus.cache"
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.quarkus.spring.cache;

import static io.quarkus.spring.cache.SpringCacheUtil.*;
import static io.quarkus.spring.cache.SpringCacheUtil.getSpringCacheName;

import java.util.ArrayList;
import java.util.Arrays;
Expand All @@ -20,7 +20,7 @@
import org.springframework.cache.annotation.Cacheable;

import io.quarkus.arc.deployment.AnnotationsTransformerBuildItem;
import io.quarkus.cache.deployment.AdditionalCacheNameBuildItem;
import io.quarkus.cache.deployment.spi.AdditionalCacheNameBuildItem;
import io.quarkus.deployment.Feature;
import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
Expand Down

0 comments on commit 03cb806

Please sign in to comment.