5 Replies Latest reply on Apr 7, 2008 10:08 AM by alesj

    BeanFactory and IoC annotations support

    alesj

      Currently we don't do anything with MC IoC annotations on beans that are created by bean factory (e.g. GenericBeanFactory).

      Handling them in createBean method is too late, since we loose the notion of dependencies, e.g. @Inject(bean="somebean") at that moment we can only do lookup and fail if 'somebean' is not installed, loosing what MC's state machine is all about.

      We could move annotations lookup in create() and set the dependencies whenRequired state to INSTALLED.
      But this will again only work if bean attribute is explicitly defined.
      In the case when bean is created through ConstructorMetaData.factory, there is nothing we can do to avoid problems previously mentioned - no true dependencies.

      Which road to take?

        • 1. Re: BeanFactory and IoC annotations support

          Related classes (see the JIRA issue)
          http://jira.jboss.com/jira/browse/JBMICROCONT-22.

          i.e. When I deploy my factory or some other container,
          I also want the dependencies on a given class resolved before the factory is deployed.

          <bean name="MainClass" class="com.acme.Main">
           <related>com.acme.Related</related>
          </bean>
          


          This was initially raised for AOP where we need to know that com.acme.Main
          instantiates a com.acme.Related programmatically and that Related has aspects
          whose dependencies need to be satisifed before we deploy/invoke on Main.


          • 2. Re: BeanFactory and IoC annotations support

            For the simple BeanFactory case (i.e. no factory injection in its constructor),
            we can add the "bean class" as a related class automatically to the
            GenericBeanFactoryMetaData

            • 3. Re: BeanFactory and IoC annotations support

               

              "adrian@jboss.org" wrote:

              This was initially raised for AOP where we need to know that com.acme.Main
              instantiates a com.acme.Related programmatically and that Related has aspects
              whose dependencies need to be satisifed before we deploy/invoke on Main.


              So its not just annotation defined depdencies, we also need to ask
              aop to give its dependencies for that class.

              • 4. Re: BeanFactory and IoC annotations support
                alesj

                 

                "adrian@jboss.org" wrote:
                For the simple BeanFactory case (i.e. no factory injection in its constructor),
                we can add the "bean class" as a related class automatically to the
                GenericBeanFactoryMetaData

                OK, this needs to be done. :-)
                Since if Scott wants to use our beanfactory as a way to create/pool beans, this is a must to have.
                e.g. applying @EJB on enterprise beans

                I can have a hack at that, unless Kabir wants to resolve this task personally. ;-)
                But I would need some instructions, since it's out of the scope of my simple IoC annotations handling.

                • 5. Re: BeanFactory and IoC annotations support
                  alesj

                   

                  "adrian@jboss.org" wrote:

                  i.e. When I deploy my factory or some other container,
                  I also want the dependencies on a given class resolved before the factory is deployed.

                  <bean name="MainClass" class="com.acme.Main">
                   <related>com.acme.Related</related>
                  </bean>
                  


                  This was initially raised for AOP where we need to know that com.acme.Main
                  instantiates a com.acme.Related programmatically and that Related has aspects
                  whose dependencies need to be satisfied before we deploy/invoke on Main.

                  Should I then add a Set<String> related to BeanMetaData?

                  How to generically handle this related?
                  e.g. beanfactory's related bean should be scanned for MC's IoC annotations, but when there is related item for non-beanfactory we shouldn't scan for IoC, it should only be used for AOP dependencies