How to create global ejb server side / client side interceptors in JBoss EAP
Environment
- Red Hat JBoss Enterprise Application Platform (EAP)
- 7
- 6
Issue
I would like to create an implementation of org.jboss.invocation.Interceptor and add it to the list of interceptors (such as ExecutionTimeInterceptor, SBInvocationInterceptor, ...), specifically for ejb3 timers. How do I do that in EAP6?
Resolution
EAP 7.3+
Add a custom module with the jar containing the interceptors
module add --name=examples.ejb.interceptors --resources=/path/to/example-ejb-interceptors.jar
Enable a global EJB Server Interceptor
/subsystem=ejb3:list-add(name=server-interceptors,value={module=examples.ejb.interceptors,class=org.jboss.examples.ejb.interceptors.ExampleServerInterceptor})
Enable a global EJB Client Interceptor
/subsystem=ejb3:list-add(name=client-interceptors,value={module=examples.ejb.interceptors,class=org.jboss.examples.ejb.interceptors.ExampleClientInterceptor})
Prior to EAP 7.3
Workaround:
- create an EJB Interceptor and configure it in the ejb-jar.xml, jboss-ejb3.xml , etc for all deployments. JBoss deployment overlays could be used to add a configuration xml to all deployments to enable the interceptor.
Related Solutions
SBR
Components
Category
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.