Skip to main content

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

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.

 

 

Cordialement / Best regards

 

Jean-Louis Pasturel
jeanlouis.pasturel@xxxxxxxxxxxxxxxxxx

 


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

*********************************
This message and any attachments (the "message") are confidential and intended solely for the addressees.
Any unauthorised use or dissemination is prohibited.
Messages are susceptible to alteration.
France Telecom Group shall not be liable for the message if altered, changed or falsified.
If you are not the intended addressee of this message, please cancel it immediately and inform the sender.
********************************

Back to the top