Our Thorntail (2.4.0.Final) webapp is using Infinispan as a JCache (JSR-107) provider. We would like to modify Infinispan specific attributes (such as default acquire timeout) in addition to JCache's attributes (such as store-by-value option).
Our current solution isn't working. Here's what we've tried so far.
- Defined
infinispan.xml
:
<infinispan
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:infinispan:config:5.2 http://www.infinispan.org/schemas/infinispan-config-9.4.xsd"
xmlns="urn:infinispan:config:9.4">
<cache-container>
<local-cache name="foo">
<locking acquire-timeout="15000"/>
</local-cache>
</cache-container>
</infinispan>
- The config above is then used by the following class:
public class CacheManagerProducer {
@Produces
@ApplicationScoped
public CacheManager defaultEmbeddedCacheManager() {
return Caching.getCachingProvider().getCacheManager(URI.create("infinispan.xml"), this.getClass().getClassLoader());
}
}
FooCache
interface is defined as:
@Qualifier
@Target({ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface FooCache {
}
- Here's how we're configuring cache using JCache API:
@Produces
@FooCache
public Cache<Long, DiscountOrAddition> createDiscoCache(InjectionPoint injectionPoint) {
MutableConfiguration<Long, DiscountOrAddition> config = new MutableConfiguration<>();
config.setStoreByValue(true);
config.setStatisticsEnabled(false);
config.setManagementEnabled(false);
return mgr.createCache("foo", config);
}
This is where we fail as foo
cache already exists (created as per XML config). Is there a way we could configure existing cache? Or any other alternative way allowing us to stay cache-provider agnostic? Thank you for your answers.