Java EE EJB Interceptors

Can I set a default sniffer for all EJBs in my ear?

Default hooks can be mentioned for EJB in a module in ejb-jar.xml. If an application has several modules, all modules must have this configuration.

I am considering using some interceptors in an application around the world. Therefore, it would be useful if it could be installed at the application level or at the server level, so that it does not remain at the discretion of the developers of individual modules for their inclusion.

+4
source share
1 answer

You cannot fail to specify an interceptor in each ejb-jar file, there is no way to define it at the EAR level. The interceptor class must be packaged in the same ejb-jar file as all beans that use it.

You can still extract the interceptor code into the shared library used by all ejb modules, but still in each ejb-jar file you need to define and activate a separate interceptor that calls the common implementation.

+2
source

Source: https://habr.com/ru/post/1380839/


All Articles