Open agori opened 10 years ago
Thanks for creating the issue.
We will take care of it in the next release (0.2).
At the moment I´am fixing the NPE :bug: in https://github.com/qabbasi/BeanTest/tree/Issue%233 :wink:
Tried the following:
public void processAfterBeanDiscovery(@Observes AfterTypeDiscovery afterTypeDiscovery, BeanManager beanManager) { List<Class<?>> interceptors = afterTypeDiscovery.getInterceptors(); }
But AfterTypeDiscovery#getInterceptors returns an empty Interceptor list.
Ref: http://docs.oracle.com/javaee/7/api/javax/enterprise/inject/spi/AfterTypeDiscovery.html
Alternative approach: retrieve via the @Interceptors(Class[]) annotation all old fashioned Interceptor definitions altogether with injection points such as the @PersistenceContext.
@Interceptors(MyInterceptor.class) public class MyInterceptedBean {}
public class MyInterceptor {
@PersistenceContext <-- replaced by @Inject
EntityManager em;
@AroundInvoke
public Object handle(InvocationContext context) throws Exception {
try {
return context.proceed();
} finally {
em.flush();
}
}
}
PersistenceContext is not injected in EJB interceptors, and throws NullPointerException when I try to access the EntityManager. This issue forces me to rewrite all the interceptors.