Would appreciate some advice on the best way to accomplish the following requirement.
We are using JBoss Cache 1.4.1 SP9. We have an EAR file with one Web module (WAR). We deploy this application on both WebSphere and JBoss. So we include the JBoss Cache JAR file inside the WAR's WEB-INF/lib directory. In the case of WebSphere we also include the JBoss Cache dependencies (jboss-common.jar, etc). We set the class loader order so the Web module class loader is first. Our TreeCache configuration file is deployed to a folder outside the deployed app and this folder is added to the server's classpath using a vendor-specific mechanism.
The end result is exactly one cache instance per application instance. The cache instances are configured to communicate with each other using REPL_SYNC.
We are coming out with a new version of the app which includes multiple Web modules (WARs) in the same EAR. All the Web modules need the same cache contents. If we retain the existing architecture this will multiply the number of cache instances. This is undesirable because (a) each cache instance will require memory, (b) all cache instances need to stay in sync, multiplying the network traffic, (c) each cache instance will need its own configuration file, especially for TCP-based replication.
What we want is a way to instantiate one cache instance for the entire JVM and register it so it can be accessed by JNDI or JMX. Then each Web module can just lookup the cache. This must work on both WebSphere and JBoss (and in the future WebLogic).
We would strip all JBoss JARs from the WAR/EAR and deploy them to the server. Then the server would need to be instructed to create a cache instance as the server comes up and register it. We would have lookup code to get a handle on the cache instance when the Web module(s) came up. We would also upgrade to JBoss Cache 3.x at the same time so we didn't have to deal with conflicts in JBoss system libraries and the versions embedded in the app server (javax.management classes for example).
I think it is fairly easy on JBoss AS. There are instructions for deploying a cache instance to JMX. This should create one instance per node.
However, I am not sure if this is recommended on other app servers. We are thinking we can use the WAS Extended MBean Provider feature, http://publib.boulder.ibm.com/infocenter/wasinfo/v6r1/index.jsp?topic=/com.ibm.websphere.nd.multiplatform.doc/info/ae/ae/uagt_mbeanprovider.html.
Any advice on whether this is recommended or any tips to get it going? I would be happy to write up a Wiki article if we do get it working on WebSphere. The current Wiki articles on the topic on the JBoss Cache community site aren't very comprehensive.