If I understand you question correctly, the reason that the interceptor is not working is that it directly calls the method instead of going through the proxy. It is a known feature.

Many thanks,
Emily
===========================
Emily Jiang
WebSphere Application Server, CDI Development Lead

 
MP 211, DE3A20, Winchester, Hampshire, England, SO21 2JN
Phone:  +44 (0)1962 816278  Internal: 246278

Email: emijiang@uk.ibm.com
Lotus Notes: Emily Jiang/UK/IBM@IBMGB




From:        Matej Novotny <manovotn@redhat.com>
To:        Michael Remijan <mjremijan@yahoo.com>
Cc:        weld-dev@lists.jboss.org
Date:        14/11/2016 08:49
Subject:        Re: [weld-dev] [cdi-dev] Think I found bug with interceptor
Sent by:        weld-dev-bounces@lists.jboss.org




Hi,

first of all let us take this conversation off the cdi list, as it is a Weld related question (moving to weld-dev list).

Now to your question(s)...

If you could attach a tiny reproducer, this would probably be resolved within minutes, so if you can send one, do so please.

> Now here's the problem, If I use this annotation on just a regular method
> which I call myself, it DOES NOT work.

This feels like very basic use case do I doubt it isn't working.
What are the classes where you declare these methods?
How to you obtain a reference to the bean which has `doSend` method?

Again, reproducer would make all this very obvious and I could help you quickly :)


> @Priority set on it and that works fine. But I've also tried setting
> <interceptors> in beans.xml

@Priority enables in for whole application, while beans.xml for the given bean archive.
And you should not combine both approaches.


Regards
Matej


----- Original Message -----
> From: "Michael Remijan" <mjremijan@yahoo.com>
> To: cdi-dev@lists.jboss.org
> Sent: Monday, November 14, 2016 5:43:27 AM
> Subject: [cdi-dev] Think I found bug with interceptor
>
> Greetings,
>
> I am using:
>
> <dependency>
> <groupId>org.jboss.weld.se</groupId>
> <artifactId>weld-se-core</artifactId>
> <version>3.0.0.Alpha15</version>
> </dependency>
>
> and I think I found a bug with the interceptors. I wanted to ask about it
> first before I put it in Jira.
>
> Basically, the interceptor I have defined works great if I annotate a method
> called by the CDI container, which in my case is an method observing for an
> event. I have an ExceptionRetryInterceptor class and an ExceptionRetry
> annotation. If I annotate an observer method like this:
>
> @ExceptionRetry
> public void send(
> @Observes @Priority(SEND_EMAIL_MESSAGE) EmailEvent evnt
> ) throws MessagingException, IOException {....}
>
>
> No problem, everything works fine. I can see the interceptor code being
> called in my logs.
>
> Now here's the problem, If I use this annotation on just a regular method
> which I call myself, it DOES NOT work. So if I refactor the above example so
> the annotation is NOT on the observer method called by the container, then
> the doSend() method below does NOT get wrapped by the interceptor:
>
>
> public void send(
> @Observes @Priority(SEND_EMAIL_MESSAGE) EmailEvent evnt
> ) throws MessagingException, IOException {
> //....
> doSend();
> }
>
> @ExceptionRetry
> public void doSend() {....} // this method does not get wrapped by the
> interceptor
>
>
> I'm trying to figure out why. My ExceptionRetryInterceptor class has a
> @Priority set on it and that works fine. But I've also tried setting
> <interceptors> in beans.xml but the doSend(){...} method still doesn't get
> wrapped.
>
> Any thoughts/help?
>
>
>
>
>
> _______________________________________________
> cdi-dev mailing list
> cdi-dev@lists.jboss.org
>
https://lists.jboss.org/mailman/listinfo/cdi-dev
>
> Note that for all code provided on this list, the provider licenses the code
> under the Apache License, Version 2
> (
http://www.apache.org/licenses/LICENSE-2.0.html). For all other ideas
> provided on this list, the provider waives all patent and other intellectual
> property rights inherent in such information.
_______________________________________________
weld-dev mailing list
weld-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/weld-dev



Unless stated otherwise above:
IBM United Kingdom Limited - Registered in England and Wales with number 741598.
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU