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
http://scrum-master.de


Am 03.07.2013 um 01:15 schrieb Andy Clement <andrew.clem...@gmail.com>:

> 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.ja...@tcs.com> 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@eclipse.org
>> 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@eclipse.org
>> https://dev.eclipse.org/mailman/listinfo/aspectj-users
> 
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
_______________________________________________
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users

Reply via email to