• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

What is AOP in spring framwork? and its deifferences with DI?

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can anyone explain what is AOP in spring and its diferences with DI?
 
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
AOP (Aspected-oriented programming) and DI (Dependency Injection) are two different concepts, which happen to be two of the main concepts on and around which the Spring framework is built.
I suggest you google a bit on both to find some more references.
 
author
Posts: 422
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Riyaz Abdul Kareem:
Can anyone explain what is AOP in spring and its diferences with DI?



Dependency Injection (DI) is basically a programming model where object are given other objects that they depend upon. This is in contrast to a more conventional model where objects create or lookup objects that they depend upon. The downside of creating or looking up your own dependencies is that you are coupled to those dependencies and can't exist without them. With DI, however, you are given your dependencies, typically by a container. When used along with interfaces, you only know about your dependencies through their interface...you know nothing of how they are created or how they're implemented. You could be dealing with a local POJO, a remote web service, an EJB, or a mock implementation...you don't know and you don't care. As long as the object your given lives up to the requirements of its interface, you are happy.

AOP is a way of applying common functionality across multiple points in an application, without those points being aware that the functionality is being applied. A typical example of AOP is the use of declarative transactions. Without AOP, you might go to the effort of starting a transaction, performing your database work, then either committing or rolling back the transaction depending on whether or not the DB work was a success. No big deal, except that transaction management is probably not a core concern of your saveEmployeeInfo() method--the chief concern of that method is saving an employee's information. Using AOP, you can extract the transaction management functionality into an aspect, and then declaratively select places to apply it. Your saveEmployeeInfo() method now focuses solely on saving an employee's info and how no idea that it will be wrapped in an aspect that will start and then either commit or roll back a transaction.

So, in short, both DI and AOP are mechanisms for removing coupling from code. DI removes coupling between application objects, while AOP decouples application concerns.
 
Riyaz Abdul Kareem
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Craig,

Great Content on DI and Aop, Thanks a lot...
I also got some idea on local POJO.
Sure will dig more on POJOS.

If i'm not wrong AOP means that its aspect oriented programming.
For example writing the logs in java classes.

Craig, Why i ask these many questions because i'm going to handle a
basic session on spring framework.

Thanks
riyaz
 
Craig Walls
author
Posts: 422
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Riyaz Abdul Kareem:
Hi Craig,
Great Content on DI and Aop, Thanks a lot...
I also got some idea on local POJO.
Sure will dig more on POJOS.



Not much to dig on there, really. POJO is just "plain-old Java object". Everybody has a differing opinion on how "plain" a POJO must be to be considered a POJO, but in essence, it's an object that does not extend any class or implement any interface that isn't part of your application (or perhaps part of the JDK, but that part's debatable).


If i'm not wrong AOP means that its aspect oriented programming.
For example writing the logs in java classes.



Well, logging is only the "textbook" case for AOP. It's hardly the most powerful or most beneficial use of AOP.

As I mentioned, transactions are a much more interesting use of AOP than logging. Method-level security and caching are two more interesting uses of AOP. (BTW, Spring provides transaction aspect, Spring Security provides security aspects, and Spring Modules provides caching aspects).

Even then security, transactions, and caching are textbook cases for AOP...just more advanced textbook cases. There are some really smart folks out there who have figured out how to use AOP in even more interesting ways. My friend Ramnivas Laddad and Adrian Colyer are two folks who really get AOP. Both are on the Spring team, and Ramnivas has written "AspectJ in Action". If you get a chance to read anything they've written or hear them speak, I recommend that you do so. There's some good stuff in the "AOP @ Work" series, too: http://www-128.ibm.com/developerworks/views/java/libraryview.jsp?search_by=AOP@work:
 
Riyaz Abdul Kareem
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Craig.

Sure i will look into this book "AspectJ in Action".
If any good resource on AOP & POJOS.
Please send it across to this mail id
rezz123@rediffmail.com

Still i'm not clear on POJOS. I just understand that
it is used as business object like EJB. If am i not wrong.

Thanks,
Riyaz
 
I’m tired of walking, and will rest for a minute and grow some wheels. This is the promise of this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic