Drop support for Infinispan until it is Jakarta EE 9 compatible

Closes gh-28799
pull/28862/head
Andy Wilkinson 3 years ago
parent 015dca1956
commit a17d6f9791

@ -110,13 +110,6 @@ dependencies {
exclude group: "org.jboss.spec.javax.transaction", module: "jboss-transaction-api_1.2_spec" exclude group: "org.jboss.spec.javax.transaction", module: "jboss-transaction-api_1.2_spec"
} }
optional("org.hibernate.validator:hibernate-validator") optional("org.hibernate.validator:hibernate-validator")
optional("org.infinispan:infinispan-component-annotations")
optional("org.infinispan:infinispan-jcache") {
exclude group: "org.jboss.spec.javax.transaction", module: "jboss-transaction-api_1.2_spec"
}
optional("org.infinispan:infinispan-spring5-embedded") {
exclude group: "org.jboss.spec.javax.transaction", module: "jboss-transaction-api_1.2_spec"
}
optional("org.influxdb:influxdb-java") optional("org.influxdb:influxdb-java")
optional("org.jooq:jooq") { optional("org.jooq:jooq") {
exclude group: "javax.xml.bind", module: "jaxb-api" exclude group: "javax.xml.bind", module: "jaxb-api"

@ -37,7 +37,6 @@ final class CacheConfigurations {
Map<CacheType, String> mappings = new EnumMap<>(CacheType.class); Map<CacheType, String> mappings = new EnumMap<>(CacheType.class);
mappings.put(CacheType.GENERIC, GenericCacheConfiguration.class.getName()); mappings.put(CacheType.GENERIC, GenericCacheConfiguration.class.getName());
mappings.put(CacheType.HAZELCAST, HazelcastCacheConfiguration.class.getName()); mappings.put(CacheType.HAZELCAST, HazelcastCacheConfiguration.class.getName());
mappings.put(CacheType.INFINISPAN, InfinispanCacheConfiguration.class.getName());
mappings.put(CacheType.JCACHE, JCacheCacheConfiguration.class.getName()); mappings.put(CacheType.JCACHE, JCacheCacheConfiguration.class.getName());
mappings.put(CacheType.REDIS, RedisCacheConfiguration.class.getName()); mappings.put(CacheType.REDIS, RedisCacheConfiguration.class.getName());
mappings.put(CacheType.CAFFEINE, CaffeineCacheConfiguration.class.getName()); mappings.put(CacheType.CAFFEINE, CaffeineCacheConfiguration.class.getName());

@ -50,8 +50,6 @@ public class CacheProperties {
private final Couchbase couchbase = new Couchbase(); private final Couchbase couchbase = new Couchbase();
private final Infinispan infinispan = new Infinispan();
private final JCache jcache = new JCache(); private final JCache jcache = new JCache();
private final Redis redis = new Redis(); private final Redis redis = new Redis();
@ -80,10 +78,6 @@ public class CacheProperties {
return this.couchbase; return this.couchbase;
} }
public Infinispan getInfinispan() {
return this.infinispan;
}
public JCache getJcache() { public JCache getJcache() {
return this.jcache; return this.jcache;
} }
@ -150,26 +144,6 @@ public class CacheProperties {
} }
/**
* Infinispan specific cache properties.
*/
public static class Infinispan {
/**
* The location of the configuration file to use to initialize Infinispan.
*/
private Resource config;
public Resource getConfig() {
return this.config;
}
public void setConfig(Resource config) {
this.config = config;
}
}
/** /**
* JCache (JSR-107) specific cache properties. * JCache (JSR-107) specific cache properties.
*/ */

@ -41,11 +41,6 @@ public enum CacheType {
*/ */
HAZELCAST, HAZELCAST,
/**
* Infinispan backed caching.
*/
INFINISPAN,
/** /**
* Redis backed caching. * Redis backed caching.
*/ */

@ -1,90 +0,0 @@
/*
* Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.cache;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import org.infinispan.configuration.cache.ConfigurationBuilder;
import org.infinispan.manager.DefaultCacheManager;
import org.infinispan.manager.EmbeddedCacheManager;
import org.infinispan.spring.embedded.provider.SpringEmbeddedCacheManager;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.cache.CacheManager;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.Resource;
import org.springframework.util.CollectionUtils;
/**
* Infinispan cache configuration.
*
* @author Eddú Meléndez
* @author Stephane Nicoll
* @author Raja Kolli
* @since 1.3.0
*/
@Configuration(proxyBeanMethods = false)
@ConditionalOnClass(SpringEmbeddedCacheManager.class)
@ConditionalOnMissingBean(CacheManager.class)
@Conditional(CacheCondition.class)
public class InfinispanCacheConfiguration {
@Bean
public SpringEmbeddedCacheManager cacheManager(CacheManagerCustomizers customizers,
EmbeddedCacheManager embeddedCacheManager) {
SpringEmbeddedCacheManager cacheManager = new SpringEmbeddedCacheManager(embeddedCacheManager);
return customizers.customize(cacheManager);
}
@Bean(destroyMethod = "stop")
@ConditionalOnMissingBean
public EmbeddedCacheManager infinispanCacheManager(CacheProperties cacheProperties,
ObjectProvider<ConfigurationBuilder> defaultConfigurationBuilder) throws IOException {
EmbeddedCacheManager cacheManager = createEmbeddedCacheManager(cacheProperties);
List<String> cacheNames = cacheProperties.getCacheNames();
if (!CollectionUtils.isEmpty(cacheNames)) {
cacheNames.forEach((cacheName) -> cacheManager.defineConfiguration(cacheName,
getDefaultCacheConfiguration(defaultConfigurationBuilder.getIfAvailable())));
}
return cacheManager;
}
private EmbeddedCacheManager createEmbeddedCacheManager(CacheProperties cacheProperties) throws IOException {
Resource location = cacheProperties.resolveConfigLocation(cacheProperties.getInfinispan().getConfig());
if (location != null) {
try (InputStream in = location.getInputStream()) {
return new DefaultCacheManager(in);
}
}
return new DefaultCacheManager();
}
private org.infinispan.configuration.cache.Configuration getDefaultCacheConfiguration(
ConfigurationBuilder defaultConfigurationBuilder) {
if (defaultConfigurationBuilder != null) {
return defaultConfigurationBuilder.build();
}
return new ConfigurationBuilder().build();
}
}

@ -22,7 +22,6 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import com.hazelcast.spring.cache.HazelcastCacheManager; import com.hazelcast.spring.cache.HazelcastCacheManager;
import org.infinispan.spring.embedded.provider.SpringEmbeddedCacheManager;
import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.test.context.assertj.AssertableApplicationContext; import org.springframework.boot.test.context.assertj.AssertableApplicationContext;
@ -79,49 +78,42 @@ abstract class AbstractCacheAutoConfigurationTests {
@Bean @Bean
CacheManagerCustomizer<CacheManager> allCacheManagerCustomizer() { CacheManagerCustomizer<CacheManager> allCacheManagerCustomizer() {
return new CacheManagerTestCustomizer<CacheManager>() { return new CacheManagerTestCustomizer<>() {
}; };
} }
@Bean @Bean
CacheManagerCustomizer<ConcurrentMapCacheManager> simpleCacheManagerCustomizer() { CacheManagerCustomizer<ConcurrentMapCacheManager> simpleCacheManagerCustomizer() {
return new CacheManagerTestCustomizer<ConcurrentMapCacheManager>() { return new CacheManagerTestCustomizer<>() {
}; };
} }
@Bean @Bean
CacheManagerCustomizer<SimpleCacheManager> genericCacheManagerCustomizer() { CacheManagerCustomizer<SimpleCacheManager> genericCacheManagerCustomizer() {
return new CacheManagerTestCustomizer<SimpleCacheManager>() { return new CacheManagerTestCustomizer<>() {
}; };
} }
@Bean @Bean
CacheManagerCustomizer<RedisCacheManager> redisCacheManagerCustomizer() { CacheManagerCustomizer<RedisCacheManager> redisCacheManagerCustomizer() {
return new CacheManagerTestCustomizer<RedisCacheManager>() { return new CacheManagerTestCustomizer<>() {
}; };
} }
@Bean @Bean
CacheManagerCustomizer<HazelcastCacheManager> hazelcastCacheManagerCustomizer() { CacheManagerCustomizer<HazelcastCacheManager> hazelcastCacheManagerCustomizer() {
return new CacheManagerTestCustomizer<HazelcastCacheManager>() { return new CacheManagerTestCustomizer<>() {
};
}
@Bean
CacheManagerCustomizer<SpringEmbeddedCacheManager> infinispanCacheManagerCustomizer() {
return new CacheManagerTestCustomizer<SpringEmbeddedCacheManager>() {
}; };
} }
@Bean @Bean
CacheManagerCustomizer<CaffeineCacheManager> caffeineCacheManagerCustomizer() { CacheManagerCustomizer<CaffeineCacheManager> caffeineCacheManagerCustomizer() {
return new CacheManagerTestCustomizer<CaffeineCacheManager>() { return new CacheManagerTestCustomizer<>() {
}; };
} }

@ -32,9 +32,6 @@ import com.hazelcast.cache.impl.HazelcastServerCachingProvider;
import com.hazelcast.core.Hazelcast; import com.hazelcast.core.Hazelcast;
import com.hazelcast.core.HazelcastInstance; import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.spring.cache.HazelcastCacheManager; import com.hazelcast.spring.cache.HazelcastCacheManager;
import org.infinispan.configuration.cache.ConfigurationBuilder;
import org.infinispan.jcache.embedded.JCachingProvider;
import org.infinispan.spring.embedded.provider.SpringEmbeddedCacheManager;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.BeanCreationException; import org.springframework.beans.factory.BeanCreationException;
@ -70,8 +67,6 @@ import org.springframework.test.util.ReflectionTestUtils;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.BDDMockito.given; import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
/** /**
* Tests for {@link CacheAutoConfiguration}. * Tests for {@link CacheAutoConfiguration}.
@ -475,71 +470,6 @@ class CacheAutoConfigurationTests extends AbstractCacheAutoConfigurationTests {
}); });
} }
@Test
void infinispanCacheWithConfig() {
this.contextRunner.withUserConfiguration(DefaultCacheConfiguration.class)
.withPropertyValues("spring.cache.type=infinispan", "spring.cache.infinispan.config=infinispan.xml")
.run((context) -> {
SpringEmbeddedCacheManager cacheManager = getCacheManager(context,
SpringEmbeddedCacheManager.class);
assertThat(cacheManager.getCacheNames()).contains("foo", "bar");
});
}
@Test
void infinispanCacheWithCustomizers() {
this.contextRunner.withUserConfiguration(DefaultCacheAndCustomizersConfiguration.class)
.withPropertyValues("spring.cache.type=infinispan")
.run(verifyCustomizers("allCacheManagerCustomizer", "infinispanCacheManagerCustomizer"));
}
@Test
void infinispanCacheWithCaches() {
this.contextRunner.withUserConfiguration(DefaultCacheConfiguration.class)
.withPropertyValues("spring.cache.type=infinispan", "spring.cache.cacheNames[0]=foo",
"spring.cache.cacheNames[1]=bar")
.run((context) -> assertThat(getCacheManager(context, SpringEmbeddedCacheManager.class).getCacheNames())
.containsOnly("foo", "bar"));
}
@Test
void infinispanCacheWithCachesAndCustomConfig() {
this.contextRunner.withUserConfiguration(InfinispanCustomConfiguration.class)
.withPropertyValues("spring.cache.type=infinispan", "spring.cache.cacheNames[0]=foo",
"spring.cache.cacheNames[1]=bar")
.run((context) -> {
assertThat(getCacheManager(context, SpringEmbeddedCacheManager.class).getCacheNames())
.containsOnly("foo", "bar");
verify(context.getBean(ConfigurationBuilder.class), times(2)).build();
});
}
@Test
void infinispanAsJCacheWithCaches() {
String cachingProviderClassName = JCachingProvider.class.getName();
this.contextRunner.withUserConfiguration(DefaultCacheConfiguration.class)
.withPropertyValues("spring.cache.type=jcache",
"spring.cache.jcache.provider=" + cachingProviderClassName, "spring.cache.cacheNames[0]=foo",
"spring.cache.cacheNames[1]=bar")
.run((context) -> assertThat(getCacheManager(context, JCacheCacheManager.class).getCacheNames())
.containsOnly("foo", "bar"));
}
@Test
void infinispanAsJCacheWithConfig() {
String cachingProviderClassName = JCachingProvider.class.getName();
String configLocation = "infinispan.xml";
this.contextRunner.withUserConfiguration(DefaultCacheConfiguration.class)
.withPropertyValues("spring.cache.type=jcache",
"spring.cache.jcache.provider=" + cachingProviderClassName,
"spring.cache.jcache.config=" + configLocation)
.run((context) -> {
Resource configResource = new ClassPathResource(configLocation);
assertThat(getCacheManager(context, JCacheCacheManager.class).getCacheManager().getURI())
.isEqualTo(configResource.getURI());
});
}
@Test @Test
void jCacheCacheWithCachesAndCustomizer() { void jCacheCacheWithCachesAndCustomizer() {
String cachingProviderFqn = HazelcastServerCachingProvider.class.getName(); String cachingProviderFqn = HazelcastServerCachingProvider.class.getName();
@ -764,19 +694,6 @@ class CacheAutoConfigurationTests extends AbstractCacheAutoConfigurationTests {
} }
@Configuration(proxyBeanMethods = false)
@EnableCaching
static class InfinispanCustomConfiguration {
@Bean
ConfigurationBuilder configurationBuilder() {
ConfigurationBuilder builder = mock(ConfigurationBuilder.class);
given(builder.build()).willReturn(new ConfigurationBuilder().build());
return builder;
}
}
@Configuration(proxyBeanMethods = false) @Configuration(proxyBeanMethods = false)
@EnableCaching @EnableCaching
static class CustomCacheManagerConfiguration { static class CustomCacheManagerConfiguration {

@ -459,13 +459,6 @@ bom {
] ]
} }
} }
library("Infinispan", "12.1.7.Final") {
group("org.infinispan") {
imports = [
"infinispan-bom"
]
}
}
library("InfluxDB Java", "2.22") { library("InfluxDB Java", "2.22") {
group("org.influxdb") { group("org.influxdb") {
modules = [ modules = [

@ -2,7 +2,7 @@
== IO == IO
If your application needs IO capabilities, see one or more of the following sections: If your application needs IO capabilities, see one or more of the following sections:
* *Caching:* <<io#io.caching, Caching support EhCache, Hazelcast, Infinispan and more>> * *Caching:* <<io#io.caching, Caching support EhCache, Hazelcast and more>>
* *Quartz:* <<io#io.quartz, Quartz Scheduling>> * *Quartz:* <<io#io.quartz, Quartz Scheduling>>
* *Mail:* <<io#io.email, Sending Email>> * *Mail:* <<io#io.email, Sending Email>>
* *Validation:* <<io#io.validation, JSR-303 Validation>> * *Validation:* <<io#io.validation, JSR-303 Validation>>

@ -40,9 +40,8 @@ The cache abstraction does not provide an actual store and relies on abstraction
If you have not defined a bean of type `CacheManager` or a `CacheResolver` named `cacheResolver` (see {spring-framework-api}/cache/annotation/CachingConfigurer.html[`CachingConfigurer`]), Spring Boot tries to detect the following providers (in the indicated order): If you have not defined a bean of type `CacheManager` or a `CacheResolver` named `cacheResolver` (see {spring-framework-api}/cache/annotation/CachingConfigurer.html[`CachingConfigurer`]), Spring Boot tries to detect the following providers (in the indicated order):
. <<io#io.caching.provider.generic,Generic>> . <<io#io.caching.provider.generic,Generic>>
. <<io#io.caching.provider.jcache,JCache (JSR-107)>> (EhCache 3, Hazelcast, Infinispan, and others) . <<io#io.caching.provider.jcache,JCache (JSR-107)>> (EhCache 3, Hazelcast, and others)
. <<io#io.caching.provider.hazelcast,Hazelcast>> . <<io#io.caching.provider.hazelcast,Hazelcast>>
. <<io#io.caching.provider.infinispan,Infinispan>>
. <<io#io.caching.provider.redis,Redis>> . <<io#io.caching.provider.redis,Redis>>
. <<io#io.caching.provider.caffeine,Caffeine>> . <<io#io.caching.provider.caffeine,Caffeine>>
. <<io#io.caching.provider.simple,Simple>> . <<io#io.caching.provider.simple,Simple>>
@ -78,7 +77,7 @@ A `CacheManager` wrapping all beans of that type is created.
[[io.caching.provider.jcache]] [[io.caching.provider.jcache]]
==== JCache (JSR-107) ==== JCache (JSR-107)
https://jcp.org/en/jsr/detail?id=107[JCache] is bootstrapped through the presence of a `javax.cache.spi.CachingProvider` on the classpath (that is, a JSR-107 compliant caching library exists on the classpath), and the `JCacheCacheManager` is provided by the `spring-boot-starter-cache` "`Starter`". https://jcp.org/en/jsr/detail?id=107[JCache] is bootstrapped through the presence of a `javax.cache.spi.CachingProvider` on the classpath (that is, a JSR-107 compliant caching library exists on the classpath), and the `JCacheCacheManager` is provided by the `spring-boot-starter-cache` "`Starter`".
Various compliant libraries are available, and Spring Boot provides dependency management for Ehcache 3, Hazelcast, and Infinispan. Various compliant libraries are available, and Spring Boot provides dependency management for Ehcache 3 and Hazelcast.
Any other compliant library can be added as well. Any other compliant library can be added as well.
It might happen that more than one provider is present, in which case the provider must be explicitly specified. It might happen that more than one provider is present, in which case the provider must be explicitly specified.
@ -117,28 +116,6 @@ If a `HazelcastInstance` has been auto-configured, it is automatically wrapped i
[[io.caching.provider.infinispan]]
==== Infinispan
https://infinispan.org/[Infinispan] has no default configuration file location, so it must be specified explicitly.
Otherwise, the default bootstrap is used.
[source,yaml,indent=0,subs="verbatim",configprops,configblocks]
----
spring:
cache:
infinispan:
config: "infinispan.xml"
----
Caches can be created on startup by setting the configprop:spring.cache.cache-names[] property.
If a custom `ConfigurationBuilder` bean is defined, it is used to customize the caches.
NOTE: The support of Infinispan in Spring Boot is restricted to the embedded mode and is quite basic.
If you want more options, you should use the official Infinispan Spring Boot starter instead.
See https://github.com/infinispan/infinispan-spring-boot[Infinispan's documentation] for more details.
[[io.caching.provider.redis]] [[io.caching.provider.redis]]
==== Redis ==== Redis
If https://redis.io/[Redis] is available and configured, a `RedisCacheManager` is auto-configured. If https://redis.io/[Redis] is available and configured, a `RedisCacheManager` is auto-configured.

@ -17,10 +17,6 @@ def caches = [
"com.hazelcast:hazelcast", "com.hazelcast:hazelcast",
"com.hazelcast:hazelcast-spring" "com.hazelcast:hazelcast-spring"
], ],
"infinispan": [
"org.infinispan:infinispan-jcache",
"org.infinispan:infinispan-spring5-embedded"
],
"redis": [ "redis": [
project(":spring-boot-project:spring-boot-starters:spring-boot-starter-data-redis") project(":spring-boot-project:spring-boot-starters:spring-boot-starter-data-redis")
] ]

Loading…
Cancel
Save