Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Fw: aspectj capturing currently executing object

Hi Users,

I need to insert code in a method before return statement. Please help me.


On Wed, Jul 3, 2013 at 3:40 PM, Krishna Jasty <krishna.jasty@xxxxxxx> wrote:
Hi ,
 
My intention is identifying the OutOfMemory exception cases even before occuring.
Most of the times the generated heapdump shows collection classes such as hashmap or arraylist with 80% of heap occupation.
 
So if we identify such objects with collection size crosses a threshold of 100 or say. I want the information to be logged.
While logging the information, i want to print the corresponding object name in the logger.
 
Currently i am making use of only file and line number for this purpose.

Thanks,
Krishnachaitanya Jasty
Tata Consultancy Services
Mailto: krishna.jasty@xxxxxxx
Website: http://www.tcs.com
____________________________________________
Experience certainty. IT Services
Business Solutions
Consulting
____________________________________________


-----aspectj-users-bounces@xxxxxxxxxxx wrote: -----
To: "aspectj-users@xxxxxxxxxxx" <aspectj-users@xxxxxxxxxxx>
From: Alexander Kriegisch
Sent by: aspectj-users-bounces@xxxxxxxxxxx
Date: 07/03/2013 03:23PM
Subject: Re: [aspectj-users] Fw: aspectj capturing currently executing object


Hi Krishna.

Your questions indicate you want to do some kind of run-time analysis, logging, monitoring or debugging. This assumption is speculative though. Anyway, I have a feeling that maybe what you are trying to do might be overkill or at least suboptimal. If you could describe your goal or intent a bit to us, maybe we could suggest a simpler or more elegant way to solve your problem. For instance, I cannot imagine why you would need the source code during runtime. In your earlier example I also thought that you could work with argument binding via this(), target() and args() instead of creating arrays and iterating over them if just your pointcuts were a bit smarter or more precise.

Bottom line: AspectJ is for adding cross-cutting behaviour to your application. What kind of behaviour do you want?

Kind regards
--
Alexander Kriegisch


Am 03.07.2013 um 01:15 schrieb Andy Clement <andrew.clement@xxxxxxxxx>:

Unfortunately the source code line is not captured in the joinpoint object, nor is the entire source encoded in the class file so that the relevant snippet could be extracted at runtime. You'd have to read the relevant source file and pull out the text you need.

cheers,
Andy


On 2 July 2013 06:28, Krishna Jasty <krishna.jasty@xxxxxxx> wrote:
Hi,
 
Is there a way in aspect to read the source line as it is.
Say for example. My Java class code
 
  public static void main(String[] args)throws IOException,SQLException
{
     Vector testvector = new Vector();
      testvector.add("abc");
 }
 
I want to read the source line Vector testvector= new Vector();
When i use
SourceLocation sl =thisJoinPointStaticPart
.getSourceLocation();
 
Which is giving me the file details and line number details but not the source line read ..
 
Thanks,
 



-----Forwarded by Krishna Jasty/BLR/TCS on 07/02/2013 06:40PM -----
To: aspectj-users@xxxxxxxxxxx
From: Krishna Jasty/BLR/TCS
Date: 06/27/2013 03:41PM
Subject: aspectj capturing currently executing object


Hi Users,

Go through the following steps once.
 
1) My Java class code
 
  public static void main(String[] args)throws IOException,SQLException
{
     Vector testvector = new Vector();
      testvector.add("abc");
   }
 
 
2) Aspect Implementation
 
 pointcut allConstructors() : call( * java.util..add(..));
 Object around() : allConstructors() {
 Object[] objarr = thisJoinPoint.getArgs();
 for (int i = 0; i < objarr.length; i++)
{
  System.out.println("object is..."+objarr[i]);//This will give me tha value "abc"
 }
 
Similarly if i want to get the object testvector and i want to perform the testvector.size() operation on it.
How to capture this testvector object, if i use this or getTarget() which is returning null.
Please suggest the way to make it possible.
 
Thanks,
Krishnachaitanya Jasty

=====-----=====-----=====
Notice: The information contained in this e-mail
message and/or attachments to it may contain
confidential or privileged information. If you are
not the intended recipient, any dissemination, use,
review, distribution, printing or copying of the
information contained in this e-mail message
and/or attachments to it are strictly prohibited. If
you have received this communication in error,
please notify us by reply e-mail or telephone and
immediately and permanently delete the message
and any attachments. Thank you


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


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

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



Back to the top