Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] method's calls

Hi,

You can find the AspectJ programming guide here:
http://www.eclipse.org/aspectj/doc/released/progguide/index.html
It is a good reference for the language.

Here is a nice intro:
http://www.javaworld.com/javaworld/jw-01-2002/jw-0118-aspect.html

As for your question, try this (this captures only the particular
method with 3 integer arguments):

aspect CounterAspect {
  static int counter = 0;
  pointcut interestingMethod() : execution(public int
MyClass.myMethod(int, int, int);
  before() : interestingMethod() {
    counter++;
  }

  around() : interestingMethod() {
    int start = System.currentTimeMillis();
    proceed();
    int end = System.currentTimeMillis();
    System.out.println("Time taken: " + (end - start));
  }
}

On Mon, Apr 27, 2009 at 2:43 PM, Missing Name <missing.name@xxxxxxxxx> wrote:
> Hello,
>
>
>
> I am a novice in AspectJ and I’m trying to count the number of calls for a
> method or the duration of one. Does anyone have a clue?  I also would like
> some advice about a good AspectJ documentation/help. Thanks.
>
>
>
> Regards,
>
> Diana
>
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>


Back to the top