This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Aspect Oriented Programming and the fly likes AOP and Spring 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 » Aspect Oriented Programming
Bookmark "AOP and Spring" Watch "AOP and Spring" New topic
Author

AOP and Spring

Julio leopard banderas
Greenhorn

Joined: Dec 20, 2012
Posts: 29
Hey,

i heared about AOP in Spring, but i still confusing the concept of AOP and his utility in Spring,
can anyone give us the concept and the utility to use AOP ?

thanks
Shailesh Phatak
Ranch Hand

Joined: Aug 27, 2009
Posts: 64
Julio leopard banderas wrote:Hey,

i heared about AOP in Spring, but i still confusing the concept of AOP and his utility in Spring,
can anyone give us the concept and the utility to use AOP ?

thanks


Hi Julio,

I too learning AOP in Spring these days, I can help you in understanding what AOP is and its utility in any web application.

Suppose you have a class say Audience and in that class you have methods say
1) takeSeats()
2) switchOffMobile()
3) appluad()

Also you have a pojo class say Compititor which is having fields Name and Instrument

we have a class ShowStarting which look like this once you initialized bean for Competitor and Audience



You can eliminate these cross cutting concerns and allow Spring to handle these. This is one of the advantage of AOP.
These cross cutting concerns you have to write in an xml to tell spring when and where to call them.


See Dreams With Open Eyes And Make It Real
Hussein Baghdadi
clojure forum advocate
Bartender

Joined: Nov 08, 2003
Posts: 3476

You can find here some some good materials about AOP:
JBoss AOP and Aspect-oriented Programming.
Hussein Baghdadi
clojure forum advocate
Bartender

Joined: Nov 08, 2003
Posts: 3476

Shailesh Phatak wrote:
Julio leopard banderas wrote:Hey,

i heared about AOP in Spring, but i still confusing the concept of AOP and his utility in Spring,
can anyone give us the concept and the utility to use AOP ?

thanks


Hi Julio,

I too learning AOP in Spring these days, I can help you in understanding what AOP is and its utility in any web application.

Suppose you have a class say Audience and in that class you have methods say
1) takeSeats()
2) switchOffMobile()
3) appluad()

Also you have a pojo class say Compititor which is having fields Name and Instrument

we have a class ShowStarting which look like this once you initialized bean for Competitor and Audience



You can eliminate these cross cutting concerns and allow Spring to handle these. This is one of the advantage of AOP.
These cross cutting concerns you have to write in an xml to tell spring when and where to call them.


I'm not sure how your example is going to explain AOP but maybe it is just me.

It is worth noting that XML isn't the only way to configure your Aspects, you can also use annotations.
Bill Gorder
Bartender

Joined: Mar 07, 2010
Posts: 1646
    
    7

Spring uses aspects behind the scenes to do many of the things you probably use. Any cross cutting concern is a good candidate such as security, logging, and transactions. You can leverage spring-aop to create your own aspects or use AspectJ with Spring for even more powerful constructs. As was said with Spring AOP you can take an annotation or xml configuration approach. When using AspectJ you can also use the AspectJ language (to write .aj files).

One example of how this is used is the @Transactional annotation. Typically there would be a lot of boiler plate around creating transactions, committing them and rolling them back. Some of this would have to happen before the database operation and some of it after. AspectJ is used to inject code before and after a method annotated with @Transactional so that you no longer have to do this things every single time you wish to use transactions.


[How To Ask Questions][Read before you PM me]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: AOP and Spring
 
Similar Threads
AOP
Spring AOP / Spring AOP + AspectJ ?
AOP
Help Needed in AOP
Seam AOP