Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

AOP and Spring

 
Julio leopard banderas
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can find here some some good materials about AOP:
JBoss AOP and Aspect-oriented Programming.
 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1682
7
Android IntelliJ IDE Linux Mac OS X Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic