Discussion:
CDI Interceptors to intercept all EJB @Schedule methods
cocorossello
2018-09-20 09:45:17 UTC
Permalink
Hi,

Is there any way to apply a CDI interceptor to existing @Schedule without
explicitly usign @Interceptors in all methods? I haven't found anything in
the spec.

Or is there any easy way to create my own @Schedule CDI interceptor?

Thanks in advance.



--
Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Users-f979441.html
Romain Manni-Bucau
2018-09-20 09:51:07 UTC
Permalink
Hi,

did you put @AroundTimeout on the interceptor method? AroundInvoke is not
triggered for @Schedule.

Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> | Blog
<https://rmannibucau.metawerx.net/> | Old Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Book
<https://www.packtpub.com/application-development/java-ee-8-high-performance>
Post by cocorossello
Hi,
the spec.
Thanks in advance.
--
http://tomee-openejb.979440.n4.nabble.com/TomEE-Users-f979441.html
cocorossello
2018-09-20 21:21:11 UTC
Permalink
Sorry, I made a mistake (I made the interceptor without parameters and didn't
read the tomee warnings)

It works with an ejb-jar.xml

<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar xmlns="http://xmlns.jcp.org/xml/ns/javaee"
version="3.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/ejb-jar_3_2.xsd">
<assembly-descriptor>
<interceptor-binding>
<ejb-name>*</ejb-name>
<interceptor-class>com.ScheduleInterceptor</interceptor-class>
</interceptor-binding>
</assembly-descriptor>
</ejb-jar>

and


public class ScheduleInterceptor {

@AroundTimeout
public Object intercept(InvocationContext ctx) throws Exception {
System.out.println("hi");
return super.intercept(ctx);
}
}






--
Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Users-f979441.html
Loading...