0

Spring AOP depends on proxy mechanism - J2SE dynamic proxies or using CGLIB(according to the spring documentation). Is it possible to use the AOP mechanism defined by Spring without creating/declaring the beans in the spring application context?

If its not possible with Spring - is AspectJ's Load time Weaving(LTW) or Compile Time Weaving (CTW) would help resolve the issue?

Requirement : Trying to implement logging and transaction management for a old project of mine without declaring the POJO's as spring beans.

Bharath ABK
  • 324
  • 3
  • 4
  • 16

2 Answers2

2

No, you have to put them under Spring's control. You can't ask Spring to advise beans that it doesn't know about.

No calls to "new"; have to replace those with application context.

duffymo
  • 305,152
  • 44
  • 369
  • 561
1

As stated by @duffymo Spring can only operate on beans declared within its context.

AspectJ, both LTW and CTW, can be used to achieve what you want.

Another tools you might consider is Byteman, which operate at a lower level but has also a lower overhead if performance is an issue for you.

gizmo
  • 11,819
  • 6
  • 44
  • 61