Just a piece of code with
an around advice to give an idea
public
abstract pointcut methods();
Object around(): methods() {
long deb = Calendar.getInstance().getTimeInMillis();
Object
retour = proceed();
long
fin = Calendar.getInstance().getTimeInMillis();
long
duree= fin-deb;
if
(duree >= this.durationMini) {
outDurationMethods
.append(new
StringBuffer(outDurationMethods.getSdf()
.format(Calendar.getInstance().getTime())).append(
sep)
.append(
thisJoinPoint.getSignature()
.getDeclaringTypeName())
.append(".").append(
thisJoinPoint.getSignature().getName())
.append(sep).append(
(fin
- deb)).append("\n").toString());
//
outDurationMethods.flush();
}
return
retour;
}
This abstract aspect must
be implemented at ltw weaving ( aop.xml) or by extending it at Compile Time
weaving.
I develop a handler Class
( outDurationMethods is an instance of this class, with synchronized accesses
to write operations) to log the result in a file ( cvs format) that I can
visualize with Excel for example.
There are examples in the
aspectj doc/examples folder.
De : aspectj-users-bounces@xxxxxxxxxxx
[mailto:aspectj-users-bounces@xxxxxxxxxxx] De
la part de Missing Name
Envoyé : lundi 27 avril 2009
23:44
À : aspectj-users@xxxxxxxxxxx
Objet : [aspectj-users]
method's calls
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