Work on JBCACHE-13: Standalone Tomcat http session replicati
bstansberry Jun 20, 2005 2:01 AMFor the last few weeks I've been working on getting JBossCache-based session replication to work in standalone Tomcat 5.5. I've gotten a pretty reasonable version working, and want to post what I doing on this thread so others can be informed and provide any inputs they would like. (I've been discussing things with Ben Wang and earlier with Remy Maucherant).
Basically this task breaks down into two main elements -- getting a TreeCache deployed when Tomcat starts and getting JBossCacheManager instances deployed when distributable webapps are deployed.
To do this, I've:
1) Created a new implementation of the TC Cluster interface,
JBossCacheCluster. It's role is basically to:
a) Interact with the TC deployment system -- get config attributes from server.xml, implement the TC Lifecycle interface.
b) Instantiate a TreeCache and register it in JMX.
c) Instantiate and configure JBossCacheManager instances
when requested by the Tomcat deployer.
2) Created new class StandaloneJBossCacheManager, subclass of JBossCacheManager. I expect that with a bit of refactoring this subclass' functionality can be merged back into JBossCacheManager. Instances of this class can be created by JBossCacheCluster, or directly by TC's webapp deployer code. The latter happens if the user specifies a element in the context.xml the describes their webapp. This latter approach allows a user to set the replicationGranularity and replicationTrigger atttributes to something other than the cluster-wide defaults. In embedded JBoss/Tomcat these two attributes are set via jboss-web.xml.
Added functionality in StandaloneJBossCacheManager is basically:
a) Exposes a few property attributes so JBossCacheCluster or the TC deployer can set them without using the WebMetaData object used with embedded JBoss/Tomcat.
b) Handles the start()/stop() process differently, to account for the fact that it can't count on being configured by JBoss' TomcatDeployer. Key things it must do:
-- Detect if it was instantiated by the TC deployer rather than JBossCacheCluster. If it was, it finds the JBossCacheCluster and passes itself to it so the cluster can set cluster-wide properties (e.g. snapshot mode, useJK, etc).
-- Instantiate and install its ClusteredSessionValve.
I'll discuss some of the issues related to the above in separate posts.