Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Using Reflection to determine method invocation  RSS feed

 
Tony Moses
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to determine when a specific method is executed (not just declared). Is there any way to use the Reflection API (or any other API) to determine when a specific method is invoked/executed? Thanks.
 
Rob Spoor
Sheriff
Posts: 20893
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check AspectJ
 
Tony Moses
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob,

Thanks for the tip on AspectJ. I have been able to install AspectJ and get an aspect file to compile. However, I can't get a simple aspect function how I expect it to. The following is my (very simple) aspect class:

public aspect PutAspect {
pointcut putFile(): within(ServerPI) && execution (* *(..));

after(): putFile(){
System.out.println("AspectJ is working on the FTP put");

}
}

A new ServerPI thread gets spawned for every ftp command. I am simply trying to get my aspect object to do a simple sys out println when a ServerPI method is executed. Any idea why the println is working?

I would greatly appreciate any insight on this AOP (AspectJ). Thanks
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!