In the case of the file cache store, you can do:
Configuration builder = new ConfigurationBuilder() FileCacheStoreConfigurationBuilder fcscb = builder.loaders().addFileCacheStore();
And use the file cache store config builder to set the config options you want.
With any other cache store, addCacheLoader() returns a LoaderConfigurationBuilder which you use to pass in the configuration options as before.
I'm facing a similar question, but my cache loader is not related with the FileCacheLoader. My problem is that I would like to instantiate a CacheLoader which requires some initialization parameters.
I thought I could instantiate my CacheLoader myself and pass it to the configuration builder doing something like this:
MyCacheLoader cacheLoader = new MyCacheLoader( ... );
Configuration configuration = new ConfigurationBuilder()
Unfortunately it seems that infinispan actually tries to instantiates itself the CacheLoader even though an instance is provided (which in my case fails as the required constructor isn't there).
I could pass necessary informations via a CacheLoaderConfig subclass, but I fail to see how I can instantiate a CacheLoader based on this with the new API.
Could someone shed some light on this ? Maybe there's a trick using the "addFileCacheStore()" but I don't see which one.
Thanks in advance.
For any other cache loader, until we sort out the new config for it, you have to do something like this:
Properties loaderProps = new Properties(); // For each property to configure, set it here - just like you do with XML loaderProps.setProperty("remoteCallTimeout", replTimeout.toString); builder.loaders().addCacheLoader().cacheLoader(new ClusterCacheLoader()) .withProperties(loaderProps);
The cache loader instance passed is only used to determine the type of cache loader. Infinispan internals will generate a new instance out of it. So, no point in setting anything there. This is already explained in the cacheLoader() method javadoc.
Thanks I actually came across the functions that allow setting properties, which I though would be good enought for my use case. Trying it though caused and issue, it complains that setters aren't found on the AbstractCacheLoader class whereas I'm trying to assign value to properties of my own class.
I get the following exception:
Caused by: org.infinispan.config.ConfigurationException: Couldn't find a setter named [setWrappedClassName] which takes a single parameter, for parameter wrappedClassName on class [class org.infinispan.loaders.AbstractCacheStoreConfig]
Looking at the code in LegacyConfigurationAdaptor, it seems that when entering the "setValues" method of "XmlConfigHelper", the target object is seen as an AbstractCacheLoaderConfig, which is surprising since the CacheLoader I pass in configuration overrides the "getConfigurationClass" to point to my own configuration file (public inner class of MyCacheLoader).
Not sure why I see that AbstractCacheLoaderConfig instead of my own class.
Can you attach a test case (zipped) so that we can have a look?