[
https://issues.apache.org/jira/browse/ARIES-1481?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15094926#comment-15094926
]
Sam Wright commented on ARIES-1481:
-----------------------------------
I've played around with blueprint and here are the possible scenarios, using
class B which extends class A, and class Foo to be injected using:
{code}
<bean class="example.B" id="b" ext:field-injection="true">
<property name="foo" ref="foo"/>
</bean>
<bean class="example.Foo", id="foo"/>
{code}
- If there is an A.foo field and a B.foo field, blueprint throws
{{org.osgi.service.blueprint.container.ComponentDefinitionException: Unable to
find property descriptor foo on class example.B}}.
- If there is an A.foo field only, blueprint creates the {{b}} bean
successfully.
- If there is another injectable class e.g. Foo2 such that A.foo is of type
Foo, and B.foo is of type Foo2, blueprint throws the same exception
{{org.osgi.service.blueprint.container.ComponentDefinitionException: Unable to
find property descriptor foo on class example.B}} using the following xml file:
{code}
<bean class="example.B" id="b" ext:field-injection="true">
<property name="foo" ref="foo"/>
<property name="foo" ref="foo2"/>
</bean>
{code}
So, {{FieldUtil}} should throw an exception if the same field name is used
twice throughout the class hierarchy, in order to match what blueprint would
do. I have implemented it and will push to github now.
> blueprint-maven-plugin: fix detection of inherited
> @OsgiService/@PersistenceContext/Unit-annotated fields
> ---------------------------------------------------------------------------------------------------------
>
> Key: ARIES-1481
> URL: https://issues.apache.org/jira/browse/ARIES-1481
> Project: Aries
> Issue Type: Bug
> Components: Blueprint
> Reporter: Sam Wright
> Assignee: Christian Schneider
> Fix For: blueprint-maven-plugin-1.4.0
>
>
> Fields inherited from parent classes annotated with @Inject are properly
> detected by blueprint-maven-plugin, but the presence of @OsgiService,
> @PersistenceContext, and @PersistenceUnit annotations on fields declared in
> parent classes is ignored.
> This is because @Inject-annotated fields are found in the
> Bean.resolve(Matcher) method which recursively searches all parent classes
> for declared fields, whereas @PersistenceContext/Unit-annotated fields are
> discovered in Bean.getPersistenceFields() by simply using the fields declared
> in the bean class. Similarly, @OsgiService-annotated fields are discovered in
> Context.addServiceRefs(Class) by looking through the fields declared in the
> bean class.
> This commit extracts the field-getting algorithm used for finding
> @Inject fields to a utility method which is used for finding fields for the
> other
> annotations.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)