As you said, the issue with DRM/ClusterPartition is that it's a circular dependency, making it a wee bit complex for dependency injection. That should be solvable by adding "whenRequired" attributes to the inject elements.
I.e in pseudo-xml in cluster-beans.xml:
<bean name="HAPartition" ...> <property name="distributedReplicantManager"><inject bean="DRM" whenRequired="Create"/></property> </bean> <bean name="DRM" ...> <property name="HAPartition"><inject bean="HAPartition" whenRequired="Instantiated"/></property> </bean>
The above example could be wrong; it's more there to give you the concept. Idea is you inject the DRM into the HAPartition just before it needs it in create(). You inject HAPartition into DRM early, since a DRM without an HAPartition is basically useless. The MC can analyze this situation and properly instantiate both objects.
The schema for beans.xml explains this stuff fairly well; it's in the Microcontainer source at https://svn.jboss.org//repos/jbossas/projects/microcontainer/trunk/kernel/src/resources/main/schema/bean-deployer_2_0.xsd . Valid values for "whenRequired" are the various states the MC moves a bean through as it deploys it:
I didn't have a chance to properly explore this last Nov when I was looking at this. If you have bandwidth to play with it a bit and try to get it sorted, that would be great. (Note I'm leaving on 2 week vacation in a few hours, so will not be in touch.)
Re: JBAS-3499, that's still really low priority. DRM works now, except for a couple JIRAs we need to track down. DRM is mission critical, and with all the stuff there is to do, I have a "if it ain't broke don't fix it" attitude toward making DRM use JBoss Cache.
I'll take a look at the circular dependency issue using "whenRequired." I won't pursue JBAS-3499; I only mentioned it in case that's what you had in mind as a prerequisite here.
Brian - I'm documenting my progress here as I'll be away on vacation when you return.
The required dependencies are as follows. The dependency states are reversed from your example.
<bean name="DistributedReplicantManager" ... <property name="HAPartition"><inject bean="HAPartition" state="Create"/></property> <depends>HAPartition</depends> </bean> <bean name="HAPartition" ... <property name="distributedReplicantManager"><inject bean="DistributedReplicantManager" state="Instantiated"/></property> </bean>
I've checked in the changes necessary to provide dependency injection and I've removed the logic that supported usage of ClusterPartition without DI of DRM (as it appears that was your intent).
This implementation differs from DI of DistributedState where DS was injected into ClusterPartitionConfig which was then passed into the ClusterPartition constructor. My implementation injects DRM directly into ClusterPartition as I couldn't resolve the circular dependencies between DRM and ClusterPartition when injecting into the Config object. I'm going to revisit this as I may have missed something when trying it earlier.
Just a follow up on what I did here.
DRM and DS are really just subcomponents of HAPartition. So, I changed them so they no longer expose create()/start()/stop()/deploy(). This means the microcontainer will no longer to manage a 4 stage lifecycle for them.
They now simply get injected into HAPartition. HAPartition manages their lifecycle, and injects itself into DRM.