dev@javaserverfaces.java.net

Re: Please help: CDI definition failure:WELD-000409: Observer method for container lifecycle event

From: arjan tijms <arjan.tijms_at_gmail.com>
Date: Tue, 15 Sep 2015 18:18:34 +0200

Hi,

On Tue, Sep 15, 2015 at 5:08 PM, Edward Burns <edward.burns_at_oracle.com> wrote:
>>>>>> On Fri, 11 Sep 2015 23:14:13 +0200, arjan tijms <arjan.tijms_at_gmail.com> said:
> Any reply on this? I'm keen to put it in because without it we can't
> use 8u60.

Hmmm, I replied yesterday (18 hours ago according to my mail client).
Maybe the message didn't make it to the list? I did get a "your
message is waiting for approval" or something reply.

The important bit of my previous reply was this:

"I already had nearly the same change queued locally, but was waiting
for review of a couple of other commits to the same file (for which
the change bundles have to be created serialised because of changes to
the same file).

Anyway, the change itself is okay. One thing is that checking Optional
for null is not needed. The method never returns null (although JDK8
best practices still have to be firmly established, I believe that
returning null for an Optional is rather bad practice)."

Kind regards,
Arjan Tijms








>
> Thanks,
>
> Ed
>
> --
> | edward.burns_at_oracle.com | office: +1 407 458 0017
> | 37 Business days til JavaOne 2015
> | 52 Business days til DOAG 2015
>
>
> Don't use lambda in processBean() since Weld doesn't like it.
>
> SECTION: Modified Files
> ----------------------------
> M jsf-ri/src/main/java/com/sun/faces/cdi/CdiExtension.java
>
>
> SECTION: Diffs
> ----------------------------
> Index: jsf-ri/src/main/java/com/sun/faces/cdi/CdiExtension.java
> ===================================================================
> --- jsf-ri/src/main/java/com/sun/faces/cdi/CdiExtension.java (revision 15195)
> +++ jsf-ri/src/main/java/com/sun/faces/cdi/CdiExtension.java (working copy)
> @@ -47,6 +47,7 @@
> import java.util.LinkedHashMap;
> import java.util.List;
> import java.util.Map;
> +import java.util.Optional;
>
> import javax.enterprise.event.Observes;
> import javax.enterprise.inject.spi.AfterBeanDiscovery;
> @@ -105,17 +106,13 @@
> @SuppressWarnings("unchecked")
> public <T extends DataModel<?>> void processBean(@Observes ProcessBean<T> event, BeanManager beanManager) {
>
> - // Collect all classes annotated by @FacesDataModel in a Map
> - // Key: (collection) class that a DataModel implementations wraps
> - // Value: the DataModel implementation class
> -
> - getAnnotation(beanManager, event.getAnnotated(), FacesDataModel.class)
> - .ifPresent(d ->
> - forClassToDataModelClass.put(
> - d.forClass(),
> - (Class<? extends DataModel<?>>) event.getBean().getBeanClass()
> - )
> - );
> + Optional result;
> + result = getAnnotation(beanManager, event.getAnnotated(), FacesDataModel.class);
> + if (null != result && result.isPresent()) {
> + FacesDataModel d = (FacesDataModel) result.get();
> + forClassToDataModelClass.put(d.forClass(),
> + (Class<? extends DataModel<?>>) event.getBean().getBeanClass());
> + }
> }
>
> /**
>
>
>