I would have to upgrade from 4.0.4 to 4.2 as well, hopefully thats not too painful (-:}
Best thing to do is to have a look at the 4.2 codebase, cluster module, package org.jboss.ha.singleton. HASingletonElectionPolicy is the interface; HASingletonElectionPolicySimple is the default implementation.
What you do is you deploy your policy as an mbean. Your policy can take whatever config attributes you want; just expose them in the mbean interface. Then in the mbean descriptor for the HASingletonController you inject the policy. E.g.:
<server> <!-- First the service being controlled --> <mbean code="org.jboss.ha.singleton.examples.HASingletonMBeanExample" name="jboss.examples:service=HASingletonMBeanExample_1"> </mbean> <mbean code="org.jboss.ha.singleton.PreferredMasterHASingletonElectionPolicy" name="jboss.examples:service=HASingletonMBeanExample-HASingletonElectionPolicy_1"> <attribute name="PreferredServer">foo:1099</attribute> </mbean> <mbean code="org.jboss.ha.singleton.HASingletonController" name="jboss.examples:service=HASingletonMBeanExample-HASingletonController_1"> <depends optional-attribute-name="ClusterPartition" proxy-type="attribute">jboss:service=DefaultPartition</depends> <depends>jboss.examples:service=HASingletonMBeanExample_1</depends> <depends optional-attribute-name="ElectionPolicy" proxy-type="attribute">jboss.examples:service=HASingletonMBeanExample-HASingletonElectionPolicy_1</depends> <attribute name="TargetName">jboss.examples:service=HASingletonMBeanExample_1</attribute> <attribute name="TargetStartMethod">startSingleton</attribute> <attribute name="TargetStopMethod">stopSingleton</attribute> <attribute name="TargetStopMethodArgument">true</attribute> </mbean> </server>