dev@javaserverfaces.java.net

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

From: Edward Burns <edward.burns_at_oracle.com>
Date: Tue, 15 Sep 2015 08:08:42 -0700

>>>>> On Fri, 11 Sep 2015 23:14:13 +0200, arjan tijms <arjan.tijms_at_gmail.com> said:

EB> Ah, you could rewrite the processBean() to not use lambdas, right?

AT> Yes, there's likely something that can be done there. I'll take a look.

>>>>> On Mon, 14 Sep 2015 14:17:00 -0700, Edward Burns <edward.burns_at_oracle.com> said:

EB> Please find attached a changebundle that rewrites the processBean() to
EB> not use lambda. If it's ok with you, please let me know and I'll commit
EB> it.

Any reply on this? I'm keen to put it in because without it we can't
use 8u60.

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());
+ }
     }
     
     /**