fromContext dependency regression
adrian.brock Apr 18, 2008 10:21 AMI'm seeing a horrible regression in the fromContext dependency injection.
e.g. this config from the system-jmx tests in the appserver
<?xml version="1.0" encoding="UTF-8"?>
<deployment xmlns="urn:jboss:bean-deployer:2.0">
 <!-- The legacy JMX kernel -->
 <bean name="ServiceControllerLocator" class="org.jboss.test.system.controller.integration.support.ServiceControllerLocator" />
 <bean name="ServiceLifecycle" class="org.jboss.test.system.controller.integration.support.TestServiceControllerLifecycleCallback">
 <property name="mbeanServer">
 <inject bean="ServiceControllerLocator" property="mbeanServer"/>
 </property>
 <property name="serviceController">
 <inject bean="ServiceControllerLocator" property="serviceController"/>
 </property>
 </bean>
 <bean name="TransactionManager" class="org.jboss.test.system.controller.integration.support.MockTransactionManager">
 <annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss:service=TransactionManager", exposedInterface=org.jboss.test.system.controller.integration.support.MockTransactionManagerMBean.class, registerDirectly=true)</annotation>
 <property name="transactionTimeout">300</property>
 <property name="objectStoreDir">${jboss.server.data.dir}/tx-object-store</property>
 <install bean="ServiceLifecycle" method="install">
 <parameter><inject fromContext="context"/></parameter>
 </install>
 <uninstall bean="ServiceLifecycle" method="uninstall">
 <parameter><inject fromContext="context"/></parameter>
 </uninstall>
 </bean>
</deployment>
is causing a circular dependency of the bean on itself.
AbstractDependencyItem@e59e40{name=TransactionManager dependsOn=TransactionManager whenRequired=Installed dependentState=Installed resolved=false}
Each FromContext enumeration value should have an associated state
when it becomes valid. Most will be PreInstall, but some like BeanInfo
will Instantiated.
Something like:
public enum FromContext
{
 ...
 BEANINFO(FromContextDelegate.BEANINFO, ControllerState.INSTANTIATED),
With the second value used to determine the dependent state.
 
    