Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] Performancemonitoring aspect

Hi.

i was just wandering if there could be a clever way of making an
aspect that could figure out the duration in time from a call in one
class to a later call in another class ?

To elaborate a little.
Let say we have a class called Customer who has a method, updateCustomer()
And then we have a class CustomerDao with a method save()
In addition we have a unspecified number of logical application
layers, doing alot of things as a part of this process, some of them
e.g. checking the given adress on a central adress register and so on.

So what i would like to is to start a timer when someone calls
updateCustomer(), then let the applicationflow go about it's ususal
tasks, some of them asynchroniously and some not, until we get to the
point that the dao is finished with the persisting in the database,
then i would like to stop the timer handle and log the result.
Ideas anyone ?

@Aspect
MyAspect{
    private Timer timer = new Timer();

    @Before("call (* Customer.updateCustomer(..)"
    public startTimer(){
        timer.start();
    }

    @After("call (* CustomerDao.save(..)"
    public stopTimer(){
        timer.stop();
        timer.log();
    }
}


Best regards
Kaare Nilsen


Back to the top