Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with Spring AOP+AspectJ

 
Vladimir Koba
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all! I want to log every invoke public method in my class. So, i create LoggingAspect class for logging, and configure Spring on xml.
When i start my application, all methods logging three times, for example:
Entering method selectAllCompanies...
Entering method selectAllCompanies...
Entering method selectAllCompanies...

Really, methods invokes one times. I think, that problem in a pointcut, but i'm not sure.

aop-context.xml


LoggingAspect.java
 
Bill Gorder
Bartender
Posts: 1682
7
Android IntelliJ IDE Linux Mac OS X Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think this is fixed in newer versions of Spring.

Your problem I believe is that other proxying is being done on your DAO (Transactional etc) and your advice is being called multiple times before the actual POJO is invoked.

See if this link helps you at all.

http://forum.springframework.net/showthread.php?5528-Advice-called-multiple-times-when-using-AttributeMatchMethodPointCut

Thanks,
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic