Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] Weaving advice around methods defined by declare parents

Title: Weaving advice around methods defined by declare parents

I'm wondering if something like the following is possible:

public aspect AspectA
{
    declare parents: AImpl implements A;  // A has one method, void x();
   
    // Implement A
    public void A.x() { System.out.println( "x()" ); }

    pointcut myPC() : execution( void AImpl.x() );
   
    Object around() : myPC()
    {
        System.out.println( "Before x()" );
        Object result = proceed();
        System.out.println( "After x()");
        return result;  
    }  
}


This is a simplified example of what I'm trying to do but it illustrates my problem.  What I would like to do is implement an interface using an aspect and then add advice around those methods that were implemented.  However AspectJ doesn't seem to be able to add advice in this fashion.

Any ideas how I can accomplish this?

Cheers,

Mike


Back to the top