To that I could answer, "what's the use of ProcessBean if you can't do anything about the bean tied to the event"
?
But I have an example. I was asked to build a prototype extension to create an injection point when a given annotation (@CacheContext) is found on a field. Here's the portable code I had to wrote to create the feature :
Extension code is small but AnnotatedType and AnnotatedField impls are verbose and the whole is cumbersome to read and maintain (3 classes and 178 lines of code)
If we only target OWB, the extension code is:
package org.cdisandbox.autoinject.Extension;
import org.cdisandbox.autoinject.CacheContext;
import javax.enterprise.event.Observes;
import javax.enterprise.inject.spi.*;
import java.util.HashSet;
import java.util.Set;
/**
* Extension looking for the @CacheContext annotation to transform it in an InjectionPoint
*/
public class AutoInjectExtension implements Extension {
private Set<AnnotatedType<?>> atWithCacheContext = new HashSet<>();
/**
* This Observer captures all AnnotatedType containing @CacheContext
*/
public void CreateInjectionPoint(@Observes @WithAnnotations(CacheContext.class) ProcessAnnotatedType<?> pat) {
atWithCacheContext.add(pat.getAnnotatedType());
}
/**
* This observer add an injection point in all bean having @Cachecontext annotaion on some field
*/
public <T> void CheckBeansForCacheContext(@Observes ProcessManagedBean<T> pmb, BeanManager bm) {
AnnotatedType<T> beanAT = pmb.getAnnotatedBeanClass();
if(atWithCacheContext.contains(beanAT)) {
Bean<T> bean = pmb.getBean();
Set<InjectionPoint> ips = new HashSet(bean.getInjectionPoints());
for (AnnotatedField<? super T> f : beanAT.getFields()) {
if(f.isAnnotationPresent(CacheContext.class)) {
ips.add(bm.createInjectionPoint(f));
}
}
}
}
}
One class, 42 lines.
The CDI project is part ofJakarta and uses GitHub issues as it's issue tracking system.
Therefore, all issues in CDI JIRA project are being bulk-closed as described in this GitHub issue.
If you feel like this particular issue deserves ongoing discussion, investigation or fixes in CDI/CDI TCK, please create a new issue under GitHub repository and include a link to this JIRA.
For specification related question/issues, please use - https://github.com/eclipse-ee4j/cdi/issues
For CDI TCK related questions/issues, please use - https://github.com/eclipse-ee4j/cdi-tck/issues