Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [aspectj-users] catching container managed transactions

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: aspectj-users-bounces@xxxxxxxxxxx [mailto:aspectj-users-bounces@xxxxxxxxxxx] On Behalf Of andymorton@xxxxxxxxxxxxxx
Sent: Monday, September 29, 2008 1:37 PM
To: aspectj-users@xxxxxxxxxxx
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: "hermod.opstvedt@xxxxxxxxx" <hermod.opstvedt@xxxxxxxxx>
To: aspectj-users@xxxxxxxxxxx
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: aspectj-users-bounces@xxxxxxxxxxx [mailto:aspectj-users-bounces@xxxxxxxxxxx] On Behalf Of andymorton@xxxxxxxxxxxxxx
Sent: Monday, September 29, 2008 10:31 AM
To: aspectj-users@xxxxxxxxxxx
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.

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

Back to the top