Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top