1

I'm using Wildfly 10.1.0 + Infinispan 8.2.4.Final + cache API 1.0.0 trying to enable Infinispan Jcache Interceptors in my application with minimum efforts, with no programmatic setup if possible. I wanted to make such an annotation work to store some dictionaries:

@CacheResult(cacheName = "dictionary", cacheKeyGenerator = MyCacheKeyGeneratorImpl.class)  
public List getDictionary() {  
   ...  
}  

I initially started this activity because I missed Spring @Cacheable annotations (we currently don't use Spring config/CDI, just a few libraries like Spring Data JPA Repositories). So I downloaded Infinispan Wilfly/EAP module, unpacked it to Wilfly modules folder and added this to jboss-deployment-structure.xml:

<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
  <deployment>
  <dependencies>
  <module name="org.infinispan" slot="ispn-8.2" services="export"/>
  <module name="org.infinispan.cdi" slot="ispn-8.2" services="export"/>
  <module name="org.infinispan.jcache" slot="ispn-8.2" services="export"/>
  </dependencies>
  </deployment>
</jboss-deployment-structure>

Now the annotations are processed and some default cache container is used to create "dictionary" cache. Now I want to fine-tune this cache container. What's the common way to inject infinispan configuration? Is it possible to plug the module settings into the main Wilfly configuration file (standalone.xml) to define this cache container like this, or specify them in a separate file?

<cache-container name="JCacheContainer" default-cache="default" module="org.infinispan.jcache">
  <local-cache name="default">
   <transaction mode="NONE"/>
   <eviction strategy="LRU" max-entries="1000"/>
   <expiration max-idle="3600000"/>
  </local-cache>
  <local-cache name="dictionary">
   <locking acquire-timeout="15000" isolation="REPEATABLE_READ"/>
   <transaction locking="PESSIMISTIC" mode="NONE"/>
   <eviction strategy="LRU" max-entries="100000"/>
   <expiration lifespan="15000" max-idle="15000"/>
  </local-cache>
</cache-container>

Any help is very much appreciated.

dfche
  • 3,403
  • 2
  • 24
  • 32

1 Answers1

2

A working example of such configuration might be found in Infinispan Integration Tests. The only difference is that Infinispan is deployed inside a WAR file and not put in the modules.

All you need to do is to put infinispan.xml inside WEB-INF directory and use proper beans.xml.

Another example using Modules and CDI might be found in JBoss Data Grid Quickstarts. The only missing bit from the example is JCache.

Finally, you might find be interested in JCache documentation paragraph from Infinispan User Guide.

Sebastian Łaskawiec
  • 2,667
  • 15
  • 33
  • Thanks a lot. I've got what I wanted with Ehcache finally, but I'll leave the question for one's reference. – dfche Dec 07 '17 at 10:15
  • Sorry we could not help you. If you could share your Ehcache based solution on Github or similar, we can inspect it and see how we can improve things in the future. How does that sound? – Galder Zamarreño Dec 07 '17 at 13:45
  • @GalderZamarreño thanks for answering, I'll make a generic ehcache usage case and post if for your reference ASAP. – dfche Dec 09 '17 at 11:51