You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by cocorossello <co...@gmail.com> on 2018/09/20 09:45:17 UTC
CDI Interceptors to intercept all EJB @Schedule methods
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
Re: CDI Interceptors to intercept all EJB @Schedule methods
Posted by cocorossello <co...@gmail.com>.
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
Re: CDI Interceptors to intercept all EJB @Schedule methods
Posted by Romain Manni-Bucau <rm...@gmail.com>.
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>
Le jeu. 20 sept. 2018 à 11:45, cocorossello <co...@gmail.com> a
écrit :
> 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
>