Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] Simpe Question


    Hi,
     I have a big Java API on which I want to put
AspectJ. Most of the classes in my API are derived
from  a base StatefullParentBean class or if they are
not derived from that one are used in the context of
StatefullParentBean.

  What I want is to catch before & after & return
value for all the top level calls from the classes
which are derived from StatefullParentBean. With this
I think I cover 99% of my API code as most of the
classes are derived from Statfull or are used in
StatefullParentBean.

My code (which is not working) is :

//cathc all the calls that are made in
StatefullParentBean derived classes.

pointcut whenMethodIsCalled(StatefullParentBean bean):
this(bean) && execution (* *.* (..)) &&
!within(TestAPI); 
	
//limit just to top level calls
pointcut topLevelCalls(StatefullParentBean
bean):whenMethodIsCalled(bean) &&
!cflow(whenMethodIsCalled(StatefullParentBean));
	
before(StatefullParentBean bean): topLevelCalls(bean)
{
ProfilerTrace.beforeMethodIsCalle(thisJoinPoint);
}

after(StatefullParentBean bean) : topLevelCalls(bean)
{
ProfilerTrace.afterMethodIsCalled(thisJoinPoint);
}
 This is not working. I put breakpoints in eclipse in
before or after and it is not reaching there.

Thanks,
Virgil





--- aspectj-users-request@xxxxxxxxxxx wrote:

> Send aspectj-users mailing list submissions to
> 	aspectj-users@xxxxxxxxxxx
> 
> To subscribe or unsubscribe via the World Wide Web,
> visit
> 
>
https://dev.eclipse.org/mailman/listinfo/aspectj-users
> or, via email, send a message with subject or body
> 'help' to
> 	aspectj-users-request@xxxxxxxxxxx
> 
> You can reach the person managing the list at
> 	aspectj-users-owner@xxxxxxxxxxx
> 
> When replying, please edit your Subject line so it
> is more specific
> than "Re: Contents of aspectj-users digest..."
> 
> 
> Today's Topics:
> 
>    1. perthis instantiation model aspects (Vincenz
> Braun)
>    2. Re: [NEWSDELIVER] Getting VerifyError with
> around	advice on
>       static method (Matthew Webster)
> 
> 
>
----------------------------------------------------------------------
> 
> Message: 1
> Date: Thu, 2 Mar 2006 01:23:43 +0100
> From: "Vincenz Braun" <vb@xxxxxxxxx>
> Subject: [aspectj-users] perthis instantiation model
> aspects
> To: <aspectj-users@xxxxxxxxxxx>
> Message-ID:
> <000001c63d8f$939f8300$0b00a8c0@eveloxvbraun>
> Content-Type: text/plain; charset="us-ascii"
> 
> Hello,
> 
>  
> 
> I refactored an aspect using perthis instantiation
> type and faced a
> behaviour 
> 
> I did not expected and I can not find a reason for.
> Could somebody show me
> the problem, please?
> 
>  
> 
> Take this simple interface:
> 
>  
> 
> public  interface A {
> 
>  
> 
>             public  void a(); 
> 
> }
> 
>  
> 
> And this class:
> 
>  
> 
> public class B implements A {
> 
>             
> 
>             public void a() {
> 
>                         System.out.println("in B");
> 
>             }
> 
>             
> 
> public static void main(String[] args) {
> 
>                         new B().a();
> 
>             }
> 
> }
> 
>  
> 
> Having this aspect:
> 
> public aspect TestAspect perthis(test(A)){
> 
>  
> 
>             // this does match at runtime with
> runtime test
> 
>             //pointcut test(A a): execution(public
> void A+.a()) && this(a);
> 
>             
> 
>             // this does not match at runtime with
> runtime test
> 
>             pointcut test(A a): execution(public
> void A.a()) && this(a);
> 
>             
> 
>             void around(A a): test(a) {
> 
>                        
> System.err.println(thisJoinPoint);
> 
>                         proceed(a);
> 
>             }
> 
> }
> 
>  
> 
> public aspect ExecutionAspect {
> 
>             
> 
>             // this does match
> 
>             //pointcut test(A a): execution(public
> void A+.a()) && this(a);
> 
>             
> 
> // this also does match
> 
>             pointcut test(A a): execution(public
> void A.a()) && this(a);
> 
>             
> 
>             void around(A a): test(a) {
> 
>                        
> System.err.println(thisJoinPoint);
> 
>                         proceed(a);
> 
>             }
> 
> }
> 
>  
> 
> I know I could simply drop the declaring type in the
> pointcut declaration. 
> 
> But I "feel" the second pointcut declaration in the
> aspect using perthis
> instantiation model
> should also work. Why is that not the case?
> 
>  
> 
> Thank you very much,
> 
> Vincenz
> 
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL:
>
http://eclipse.org/pipermail/aspectj-users/attachments/20060302/842fd44c/attachment.html
> 
> ------------------------------
> 
> Message: 2
> Date: Thu, 2 Mar 2006 11:35:48 +0000
> From: Matthew Webster <matthew_webster@xxxxxxxxxx>
> Subject: [aspectj-users] Re: [NEWSDELIVER] Getting
> VerifyError with
> 	around	advice on static method
> To: Barry Kaplan <groups1@xxxxxxxxxxx>
> Cc: aspectj-users@xxxxxxxxxxx
> Message-ID:
> 
>
<OF2428965F.DECDA7CB-ON80257125.003F3740-80257125.003FAFE5@xxxxxxxxxx>
> Content-Type: text/plain; charset="us-ascii"
> 
> Barry,
> 
> Can I strongly suggest you post to aspectj-users
> which will bring you 
> discussion to a wider audience. 
> 
> Can you answer 2 questions WRT your problem:
> 
=== message truncated ===



Back to the top