[
https://issues.apache.org/jira/browse/ARIES-1455?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Mohammad Shamsi updated ARIES-1455:
-----------------------------------
Description:
Given following blueprint definition:
{code:xml}
<service interface="com.foo.MyDao">
<bean class="com.foo.impl.MyDaoImpl">
<tx:transaction method="*" value="Required"/>
</bean>
</service>
{code}
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")
{code:java}
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);
}
}
{code}
As a workaround I can change the blueprint definition to following:
{code:xml}
<bean id="myBean" class="com.foo.impl.MyDaoImpl">
<tx:transaction method="*" value="Required"/>
</bean>
<service interface="com.foo.MyDao">
<ref component-id="myBean" />
</service>
{code}
was:
Given following blueprint definition:
{code:xml}
<service interface="com.foo.MyDao">
<bean class="com.foo.impl.MyDaoImpl">
<tx:transaction method="*" value="Required"/>
</bean>
</service>
{code}
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")
{code:java}
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);
}
}
{code}
As a workaround I can change the blueprint definition to following:
{code:xml}
<bean id="myBean" class="com.foo.impl.MyDaoImpl">
<tx:transaction method="*" value="Required"/>
</bean>
<service interface="com.foo.MyDao">
<ref component-id="myBean" />
</service>
{code}
> JpaComponentProcessor is not scanning the nested beans inside service
> definition
> --------------------------------------------------------------------------------
>
> Key: ARIES-1455
> URL: https://issues.apache.org/jira/browse/ARIES-1455
> Project: Aries
> Issue Type: Bug
> Components: Blueprint, JPA
> Affects Versions: jpa-2.2.0
> Reporter: Mohammad Shamsi
>
> Given following blueprint definition:
> {code:xml}
> <service interface="com.foo.MyDao">
> <bean class="com.foo.impl.MyDaoImpl">
> <tx:transaction method="*" value="Required"/>
> </bean>
> </service>
> {code}
> 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")
> {code:java}
> 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);
> }
> }
> {code}
> As a workaround I can change the blueprint definition to following:
> {code:xml}
> <bean id="myBean" class="com.foo.impl.MyDaoImpl">
> <tx:transaction method="*" value="Required"/>
> </bean>
> <service interface="com.foo.MyDao">
> <ref component-id="myBean" />
> </service>
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)