[
https://issues.apache.org/jira/browse/OWB-1040?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14519397#comment-14519397
]
Reinhard Sandtner commented on OWB-1040:
----------------------------------------
your extension expects non-portable behavoir because it relies on the scanning
order of the beans.
in your extension you observe {code}cdiEventEndpoints(@Observes
ProcessInjectionPoint<?, CdiEventEndpoint<T>>){code} and store the
InjectionPoint from the event in a ConcurrentHashMap.
in {code}endpointProducers(@Observes ProcessBeanAttributes<T>){code} you read
the stored InjectionPoints an add the Qualifiers to the BeanAttributes and set
them into the event.
if the producer bean is scanned before the other beans, the Map with
InjectionPoints is still empty.
{quote}
For each enabled bean, the container must search the class for producer methods
and fields, as defined in Section 3.3, “Producer methods” and in Section 3.4,
“Producer fields”, including resources, and for each producer:
•
ifitisaproducermethod,fireaneventoftypeProcessInjectionPointforeachinjectionpoint
in the method parameters, as defined in Section 11.5.7, “ProcessInjectionPoint
event”, and then
• fire an event of type ProcessProducer, as defined in Section 11.5.11,
“ProcessProducer event”, and then
• if the producer method or field is enabled, fire an event of type
ProcessBeanAttributes, as defined in Section 11.5.9, “ProcessBeanAttributes
event”, and then
{quote}
in owb, the complete event-lifecycle is called for every bean. This is exactly
as defined in the specification
It might be that Weld uses a different order in which they fire events, but not
sure if this is backed by the spec
> Lifecycle events fired during bean discovery do not follow specification
> sequence
> ---------------------------------------------------------------------------------
>
> Key: OWB-1040
> URL: https://issues.apache.org/jira/browse/OWB-1040
> Project: OpenWebBeans
> Issue Type: Bug
> Components: Lifecycle
> Affects Versions: 1.5.0
> Reporter: Antonin Stefanutti
> Assignee: Reinhard Sandtner
> Priority: Critical
>
> The lifecycle events, like {{ProcessInjectionPoint}} and
> {{ProcessBeanAttributes}} are not fired according to the sequence specified
> in the [Bean
> discovery|http://docs.jboss.org/cdi/spec/1.2/cdi-spec.html#bean_discovery_steps]
> section of the specification.
> Besides, the {{BeanAttributes}} set with the {{ProcessBeanAttributes}} event
> are accessed directly which contradicts the [{{ProcessBeanAttributes}}
> event|http://docs.jboss.org/cdi/spec/1.2/cdi-spec.html#process_bean_attributes]
> specification:
> {quote}
> Any observer of this event is permitted to wrap and/or replace the
> BeanAttributes. The container must use the final value of this property,
> after all observers have been called, to manage instances of the bean.
> Changes to BeanAttributes are not propagated to the annotated type from which
> the bean definition was created.
> {quote}
> Failing test can be found here:
> https://github.com/astefanutti/camel-cdi/blob/a9e94607beaee546f76b7f6e70b9652bf8468d77/envs/se/src/test/java/org/apache/camel/cdi/se/EventEndpointTest.java
> The following exception is thrown when executed with OWB (not systematically
> though maybe due to multi-threading):
> {code}
> org.apache.webbeans.exception.WebBeansDeploymentException:
> javax.enterprise.inject.UnsatisfiedResolutionException: Api type
> [org.apache.camel.cdi.CdiEventEndpoint] is not found with the qualifiers
> Qualifiers: [@org.apache.camel.cdi.se.qualifier.BarQualifier()]
> for injection into Field Injection Point, field name :
> barQualifierCdiEventEndpoint, Bean Owner : [EventConsumingRoute,
> WebBeansType:MANAGED, Name:null, API
> Types:[org.apache.camel.builder.RouteBuilder,org.apache.camel.builder.BuilderSupport,org.apache.camel.cdi.se.bean.EventConsumingRoute,java.lang.Object,org.apache.camel.RoutesBuilder],
> Qualifiers:[javax.enterprise.inject.Any,javax.enterprise.inject.Default]]
> {code}
> This is not supposed to happen as the missing qualifiers are dynamically
> added in the Camel CDI extension here:
> https://github.com/astefanutti/camel-cdi/blob/a9e94607beaee546f76b7f6e70b9652bf8468d77/impl/src/main/java/org/apache/camel/cdi/CdiCamelExtension.java#L118.
> The problem is that OWB calls the observer methods in a different sequence
> than expected:
> {code}
> ProcessBeanAttributes<?>:class
> org.apache.camel.cdi.se.bean.EventProducingRoute
> ProcessBeanAttributes<?>:class
> org.apache.camel.cdi.se.EventEndpointTest$EventObserver
> ProcessBeanAttributes<?>:class org.apache.camel.cdi.CdiCamelFactory$1
> ProcessBeanAttributes<?>:class org.apache.camel.cdi.CdiEventComponent
> ProcessBeanAttributes<?>:class
> org.apache.camel.cdi.se.bean.EventConsumingRoute
> ProcessBeanAttributes<?>:class org.apache.camel.cdi.se.EventEndpointTest
> ProcessBeanAttributes<?>:class org.apache.camel.cdi.CdiCamelFactory
> ProcessBeanAttributes<?>:interface org.apache.camel.Endpoint
> ProcessBeanAttributes<T>:interface org.apache.camel.Endpoint
> BeanAttributes.getQualifiers()
> ProcessBeanAttributes<?>:class org.apache.camel.component.mock.MockEndpoint
> ProcessBeanAttributes<T>:class org.apache.camel.component.mock.MockEndpoint
> BeanAttributes.getQualifiers()
> ProcessBeanAttributes<?>:class org.apache.camel.component.mock.MockEndpoint
> ProcessBeanAttributes<T>:class org.apache.camel.component.mock.MockEndpoint
> BeanAttributes.getQualifiers()
> ProcessBeanAttributes<?>:class org.apache.camel.component.mock.MockEndpoint
> ProcessBeanAttributes<T>:class org.apache.camel.component.mock.MockEndpoint
> BeanAttributes.getQualifiers()
> ProcessBeanAttributes<?>:interface org.apache.camel.TypeConverter
> ProcessBeanAttributes<?>:CdiEventEndpoint<T extends class java.lang.Object>
> ProcessBeanAttributes<T>:CdiEventEndpoint<T extends class java.lang.Object>
> BeanAttributes.getQualifiers()
> ProcessBeanAttributes<?>:interface org.apache.camel.ProducerTemplate
> BeanAttributes.getQualifiers()
> ProcessInjectionPoint<?>:class
> org.apache.camel.cdi.se.bean.EventProducingRoute
> ProcessInjectionPoint<?>:class
> org.apache.camel.cdi.se.bean.EventProducingRoute
> ProcessInjectionPoint<?>:class
> org.apache.camel.cdi.se.bean.EventProducingRoute
> ProcessInjectionPoint<?>:class
> org.apache.camel.cdi.se.bean.EventProducingRoute
> ProcessInjectionPoint<?>:class
> org.apache.camel.cdi.se.bean.EventProducingRoute
> ProcessInjectionPoint<?>:class
> org.apache.camel.cdi.se.bean.EventProducingRoute
> ProcessInjectionPoint<?>:class
> org.apache.camel.cdi.se.bean.EventConsumingRoute
> ProcessInjectionPoint<?>:class
> org.apache.camel.cdi.se.bean.EventConsumingRoute
> ProcessInjectionPoint<?>:class
> org.apache.camel.cdi.se.bean.EventConsumingRoute
> ProcessInjectionPoint<?>:class
> org.apache.camel.cdi.se.bean.EventConsumingRoute
> ProcessInjectionPoint<?>:class
> org.apache.camel.cdi.se.bean.EventConsumingRoute
> ProcessInjectionPoint<?>:class
> org.apache.camel.cdi.se.bean.EventConsumingRoute
> {code}
> For example, the sequence for the {{EventProducingRoute}} bean is:
> {code}
> ProcessBeanAttributes<?>:class
> org.apache.camel.cdi.se.bean.EventProducingRoute
> ProcessInjectionPoint<?>:class
> org.apache.camel.cdi.se.bean.EventProducingRoute
> ProcessInjectionPoint<?>:class
> org.apache.camel.cdi.se.bean.EventProducingRoute
> ProcessInjectionPoint<?>:class
> org.apache.camel.cdi.se.bean.EventProducingRoute
> ProcessInjectionPoint<?>:class
> org.apache.camel.cdi.se.bean.EventProducingRoute
> ProcessInjectionPoint<?>:class
> org.apache.camel.cdi.se.bean.EventProducingRoute
> ProcessInjectionPoint<?>:class
> org.apache.camel.cdi.se.bean.EventProducingRoute
> {code}
> While from the specification, the {{ProcessInjectionPoint}} event must be
> fired before the {{ProcessBeanAttributes}}. Note that this sequence differs
> from one run to another.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)