Q. Define Aspect Oriented Programming ( AOP) in Spring ?
A. Aspect Oriented Programming (AOP) complements Object Oriented Programming. Spring is a combination of Object Oriented Programming and AOP.
- Object Oriented Programming- Represented POJO Class
- Aspect Oriented Programming – Represented Modularity.
Every application consist various modules but some modules like transaction management,logging, exception handling and security almost common for all such modules represent multiple type of objects known as crosscutting concern in term of AOP, Aspect enable the modularization of [crosscutting] concern of these modules objects.
Q. Is IoC depend on AOP or Can we use Spring without AOP?
A. Although AOP is very important part of spring but it is not mandatory requirement because IoC container not depend on it.
Q. How many ways of writing a custom AOP?
A. Spring supports two approaches writing custom aspects using either a schema-based approach or the @AspectJ annotation style both of these uses Aspectj pointcut language for weaving under IoC container.
Q. What is aspect?
A. Aspect is a modularization of a concern that cuts across multiple classes. Transaction management is one of the example of a crosscutting concern in enterprise Java applications.
Q. What is join point?
A. The method execution point represents Join point, during the execution of a program such as the execution of a method or the handling of an exception.
Q. What is advice?
A. The job of an aspect at a particular join point is called Advice in term of AOP.
Q. What is pointcut?
A. Pointcut help to define where a particular Aspect should be weaved and its definition matches one or more join points at which advice should be woven.
Q. What is Introduction?
A. An introduction allows adding new methods or attributes to existing classes.
Q. What is Target (object)?
A. Target object also referred to as advised object and it advised by one or more aspects, this object will always be a proxied object.
Q. What is AOP proxy?
A. AOP proxy is an object implemented on spring AOP by using JDK dynamic or a CGLIB proxy in order to implement the aspect contracts in the Spring Framework.
Q. What is weaving?
A. Weaving is the process of applying aspects to a target object to create a new proxied object. This can be done at compile time (like AspectJ Compiler), load time or at run time Spring AOP.
Q. How many types of advice support Spring AOP?
A. Types of advice:
- Before advice: Advice that executes before a join point, but it could not able to stop execution flow proceeding to the join point unless it throws an exception.
- After returning advice: Advice to be executed after a join point completes normally (without throwing an exception).
- After throwing advice: Advice to be executed if a method exits by throwing an exception.
- After (finally) advice: Advice to be executed regardless of the means by which a join point exits (normal or exceptional return).
- Around advice: Work before and after that surrounds a join point such as a method invocation. It is also responsible for choosing whether to proceed to the join point or to shortcut the advised method execution by returning its own return value or throwing an exception.
Q. In which features makes Spring AOP to compatible with Servlet Container unlikely other enterprise framework container?
A. As per my previous answer about spring aop, spring implement pure java (POJO), and does not need to control class loader on JVM.
Q. What are the limitations & capabilities of Spring AOP?
A. The major limitation & capabilities are
- Spring AOP supports only method execution join points not support field interception join points like Aspectj.
- Spring AOP most suitable for resolving common enterprise problem with the help of Spring IoC unlikely to other AOP framework such as Aspectj, capable very deep integration with their implementations.
- Spring AOP framework used with conjunction of IoC including capability of autoproxying, this is a very important difference between other AOP framework, such as advise very fine-grained objects and Aspectj capable to control these object on very efficiently.
Just want to say your article is as astounding. The clarity in your publish is just nice and that i could suppose you’re a professional on this subject. Fine along with your permission let me to grasp your RSS feed to stay up to date with coming near near post. Thanks one million and please carry on the rewarding work.
Thanks for your precious comment. Please find the rss url http://www.javavapor.com/feed/