Have a look at http://jira.jboss.com/jira/browse/JBMICROCONT-192 and related forum thread http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4063443.
The way the MC feature has developed, there should be no need to implement a special interface. Instead you can mark any method for kernel name injection, either via annotation or -beans.xml.
I think it should be fine to just mark setServiceHAName().
OK - I'll use setServiceHAName(). It looks like the Microcontainer version in thirdparty doesn't have this support yet so I'll revisit this later in the week.
I read some of the discussions on this subject in the Microcontainer Forum; it seems that the bean name will be accessible via annotation (unclear whether the work is done yet). I'll use an annotation in HAServiceMBeanSupport if available since this will make the name available in the base class without clients having to modify XML configurations for their services to include the name-method attribute.
Just to document what I found -
The original discussion of JBMICROCONT-192 suggested that a "name-method" attribute would be used to expose the bean name. It appears that this was either not implemented or was rolled back. The bean name is available using "inject fromContext".
For example, adding the following to the HASingletonDeployer bean will cause the bean name to be injected into serviceHAName.
<property name="serviceHAName"><inject fromContext="name"/></property>
It looks like the version of jboss-kernel.jar containing this support hasn't been updated in the repository yet. I built the jar from latest microcontainer source and confirmed that this technique works for HAServiceMBeanSupport.
Once the jar is available, I'll modify deploy-hasingleton-beans.xml to use this capability. If annotation support subsequently becomes available, I'll revisit the issue as it might be preferable to handle this in the base class rather than in the configuration.
Now that the required version of the microcontainer is available, I can complete this issue. One question here - JBAS-4543 suggests that the service's ObjectName should be used first and the bean name should only be used as an alternative. Is this actually the case or should the bean name be preferred?
For HAServiceMBeanSupport, the canonical name of the service is "jboss.ha:service=HASingletonDeployer" while the bean name is "HASingletonDeployer".
Note that I can't use setServiceHAName() unless we want to use the bean name since this name would be set on initialization and we wouldn't retrieve the canonical name. Of course it would be trivial to add another getter/setter to the class to accommodate the bean name.
Let's give preference to the kernel (bean) name. Another tiny step in getting JMX out of the middle of everything. :)
What would happen if you annotate setServiceHAName and then set it to something other than the kernel via xml? Will the xml value win out? If yes, you can annotate setServiceHAName. If not we need to create another property and annotate that.
The XML value will win out. I've annotated setServiceHAName() and it works as expected. I've committed the changes and closed the issue.
Great! Thanks :)