[
https://issues.apache.org/jira/browse/OWB-1099?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15058543#comment-15058543
]
Antonin Stefanutti edited comment on OWB-1099 at 12/15/15 7:01 PM:
-------------------------------------------------------------------
[~struberg] Sorry for the late reply, I didn't get any notification.
The need arises when you customise an {{InjectionTarget}} or a {{Producer}} and
you need to access the corresponding bean attributes like the qualifiers within
them. At the moment you set the {{InjectionTarget}} (resp. the {{Producer}}) in
the {{ProcessInjectionTarget}} (resp. in the {{ProcessProducer}}), the bean
attributes are not accessible nor final as the {{ProcessBeanAttributes}} event
is fired after.
So, the pattern I've seen and used in that use case is to store a mapping of
Annotated to Bean.
Here is an example in the Camel CDI extension:
https://github.com/astefanutti/camel-cdi/blob/cc3f15f68513eabaa6c0312caa6bd469bd56e477/impl/src/main/java/org/apache/camel/cdi/CdiCamelExtension.java#L94
It works with Weld. To make it works with OpenWebBeans, I had to wrap the
annotated:
https://github.com/astefanutti/camel-cdi/blob/cc3f15f68513eabaa6c0312caa6bd469bd56e477/impl/src/main/java/org/apache/camel/cdi/CdiCamelExtension.java#L194
I'm convinced the use case make sense, though there may be a better pattern.
was (Author: antonin.stefanutti):
[~struberg] Sorry for the late reply, I didn't get any notification.
The need arises when you customise an {{InjectionTarget}} or a {{Producer}} and
you need to access the corresponding bean attributes like the qualifiers within
them. At the moment you set the {{InjectionTarget}} (resp. the {{Producer}}) in
the {{ProcessInjectionTarget}} (resp. in the {{ProcessProducer}}), the bean
attributes are not accessible nor final as the {{ProcessBeanAttributes}} event
is fired after.
So, the pattern I've seen and used in that use case is to store a mapping of
Annotated to Bean.
Here is an example in the Camel CDI extension:
https://github.com/astefanutti/camel-cdi/blob/cc3f15f68513eabaa6c0312caa6bd469bd56e477/impl/src/main/java/org/apache/camel/cdi/CdiCamelExtension.java#L94
I'm convinced the use case make sense, though there may be a better pattern.
> Annotated SPI implementations do not override equals and hashCode
> -----------------------------------------------------------------
>
> Key: OWB-1099
> URL: https://issues.apache.org/jira/browse/OWB-1099
> Project: OpenWebBeans
> Issue Type: Bug
> Affects Versions: 1.6.2
> Reporter: Antonin Stefanutti
> Assignee: Mark Struberg
>
> The implementations of the {{Annotated}} SPIs do not override {{equals}} and
> {{hashCode}}.
> This prevents from looking up bean definitions by annotated elements which is
> often required when developing CDI extensions.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)