Win a copy of Java Persistence with Spring Data and Hibernate this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Tim Cooke
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Jeanne Boyarsky
Saloon Keepers:
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Piet Souris
Bartenders:

Spring AOP

 
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a non Spring web app. I want to implement Spring AOP for some of the methods in our app. Those methods are not invoked using Spring Beans at all. Is there anyway we can do this? I would appreciate if someone can provide me with a sample.
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Shiaber Shaam wrote:I have a non Spring web app. I want to implement Spring AOP for some of the methods in our app. Those methods are not invoked using Spring Beans at all. Is there anyway we can do this? I would appreciate if someone can provide me with a sample.



Spring AOP can only advice objects that are Spring Beans. Because it creates DynamicProxies at runtime in the Initialization phase of Spring's ApplicationContext container. And that container only knows about beans you added in Spring configuration (xml, Annotations, or Java Config way)

If you want to get AOP into code you can always just use an AOP framework like AspectJ and do bytecode instrumentation.

Mark
 
This tiny ad is guaranteed to be gluten free.
The Low Tech Laboratory Movie Kickstarter is LIVE NOW!
https://www.kickstarter.com/projects/paulwheaton/low-tech
reply
    Bookmark Topic Watch Topic
  • New Topic