I've succeeded in creating a replicated cache as follows:
// Java source:
GlobalConfigurationBuilder global = GlobalConfigurationBuilder.defaultClusteredBuilder();
global.transport().addProperty("configurationFile", "jgroups-tcp.xml").build();
builder.clustering().cacheMode(CacheMode.REPL_SYNC);
cacheManager = new DefaultCacheManager(global.build(), builder.build());
icache = cacheManager.getCache();
// XML for jgroups-tcp.xml
(Based on Infinispan default-configs/default-jgroups-tcp.xml: https://github.com/infinispan/infinispan/blob/master/core/src/main/resources/default-configs/default-jgroups-tcp.xml )
Now I want to wrap this using JCache so my application is only interfacing with the JCache API.
My current JCache code is as follows:
CachingProvider infinispan = Caching.getCachingProvider("org.infinispan.jcache.embedded.JCachingProvider");
MutableConfiguration<Long, Person> config = return new MutableConfiguration<Long, Person>()
.setTypes(k, v).setStoreByValue(true)
.setExpiryPolicyFactory(CreatedExpiryPolicy.factoryOf(Duration.ETERNAL));
Cache<Long,Person> jcache = infinispan.getCacheManager().createCache("people", config);
How can I go about wrapping my replicated cache in a JCache version?
CachingProvider has the possibility of creating a CacheManager from Infinispan configuration XML. See documentation.