Uploaded image for project: 'Aries'
  1. Aries
  2. ARIES-1455

JpaComponentProcessor is not scanning the nested beans inside service definition

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • jpa-2.2.0
    • jpa-2.3.0
    • Blueprint, JPA
    • None

    Description

      Given following blueprint definition:

      <service interface="com.foo.MyDao">
              <bean class="com.foo.impl.MyDaoImpl">
                  <tx:transaction method="*" value="Required"/>
              </bean>
      </service>
      

      MyDaoImpl has a property of type EntityManager annotated with PersistenceUnit but "JpaComponentProcessor" is not able to properly scan the nested bean inside above service definition to find the annotated property.

      looking at JpaComponentProcessor source, following code snippet, one can see it
      is checking if component definition is an instance of "MutableBeanMetadata" which is not the case when the bean definition is nested in service definition (it is an instance of "MutableServiceMetadata")

      Set<String> components = new HashSet<String(cdr.getComponentDefinitionNames());
      for (String component : components) {
           ComponentMetadata compDef = cdr.getComponentDefinition(component);
           if (compDef instanceof MutableBeanMetadata && !((MutableBeanMetadata)compDef).isProcessor()) {
                      handleComponent((MutableBeanMetadata)compDef, bundle, cdr, container);
           }
      }
      

      As a workaround I can change the blueprint definition to following:

      <bean id="myBean" class="com.foo.impl.MyDaoImpl">
           <tx:transaction method="*" value="Required"/>
      </bean>
      <service interface="com.foo.MyDao">
          <ref component-id="myBean" />
      </service>
      

      Attachments

        Activity

          People

            cschneider Christian Schneider
            m.h.shams@gmail.com Mohammad Shamsi
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: