Re: [aspectwerkz-user] After throwing advice
Alexandre Vasseur <[email protected]>
| Newsgroups | gmane.comp.java.aspectwerkz.user |
|---|---|
| Message-ID | <[email protected]> |
Raka
See src/test/test/afterxxx folder in the source
AfterThrowing fully support binding of the exception type.
f.e. with 1.4 doclet syntax:
/**
* @AfterThrowing(type="e", pointcut="execution(*
test.afterxxx.TestBinding.throwChecked(..))")
*/
public void logAfterBindingExact(ClassNotFoundException e) {
TestBinding.log("afterThrowingExact " + e.getClass().getName());
}
Also to bind the this or target instance, use a this(..) or
target(..) pointcut designator and refer to it in the advice signature
@Before("execution(* foo.Bar.do*(..)) && this(abarinstance)")
void beforeAdvice(Bar abarinstance) { ..... }
Alex
On Mar 26, 2005 8:33 AM, Wirama Putra <[email protected]> wrote:
> 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)
>
>
> __________________________________
> Do you Yahoo!?
> Yahoo! Small Business - Try our new resources site!
> http://smallbusiness.yahoo.com/resources/
>