How to avoid canonical conversion of AbstractInjectionValueMetaData's value?
jaikiran Apr 8, 2010 1:21 PMI have got a piece of code which deploys a MC bean into the kernel: {code:java} String beanName = "abc"; BeanMetaDataBuilder builder = BeanMetaDataBuilderFactory.createBuilder(beanName, MyClass.class.getName()); String constructorParamMCBeanName = "jboss.domain:m=xyz,c=pqr" builder.addConstructorParameter(SomeClass.class.getName(), new AbstractInjectionValueMetaData(constructorParamMCBeanName)); {code} So effectively, it's creating a MC bean for MyClass which accepts an instance of SomeClass as its constructor param: {code:java} public class MyClass { public MyClass(SomeClass param) { ... } } {code} The SomeClass instance which itself is a MC bean with MC bean name "jboss.domain:m=xyz,c=pqr" gets deployed by some other piece of code. This is simple enough and should have worked. But it doesn't. When the "abc" MC bean is installed, it runs into: {code:java} DEPLOYMENTS MISSING DEPENDENCIES: Deployment "abc" is missing the following dependencies: Dependency "jboss.domain:c=pqr,m=xyz" (should be in state "Installed", but is actually in state "** NOT FOUND Depends on 'jboss.domain:c=pqr,m=xyz' **") {code} Notice that the (injection) dependency MC bean name has been converted to a canonical name. Shouldn't have happened. But looking at the constructor of AbstractInjectionValueMetaData, a call to new AbstractInjectionValueMetaData(constructorParamMCBeanName), leads to: {code:java} public AbstractValueMetaData(Object value) { setValue(value); } public void setValue(Object value) { Object jmxHack = null; if (isUseJMXObjectNameFix()) jmxHack = JMXObjectNameFix.needsAnAlias(value); if (jmxHack != null) this.value = jmxHack; else this.value = value; flushJBossObjectCache(); } /** * Do we use jmx object name fix. * * @return do we use jmx object name fix */ protected boolean isUseJMXObjectNameFix() { return true; } {code} The isUseJMXObjectNameFix always returns true and then JMXObjectNameFix.needsAnAlias(value) converts the MC bean name to its canonical form. I see no way to prevent this from happening (other than create a subclass - which is a bit too much to do for this simple usecase). Am I missing something? Or is there some other way to get around this?