lives
lives

Reputation: 1185

Java EE EJB interceptors

Is it possible to have the default interceptor configured for all EJBs within an ear?

Default interceptors can be mentioned for EJBs within a module in the ejb-jar.xml. If there are multiple modules within an application, all modules need to have this configuration.

I am looking at enforcing certain interceptors on the application globally. So it would be helpful if it can be set at an application level or at a server level so that it is not left to the discretion of developers of the individual modules to include them.

Upvotes: 4

Views: 1478

Answers (1)

MaDa
MaDa

Reputation: 10762

You can't avoid having to specify the interceptor in each ejb-jar file, there is no possibility to define it on EAR level. Interceptor class needs to be packed in the same ejb-jar file as all beans that use it.

You can still extract interceptor's code into a common library used by all ejb modules, but still, in each ejb-jar file you have to define and activate a separate interceptor calling the common implementation.

Upvotes: 2

Related Questions