2 Replies Latest reply on Nov 4, 2008 10:25 AM by Carlo de Wolf

    TransactionManagerLocator has instance before TM is ready

    Carlo de Wolf Master

      https://jira.jboss.org/jira/browse/JBAS-6028

      The TransactionManagerLocator.getInstance() should return a MC bean which depends on the real transaction manager.

        • 1. Re: TransactionManagerLocator has instance before TM is read
          Adrian Brock Master

          No. If you want to do that, i.e. a real dependency, don't use the TransactionManagerLocator.

          You should inject it directly, see jca-jboss-beans.xml:

           <!-- The transaction manager -->
           <property name="transactionManager"><inject bean="TransactionManager" property="transactionManager"/></property>
          


          If you wanted to further an just use the anonymous inject, i.e.

          @Inject // No name implies match the interface to the only implementation
          public void setTransactionManager(TransactionManager tm);
          
          or xml equivalent
          
           <property name="transactionManager"><inject/></property>
          
          


          Then we'd need to make MC aware of the instance in transaction-jboss-beans.xml

          <bean name="RealTransactionManager">
           <constructor factoryMethod="getTransactionManager">
           <factory bean="TransactionManager"/>
           </constructor>
          </bean>
          


          Since the thing called TransactionManager is not really a TM, its a factory for it. :-)

          • 2. Re: TransactionManagerLocator has instance before TM is read
            Carlo de Wolf Master

            Bugger, can't get static instances past you. ;-)

            I'm going for the anonymous inject.