This content has been marked as final.
Show 1 reply
-
1. Re: How do I inject CDI beans into Custom Entity Classes?
kwintesencja Oct 19, 2014 5:29 PM (in response to firepod)Hi there, your problem is that you create the entity via new operator so CDI is not managing your entity...i can see two options:
- @Inject the Custumer so CDI can manage it which i think is not what you want
- or you can fire the event programactly like below:
public void deactivate(){ BeanManager bm = CDI.current().getBeanManager(); bm.fireEvent( new DeactivationEvent() ); }
if you use CDI 1.0 you have to lookup BeanManager via jndi, something like:
BeanManager bm = return (BeanManager) InitialContext.doLookup("java:comp/BeanManager");
I hope it helps.