*
The moose likes Spring and the fly likes Spring AOP / Spring AOP + AspectJ ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Spring AOP / Spring AOP + AspectJ ?" Watch "Spring AOP / Spring AOP + AspectJ ?" New topic
Author

Spring AOP / Spring AOP + AspectJ ?

kri shan
Ranch Hand

Joined: Apr 08, 2004
Posts: 1371
Spring AOP itself supports DI/IOC, then why we need AspectJ inegration with Spring AOP. Actually i am planing to use Spring AOP for my application Transaction, can i integegrate AspectJ with Spring AOP (or) just Spring AOP supports Transaction using IOC/DI.
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

You don't actually need to use AspectJ. Spring AOP should be enough in most cases. From the reference documentation :
Spring AOP currently supports only method execution join points (advising the execution of methods on Spring beans). Field interception is not implemented, although support for field interception could be added without breaking the core Spring AOP APIs. If you need to advise field access and update join points, consider a language such as AspectJ.

Spring AOP's approach to AOP differs from that of most other AOP frameworks. The aim is not to provide the most complete AOP implementation (although Spring AOP is quite capable); it is rather to provide a close integration between AOP implementation and Spring IoC to help solve common problems in enterprise applications.

Thus, for example, the Spring Framework's AOP functionality is normally used in conjunction with the Spring IoC container. Aspects are configured using normal bean definition syntax (although this allows powerful "autoproxying" capabilities): this is a crucial difference from other AOP implementations. There are some things you cannot do easily or efficiently with Spring AOP, such as advise very fine-grained objects (such as domain objects typically): AspectJ is the best choice in such cases. However, our experience is that Spring AOP provides an excellent solution to most problems in Java EE applications that are amenable to AOP.

Spring AOP will never strive to compete with AspectJ to provide a comprehensive AOP solution. We believe that both proxy-based frameworks like Spring AOP and full-blown frameworks such as AspectJ are valuable, and that they are complementary, rather than in competition. Spring 2.0 seamlessly integrates Spring AOP and IoC with AspectJ, to enable all uses of AOP to be catered for within a consistent Spring-based application architecture. This integration does not affect the Spring AOP API or the AOP Alliance API: Spring AOP remains backward-compatible.


[My Blog]
All roads lead to JavaRanch
kri shan
Ranch Hand

Joined: Apr 08, 2004
Posts: 1371
Hi Christope,
Aspects are configured using normal bean definition syntax (although this allows powerful "autoproxying" capabilities):

I do not understand what is "autoproxying" ? why Spring framework is called as proxy-based framework ?
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

The beans which become targets to AOP aspects are proxied by Spring. This is done without you knowing it. You still get your beans via their interface, as if nothing happened. But you are actually using a proxy implementing your interface, which does all the cool aop stuff behind the scenes. Check this Journal article.
kri shan
Ranch Hand

Joined: Apr 08, 2004
Posts: 1371
Spring Framework's AOP functionality is normally used in conjunction with the Spring IoC container


Can i use Spring AOP with Spring Application Context(framework oriented way - XML approach)? Spring AOP only works with Spring IOC container?
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

You can use Spring AOP using annotations and autoproxying, or by using the aop namespace in your application context file.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Spring AOP / Spring AOP + AspectJ ?
 
Similar Threads
AOP
uses of aop in spring
Singleton class + DI/IOC
Spring -> Factory Design Pattern / IOC/DI ?
Seam AOP