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?

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top