[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] passing local state between join points?

Nic,

I wrote two articles on Java Performance Monitoring with AspectJ and JMX for
the AOP@Work series on IBM Developerworks about how we use AspectJ to allow
monitoring performance of applications. In those articles, I show how you
can use the worker object pattern to make state like your stopwatches
available at other join points. You also can make percflow aspects. However,
in the Glassbox project (which is the successor to the code in the articles)
we end up using a ThreadLocal stack we manage ourselves because it is the
most flexible. If jp2 might happen after jp1 has exited, then the
ThreadLocal stack is the way I'd do it. Of course I'd also encourage you to
look at building on Glassbox instead of building your own thread-safe system
for capturing times inside a container :-)

Also, this is really a question for the aspectj-users mailing list, not
aspectj-dev (which is used to discuss development of the AspectJ tools
themselves).

-----Original Message-----
From: aspectj-dev-bounces@xxxxxxxxxxx
[mailto:aspectj-dev-bounces@xxxxxxxxxxx] On Behalf Of
nick.nguyen@xxxxxxxxxxxxxxxxx
Sent: Friday, February 02, 2007 4:10 AM
To: aspectj-dev@xxxxxxxxxxx
Subject: [aspectj-dev] passing local state between join points?


Hello,

I've seen examples that achive this by storing partial state of the stack
frame in member fields... but this seems like overkill when all I want to
do is keep values on the stack frame within a single method call.

Moreover, when multiple threads invoke an object it seems that i need to
use synchronization because I don't create the threads; Tomcat creates
them.

For example I have many methods of the form:

public void g()  {

jp1:  Long t1 = System.getCurrentTime();

      ...

jp2:  Long t2 = System.getCurrentTime() - t1;
}

I want t1 available at join point 2 without storing t1 into a member field.

Does AspectJ provide a mechanism for this?

Thanks in advance,
Nic.


This message and any attachments (the "message") is 
intended solely for the addressees and is confidential. 
If you receive this message in error, please delete it and
immediately notify the sender. Any use not in accord with
its purpose, any dissemination or disclosure, either whole
or partial, is prohibited except formal approval. The internet
can not guarantee the integrity of this message.
BNP PARIBAS (and its subsidiaries) shall (will) not
therefore be liable for the message if modified. 

****************************************************************************
******************

BNP Paribas Private Bank London Branch is authorised
by CECEI & AMF and is regulated by the Financial Services
Authority for the conduct of its investment business in
the United Kingdom.

BNP Paribas Securities Services London Branch is authorised 
by CECEI & AMF and is regulated by the Financial Services 
Authority for the conduct of its investment business in 
the United Kingdom.
  
BNP Paribas Fund Services UK Limited is authorised and 
regulated by the Financial Services Authority

_______________________________________________
aspectj-dev mailing list
aspectj-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-dev