Spring Aspect Oriented Programming (AOP)

Posted by: | Published: Wednesday, March 16, 2016 | Categories:
1. Explain AOP
 Aspect-oriented programming, or AOP, is a programming technique that allows programmers to modularize crosscutting concerns, or behavior that cuts across the typical divisions of responsibility, such as logging and transaction management.

2. Aspect
The core construct of AOP is the aspect, which encapsulates behaviors affecting multiple classes into reusable modules. It ia a module which has a set of APIs providing cross-cutting requirements. For example, a logging module would be called AOP aspect for logging. An application can have any number of aspects depending on the requirement. In Spring AOP, aspects are implemented using regular classes annotated with the @Aspect annotation (@AspectJ style).

3. What is the difference between concern and cross-cutting concern in Spring AOP
The Concern is behavior we want to have in a module of an application. A Concern may be defined as a functionality we want to implement.
The cross-cutting concern is a concern which is applicable throughout the application and it affects the entire application. For example, logging, security and data transfer are the concerns which are needed in almost every module of an application, hence they are cross-cutting concerns.

4. Join point
The join point represents a point in an application where we can plug-in an AOP aspect. It is the actual place in the application where an action will be taken using Spring AOP framework.

5. Advice
The advice is the actual action that will be taken either before or after the method execution. This is actual piece of code that is invoked during the program execution by the Spring AOP framework.
Spring aspects can work with five kinds of advice:
before: Run advice before the a method execution.
after: Run advice after the a method execution regardless of its outcome.
after-returning: Run advice after the a method execution only if method completes successfully.
after-throwing: Run advice after the a method execution only if method exits by throwing an exception.
around: Run advice before and after the advised method is invoked.

6. Pointcut
The pointcut is a set of one or more joinpoints where an advice should be executed. You can specify pointcuts using expressions or patterns.

7. What is Introduction? An Introduction allows us to add new methods or attributes to existing classes.

8. What is Target object?
The target object is an object being advised by one or more aspects. It will always be a proxy object. It is also referred to as the advised object.

9. What is a Proxy?
A proxy is an object that is created after applying advice to a target object. When you think of client objects the target object and the proxy object are the same.

10. What are the different types of AutoProxying?
BeanNameAutoProxyCreator
DefaultAdvisorAutoProxyCreator
Metadata autoproxying


11. What is Weaving? What are the different points where weaving can be applied?
Weaving is the process of linking aspects with other application types or objects to create an advised object. Weaving can be done at compile time, at load time, or at runtime.

12. Explain XML Schema-based aspect implementation?
In this implementation case, aspects are implemented using regular classes along with XML based configuration.

13. Explain annotation-based (@AspectJ based) aspect implementation
This implementation case (@AspectJ based implementation) refers to a style of declaring aspects as regular Java classes annotated with Java 5 annotations.


Previous
Next Post »

আপনার কোন কিছু জানার থাকলে কমেন্টস বক্স এ লিখতে পারেন। আমরা যথাযত চেস্টা করব আপনার সঠিক উত্তর দিতে। ভালো লাগলে ধন্যবাদ দিতে ভুলবেন না।
- শুভকামনায় ওয়েব স্কুল বিডি
ConversionConversion EmoticonEmoticon