Re: [aspectwerkz-user] After throwing advice

Alexandru Popescu <[email protected]>
Newsgroups gmane.comp.java.aspectwerkz.user
Message-ID <[email protected]>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

[quote Wirama Putra::on 3/26/2005 8:33 AM]
> Hi,
> 
> I want to wrap runtime exception that is thrown from
> execution of method of Services or Repositories.
> For that, I declare the following aspect:
> 
> ---
> <aspect
> class="com.revtech.framework.aop.ThrowsAspect">
>   <pointcut name="publicServiceAndRepository"
> expression="execution(public *
> com.revtech.framework.service.Service+.*(..)) OR
> execution(public *
> com.revtech.framework.repository.Repository+.*(..))"/>
>   <advice name="afterThrowing" type="after
> throwing(java.lang.RuntimeException)"
> bind-to="publicServiceAndRepository"/>
> </aspect>	
> ---
> 
> Method afterThrowing has the following signature:
> ---
> public void afterThrowing(JoinPoint jp) throws
> Throwable
> ---
> 
> The problem is: In the afterThrowing method I need the
> exception that was thrown. I can't find any way to get
> it.
> I can't even know the object (instance of service /
> repository) that was invoked :(
> 
> Is there something like ThrowsAdvice in
> Springframework? It's a simple matter in Spring to
> have access to such information... 
> I only have to have implement method with the
> following signature in my advice (which implements
> ThrowsAdvice):
> ---
> afterThrowing([Method], [args], [target], Throwable
> subclass)
> ---
> 
> I see that there's an interface named
> AfterThrowingAdvice in AspectWerkz 2.0. But it's not
> clear to me how to use it.
> 
> Best regards & TIA,
> Raka (http://www.jroller.com/page/donraka)
> 

The JP model offered by AW is very powerfull and I am sure you will find out the means to achieve
your goal.
Please try to read our documentation (http://aspectwerkz.codehaus.org/implementation.html,
http://aspectwerkz.codehaus.org/definition_issues.html,
http://aspectwerkz.codehaus.org/attribute_definition.html,
http://aspectwerkz.codehaus.org/xml_definition.html ;-) ).
You will also find a very good help in the published AOP books.

cheers,
- --
:alex |.::the_mindstorm::.|
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (MingW32)

iD8DBQFCRRozOCPjdDT2FEURAknBAKDJ3TzpIxar0nT6VLQBAyxfhki6nACginMx
tDIeGp/vhNZVz6/w+yp1W9w=
=eciv
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.