From 8ca8e3cb73f07a4ef7559e478c5fb20f4ed0c995 Mon Sep 17 00:00:00 2001 From: Martin Kouba Date: Thu, 12 Jan 2023 15:27:16 +0100 Subject: [PATCH] Cache - introduce the dev-spi module - deprecate the io.quarkus.cache.deployment.AdditionalCacheNameBuildItem; io.quarkus.cache.deployment.spi.AdditionalCacheNameBuildItem should be used instead - also provide the io.quarkus.cache capability --- bom/application/pom.xml | 5 ++++ .../io/quarkus/deployment/Capability.java | 2 ++ extensions/cache/deployment-spi/pom.xml | 23 +++++++++++++++++++ .../spi/AdditionalCacheNameBuildItem.java | 21 +++++++++++++++++ extensions/cache/deployment/pom.xml | 4 ++++ .../AdditionalCacheNameBuildItem.java | 9 ++++++-- .../cache/deployment/CacheProcessor.java | 8 ++++++- extensions/cache/pom.xml | 1 + .../resources/META-INF/quarkus-extension.yaml | 3 +++ .../spring/cache/SpringCacheProcessor.java | 4 ++-- 10 files changed, 75 insertions(+), 5 deletions(-) create mode 100644 extensions/cache/deployment-spi/pom.xml create mode 100644 extensions/cache/deployment-spi/src/main/java/io/quarkus/cache/deployment/spi/AdditionalCacheNameBuildItem.java diff --git a/bom/application/pom.xml b/bom/application/pom.xml index 6a97f225182f5..67a8a30dc908b 100644 --- a/bom/application/pom.xml +++ b/bom/application/pom.xml @@ -2742,6 +2742,11 @@ quarkus-cache-deployment ${project.version} + + io.quarkus + quarkus-cache-deployment-spi + ${project.version} + io.quarkus quarkus-google-cloud-functions diff --git a/core/deployment/src/main/java/io/quarkus/deployment/Capability.java b/core/deployment/src/main/java/io/quarkus/deployment/Capability.java index 528cc15bc2294..cec753e121398 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/Capability.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/Capability.java @@ -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"; } diff --git a/extensions/cache/deployment-spi/pom.xml b/extensions/cache/deployment-spi/pom.xml new file mode 100644 index 0000000000000..1cfd1d01e99c2 --- /dev/null +++ b/extensions/cache/deployment-spi/pom.xml @@ -0,0 +1,23 @@ + + + + quarkus-cache-parent + io.quarkus + 999-SNAPSHOT + ../ + + 4.0.0 + + quarkus-cache-deployment-spi + Quarkus - Cache - Deployment - SPI + + + + io.quarkus + quarkus-core-deployment + + + + diff --git a/extensions/cache/deployment-spi/src/main/java/io/quarkus/cache/deployment/spi/AdditionalCacheNameBuildItem.java b/extensions/cache/deployment-spi/src/main/java/io/quarkus/cache/deployment/spi/AdditionalCacheNameBuildItem.java new file mode 100644 index 0000000000000..721a50ecfab69 --- /dev/null +++ b/extensions/cache/deployment-spi/src/main/java/io/quarkus/cache/deployment/spi/AdditionalCacheNameBuildItem.java @@ -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. + *

+ * 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; + } +} diff --git a/extensions/cache/deployment/pom.xml b/extensions/cache/deployment/pom.xml index a1c35c5f644c4..98136ccb95c4b 100644 --- a/extensions/cache/deployment/pom.xml +++ b/extensions/cache/deployment/pom.xml @@ -17,6 +17,10 @@ io.quarkus quarkus-cache + + + io.quarkus + quarkus-cache-deployment-spi io.quarkus diff --git a/extensions/cache/deployment/src/main/java/io/quarkus/cache/deployment/AdditionalCacheNameBuildItem.java b/extensions/cache/deployment/src/main/java/io/quarkus/cache/deployment/AdditionalCacheNameBuildItem.java index 0d3c636eb53e5..757001e957485 100644 --- a/extensions/cache/deployment/src/main/java/io/quarkus/cache/deployment/AdditionalCacheNameBuildItem.java +++ b/extensions/cache/deployment/src/main/java/io/quarkus/cache/deployment/AdditionalCacheNameBuildItem.java @@ -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. + *

+ * 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; diff --git a/extensions/cache/deployment/src/main/java/io/quarkus/cache/deployment/CacheProcessor.java b/extensions/cache/deployment/src/main/java/io/quarkus/cache/deployment/CacheProcessor.java index 18c6d4adc8043..907779962d749 100644 --- a/extensions/cache/deployment/src/main/java/io/quarkus/cache/deployment/CacheProcessor.java +++ b/extensions/cache/deployment/src/main/java/io/quarkus/cache/deployment/CacheProcessor.java @@ -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; @@ -86,7 +87,9 @@ AnnotationsTransformerBuildItem annotationsTransformer() { @BuildStep void validateCacheAnnotationsAndProduceCacheNames(CombinedIndexBuildItem combinedIndex, - List additionalCacheNames, BuildProducer validationErrors, + List additionalCacheNames, + List additionalCacheNamesDeprecated, + BuildProducer validationErrors, BuildProducer cacheNames, BeanDiscoveryFinishedBuildItem beanDiscoveryFinished) { // Validation errors produced by this build step. @@ -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()) { diff --git a/extensions/cache/pom.xml b/extensions/cache/pom.xml index 65befebd45a1e..092198414e79c 100644 --- a/extensions/cache/pom.xml +++ b/extensions/cache/pom.xml @@ -17,6 +17,7 @@ deployment + deployment-spi runtime diff --git a/extensions/cache/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions/cache/runtime/src/main/resources/META-INF/quarkus-extension.yaml index 24b7c04af0ad8..e5b7fe4d1891c 100644 --- a/extensions/cache/runtime/src/main/resources/META-INF/quarkus-extension.yaml +++ b/extensions/cache/runtime/src/main/resources/META-INF/quarkus-extension.yaml @@ -11,3 +11,6 @@ metadata: status: "stable" config: - "quarkus.cache." + capabilities: + provides: + - "io.quarkus.cache" diff --git a/extensions/spring-cache/deployment/src/main/java/io/quarkus/spring/cache/SpringCacheProcessor.java b/extensions/spring-cache/deployment/src/main/java/io/quarkus/spring/cache/SpringCacheProcessor.java index ea60e29620558..aa5f4ca4fd388 100644 --- a/extensions/spring-cache/deployment/src/main/java/io/quarkus/spring/cache/SpringCacheProcessor.java +++ b/extensions/spring-cache/deployment/src/main/java/io/quarkus/spring/cache/SpringCacheProcessor.java @@ -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; @@ -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;