Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EJB Interceptors vs CDI Interceptors

Is there any difference between EJB Interceptors declared in ejb-jar.xml file vs CDI interceptors declared in beans.xml file?

Both interceptors are declared using annotation @Interceptors. If CDI interceptors apply to EJBs as well then why do EJB interceptors exists?

like image 448
Chir Avatar asked Dec 26 '22 13:12

Chir


1 Answers

You are right, they are basically the same but the CDI interceptors are little bit more sophisticated - they contain for example Interceptor binding. See Weld documentation for reference. Note that there will be probably effort in the future for uniting EJB and CDI (for instance CDI 1.1 allows you to use JTAs declarative transactions which effectively replaces EJB ones) so I expect those two projects to merge in next few years.

like image 165
Petr Mensik Avatar answered Jan 02 '23 11:01

Petr Mensik