Last active
March 27, 2018 10:22
-
-
Save fb64/0c35271e3a2f023ece33c18bba6223f8 to your computer and use it in GitHub Desktop.
Workaround to load infinispan config from classthpath with spring-boot jcache configuration.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
spring: | |
cache: | |
jcache: | |
config: classpath:config/cache/infinispan.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.infinispan.configuration.parsing.ParserRegistry | |
import org.infinispan.jcache.embedded.JCacheManager | |
import org.infinispan.manager.DefaultCacheManager | |
import org.springframework.beans.factory.annotation.Autowired | |
import org.springframework.boot.autoconfigure.cache.CacheProperties | |
import org.springframework.cache.annotation.EnableCaching | |
import org.springframework.context.annotation.Bean | |
import org.springframework.context.annotation.Configuration | |
import java.net.URI | |
import javax.cache.CacheManager | |
import javax.cache.Caching | |
@Configuration | |
@EnableCaching | |
class CacheConfiguration { | |
@Autowired | |
@Bean | |
fun getCacheManager(cacheProperties: CacheProperties): CacheManager { | |
val configHolder= ParserRegistry().parse(cacheProperties.jcache.config.inputStream) | |
val cacheManager = DefaultCacheManager(configHolder,true) | |
return JCacheManager(URI.create(cacheManager.name), cacheManager, Caching.getCachingProvider()) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<infinispan xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="urn:infinispan:config:9.2 http://www.infinispan.org/schemas/infinispan-config-9.2.xsd" | |
xmlns="urn:infinispan:config:9.2"> | |
<cache-container default-cache="replicatedCache" name="mycache-container"> | |
<transport cluster="my-cluster"/> | |
<replicated-cache name="replicatedCache"/> | |
</cache-container> | |
</infinispan> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment