False alarm.... Its now working. Must have been a problem with the ajdt. Sorry for the confusion!!
Regards, Andrew ----- Original Message ---- From: Mohan Radhakrishnan <[EMAIL PROTECTED]> To: [email protected] Sent: Tuesday, 30 September, 2008 11:53:34 AM Subject: Re: [aspectj-users] catching container managed transactions Hi, The following aspect actually shows those arrows to the left. I have not run it though. package com.aspect; import javax.jms.Message; public aspect MessageDrivenBeanAspect { pointcut handleException(Message i): execution (* com.test.plug.*.onMessage(Message)) && args(i); after(Message i) throwing(Throwable ex): handleException(i) { } } Thanks, Mohan On 9/30/08, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > As it turns out, I managed to do the following: > > > pointcut handleException(Message i): > execution (* myBean.onMessage(Message)) && args(i); > > > after(Message i) throwing(Throwable ex): handleException(i) > { > > System.out.println("=============================================="); > System.out.println("Exception after > \n"+"Exception:"+ex.getMessage()); > > System.out.println("=============================================="); > } > > > However, while the advice seems to match, it never gets called, which kinda > sucks. > Can anyone provide any insight into what might be wrong? > > I no longer get a 'adviceDidNotMatch' error, (whenever i changed 'Exception' > to 'Throwable'), but it still doesnt seem to link up.... (ie no wee arrow > pointing at the side) > > Sorry for the seemingly stupid request for help.... i just cant see where it > isnt matching... > > Many thanks. > > Andy > > > > > ----- Original Message ---- > From: Dean Wampler <[EMAIL PROTECTED]> > To: [email protected] > Sent: Monday, 29 September, 2008 2:00:48 PM > Subject: Re: [aspectj-users] catching container managed transactions > > Who calls the "onMessage" method? If you use the "call" pointcut designator, > AspectJ has to be able to weave the handler "advice" into the code that does > the calling. If that code is in a third-party jar that you don't want to > modify, then use "execute" instead: > > pointcut handleException(Message m): > execution(* myBean.onMessage(Message)) && args(m); > > dean > > > On Sep 29, 2008, at 7:55 AM, <[EMAIL PROTECTED]> wrote: > > > Ok, > Ive changed this to match the following > > > pointcut handleException(Message m): > call (* myBean.onMessage(Message)) && args(m); > > > > after(Message m) throwing (Exception ex): handleException(m) > { > //handle exception here > } > > However, the pointcuts doesnt seem to get matched... have I got this all > wrong? > I want to be able to access the message inside the handler, prefereably. > > Andy > > ----- Original Message ---- > From: Dean Wampler <[EMAIL PROTECTED]> > To: [email protected] > Sent: Monday, 29 September, 2008 1:21:14 PM > Subject: Re: [aspectj-users] catching container managed transactions > > Andy, > > A little more information you might find useful. Since you print a message > with the exception, you'll need to "bind" it with the "throwing": > > after() throwing(Exception ex): mypointcut() { > System.out.println("Error here, guv" + e); > } > > Also, just to be clear, if you actually wanted to recover from the > exception, you can't do that with after throwing. The exception will still > get thrown up the stack. To recover, you would have to use around advice. > > > dean > > > On Sep 29, 2008, at 7:00 AM, <[EMAIL PROTECTED]> wrote: > > Hi > > You are using an around advice: > > void around(Message m) throws Exception: handleException(m) > { > try > { > proceed(m); > } > catch(Exception e) > { > System.out.println("Error here,guv "+e); > throw e; > } > } > > the alternativ is using an after advice with a throwing clause. That means > that the advice is only executed if your pointcut throws an exception. > > after() throwing: mypointcut() { > //handle exception here > } > > > mvh > Hermod > > ________________________________ > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of > [EMAIL PROTECTED] > Sent: Monday, September 29, 2008 1:37 PM > To: [email protected] > Subject: Re: [aspectj-users] catching container managed transactions > > > Im not sure i follow, can you give a quick 1-liner example, or point me to a > relevant doco? > > thanks. > Andrew > > ----- Original Message ---- > From: "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> > To: [email protected] > Sent: Monday, 29 September, 2008 9:55:30 AM > Subject: RE: [aspectj-users] catching container managed transactions > > Hi > > Why don't you use "after returning throwing" instead of around advice. > > Hermod > > ________________________________ > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of > [EMAIL PROTECTED] > Sent: Monday, September 29, 2008 10:31 AM > To: [email protected] > Subject: [aspectj-users] catching container managed transactions > > > Hi > > I have a message driven bean which, inherently, throws an exception back to > the container to rollback jms messsages. > > I want to be able to catch this exception, log something, and then let the > exception carry on. > > I have a pointcut defined as follows: > > > pointcut handleException(Message m): > call (* myBean.onMessage(Message)) && args(m); > > With the advice being: > > void around(Message m) throws Exception: handleException(m) > { > try > { > proceed(m); > } > catch(Exception e) > { > System.out.println("Error here,guv "+e); > throw e; > } > } > > > My question is two-fold: > 1) Can we throw the exception like this and will the throw go back to the > container managed transaction?? > 2) Is this the right way to do this kind of thing? (im assuming not, as the > advice is marked as 'Not matched', but maybe this is one for the ajdt guys.) > > Sorry - im completely new to this stuff.... > > Regards, > Andy > > * * * * * * * * * * * * * * * * * * * * * * * > * * * * * * * * * * * * * * * > > This email with attachments is solely for the use of the individual or > entity to whom it is addressed. Please also be aware that the DnB NOR Group > cannot accept any payment orders or other legally binding correspondence > with > customers as a part of an email. > > This email message has been virus checked by the anti virus programs used > in the DnB NOR Group. > > * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * > > * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * > > This email with attachments is solely for the use of the individual or > entity to whom it is addressed. Please also be aware that the DnB NOR Group > cannot accept any payment orders or other legally binding correspondence > with > customers as a part of an email. > > This email message has been virus checked by the anti virus programs used > in the DnB NOR Group. > > * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * > > _______________________________________________ > aspectj-users mailing list > [email protected] > https://dev.eclipse.org/mailman/listinfo/aspectj-users > > > > > > > > > > > > Dean Wampler, Ph.D. > dean at objectmentor.com > http://www.objectmentor.com > See also: > http://www.polyglotprogramming.com > Multi-language and multi-paradigm programming > http://www.aspectprogramming.com AOP advocacy site > http://aquarium.rubyforge.org AOP for Ruby > http://www.contract4j.org Design by Contract for Java5 > > I want my tombstone to say: > Unknown Application Error in Dean Wampler.exe. > Application Terminated. > [Okay] [Cancel] > > > > > _______________________________________________ > aspectj-users mailing list > [email protected] > https://dev.eclipse.org/mailman/listinfo/aspectj-users > > > > > > > > > > > > Dean Wampler, Ph.D. > dean at objectmentor.com > http://www.objectmentor.com > See also: > http://www.polyglotprogramming.com Multi-language and > multi-paradigm programming > http://www.aspectprogramming.com AOP advocacy site > http://aquarium.rubyforge.org AOP for Ruby > http://www.contract4j.org Design by Contract for Java5 > > I want my tombstone to say: > Unknown Application Error in Dean Wampler.exe. > Application Terminated. > [Okay] [Cancel] > > > > > > _______________________________________________ > aspectj-users mailing list > [email protected] > https://dev.eclipse.org/mailman/listinfo/aspectj-users > > _______________________________________________ aspectj-users mailing list [email protected] https://dev.eclipse.org/mailman/listinfo/aspectj-users
_______________________________________________ aspectj-users mailing list [email protected] https://dev.eclipse.org/mailman/listinfo/aspectj-users
