0

Long story short, I have created a library that is using Apache JCS to manage its own objects. using

CompositeCacheManager ccm CompositeCacheManager.getUnconfiguredInstance();
Properties props = new Properties();
props.load(fis);

ccm.configure(props);

CompositeCache<Serializable, Serializable> cache = ccm.getCache(CACHE_NAME);

Above, it reads configuration from a file and loads to cache manager and everything works well when testing library with a test application.

But in my real application, I am using JCS too to manage application related objects and that is where the problem occurs.

When the application is booting up, it first instantiates application cache manager and it successfully loads all the configurations and create exactly what I intended.

But for the library's Cache Manager, it does not use my configurations at all and sounds it instantiates some default Cache instance. For example in my library's configuration I have:

jcs.region.MYREGION=DCACHE
jcs.region.MYREGION.cacheattributes=org.apache.commons.jcs.engine.CompositeCacheAttributes
jcs.region.MYREGION.cacheattributes.MaxObjects=1200
jcs.region.MYREGION.cacheattributes.MemoryCacheName=org.apache.commons.jcs.engine.memory.lru.LRUMemoryCache
jcs.region.MYREGION.cacheattributes.DiskUsagePattern=UPDATE

The DCHACHE auxiliary is defined as:

jcs.auxiliary.DCACHE=org.apache.commons.jcs.auxiliary.disk.indexed.IndexedDiskCacheFactory
jcs.auxiliary.DCACHE.attributes=org.apache.commons.jcs.auxiliary.disk.indexed.IndexedDiskCacheAttributes
jcs.auxiliary.DCACHE.attributes.DiskPath=LIB_DATA_DIR
jcs.auxiliary.DCACHE.attributes.MaxPurgatorySize=10000
jcs.auxiliary.DCACHE.attributes.MaxKeySize=10000
jcs.auxiliary.DCACHE.attributes.OptimizeAtRemoveCount=300000
jcs.auxiliary.DCACHE.attributes.MaxRecycleBinSize=7500

The evidences that show it is not using the relevant configurations are: It creates MYREGION's DiskUsagePattern with SWAP (I also tried DiskUsagePatternName but does not make any differences).

It does not use LIB_DATA_DIR as DisckPath. Instead uses the one I already defined for Application's configuration.

If I comment the the application's JCS related codes, the it works well for the library's JCS.

I also tried JCS.getInstance("cache_name") but it makes no differences.

Do you guys have any idea?

madz
  • 1,803
  • 18
  • 45

1 Answers1

0

After couple of hours digging into the problem figured that JCS having hard time dealing with separated configuration files. It sounds JCS can be configured only once using config file per java virtual machine.

So I ended up with using one file to configure JCS. This way if the application instantiates JCS firs, it loads library's configurations too and later inside library everything works well.

madz
  • 1,803
  • 18
  • 45