1 Reply Latest reply on Apr 19, 2008 7:20 PM by Ales Justin

    fromContext dependency regression

    Adrian Brock Master

      I'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.

        • 1. Re: fromContext dependency regression
          Ales Justin Master

           

          "adrian@jboss.org" wrote:

          Each FromContext enumeration value should have an associated state
          when it becomes valid. Most will be PreInstall, but some like BeanInfo
          will Instantiated.

          Fixed.

          And I also removed pre-configured dependentState==INSTALLED in AbstractDependencyValueMetaData.
          With different usages of Injection/DependencyValueMetaData,
          only null can tell us that the user didn't set this,
          so we apply defaults for different usages, e.g. for FromContext we take its getWhenValid.